repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
heyui/heyui | src/plugins/popper/index.js | Popper | function Popper(reference, popper) {
var _this = this;
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
classCallCheck(this, Popper);
this.scheduleUpdate = function () {
return requestAnimation(_this.update);
};
// make update() debounced, so that it only runs at most once-per-tick
this.update = debounce(this.update.bind(this));
// with {} we create a new object with the options inside it
this.defaultOptions = options;
this.options = _extends({}, Popper.Defaults, options);
// init state
this.state = {
isDestroyed: false,
isCreated: false,
scrollParents: []
};
// get reference and popper elements (allow jQuery wrappers)
this.reference = reference && reference.jquery ? reference[0] : reference;
this.popper = popper && popper.jquery ? popper[0] : popper;
this.updateModifiers();
// fire the first update to position the popper in the right place
this.update();
var eventsEnabled = this.options.eventsEnabled;
if (eventsEnabled) {
// setup event listeners, they will take care of update the position in specific situations
this.enableEventListeners();
}
this.state.eventsEnabled = eventsEnabled;
} | javascript | function Popper(reference, popper) {
var _this = this;
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
classCallCheck(this, Popper);
this.scheduleUpdate = function () {
return requestAnimation(_this.update);
};
// make update() debounced, so that it only runs at most once-per-tick
this.update = debounce(this.update.bind(this));
// with {} we create a new object with the options inside it
this.defaultOptions = options;
this.options = _extends({}, Popper.Defaults, options);
// init state
this.state = {
isDestroyed: false,
isCreated: false,
scrollParents: []
};
// get reference and popper elements (allow jQuery wrappers)
this.reference = reference && reference.jquery ? reference[0] : reference;
this.popper = popper && popper.jquery ? popper[0] : popper;
this.updateModifiers();
// fire the first update to position the popper in the right place
this.update();
var eventsEnabled = this.options.eventsEnabled;
if (eventsEnabled) {
// setup event listeners, they will take care of update the position in specific situations
this.enableEventListeners();
}
this.state.eventsEnabled = eventsEnabled;
} | [
"function",
"Popper",
"(",
"reference",
",",
"popper",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"var",
"options",
"=",
"arguments",
".",
"length",
">",
"2",
"&&",
"arguments",
"[",
"2",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"2",
"]",
":"... | Create a new Popper.js instance
@class Popper
@param {HTMLElement|referenceObject} reference - The reference element used to position the popper
@param {HTMLElement} popper - The HTML element used as popper.
@param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
@return {Object} instance - The generated Popper.js instance | [
"Create",
"a",
"new",
"Popper",
".",
"js",
"instance"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L2433-L2473 | train | Construct a new Popper instance | [
30522,
3853,
3769,
4842,
1006,
4431,
1010,
3769,
4842,
1007,
1063,
13075,
1035,
2023,
1027,
2023,
1025,
13075,
7047,
1027,
9918,
1012,
3091,
1028,
1016,
1004,
1004,
9918,
1031,
1016,
1033,
999,
1027,
1027,
6151,
28344,
1029,
9918,
1031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
badges/shields | core/badge-urls/path-helpers.js | escapeFormat | function escapeFormat(t) {
return (
t
// Inline single underscore.
.replace(/([^_])_([^_])/g, '$1 $2')
// Leading or trailing underscore.
.replace(/([^_])_$/, '$1 ')
.replace(/^_([^_])/, ' $1')
// Double underscore and double dash.
.replace(/__/g, '_')
.replace(/--/g, '-')
)
} | javascript | function escapeFormat(t) {
return (
t
// Inline single underscore.
.replace(/([^_])_([^_])/g, '$1 $2')
// Leading or trailing underscore.
.replace(/([^_])_$/, '$1 ')
.replace(/^_([^_])/, ' $1')
// Double underscore and double dash.
.replace(/__/g, '_')
.replace(/--/g, '-')
)
} | [
"function",
"escapeFormat",
"(",
"t",
")",
"{",
"return",
"(",
"t",
"// Inline single underscore.",
".",
"replace",
"(",
"/",
"([^_])_([^_])",
"/",
"g",
",",
"'$1 $2'",
")",
"// Leading or trailing underscore.",
".",
"replace",
"(",
"/",
"([^_])_$",
"/",
",",
... | Escapes `t` using the format specified in <https://github.com/espadrine/gh-badges/issues/12#issuecomment-31518129> | [
"Escapes",
"t",
"using",
"the",
"format",
"specified",
"in",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"espadrine",
"/",
"gh",
"-",
"badges",
"/",
"issues",
"/",
"12#issuecomment",
"-",
"31518129",
">"
] | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/core/badge-urls/path-helpers.js#L5-L17 | train | Escape a format string | [
30522,
3853,
4019,
14192,
4017,
1006,
1056,
1007,
1063,
2709,
1006,
1056,
1013,
1013,
23881,
2309,
2104,
9363,
2890,
1012,
1012,
5672,
1006,
1013,
1006,
1031,
1034,
1035,
1033,
1007,
1035,
1006,
1031,
1034,
1035,
1033,
1007,
1013,
1043,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/semi-style.js | getChildren | function getChildren(node) {
const t = node.type;
if (t === "BlockStatement" || t === "Program") {
return node.body;
}
if (t === "SwitchCase") {
return node.consequent;
}
return null;
} | javascript | function getChildren(node) {
const t = node.type;
if (t === "BlockStatement" || t === "Program") {
return node.body;
}
if (t === "SwitchCase") {
return node.consequent;
}
return null;
} | [
"function",
"getChildren",
"(",
"node",
")",
"{",
"const",
"t",
"=",
"node",
".",
"type",
";",
"if",
"(",
"t",
"===",
"\"BlockStatement\"",
"||",
"t",
"===",
"\"Program\"",
")",
"{",
"return",
"node",
".",
"body",
";",
"}",
"if",
"(",
"t",
"===",
"... | Get the child node list of a given node.
This returns `Program#body`, `BlockStatement#body`, or `SwitchCase#consequent`.
This is used to check whether a node is the first/last child.
@param {Node} node A node to get child node list.
@returns {Node[]|null} The child node list. | [
"Get",
"the",
"child",
"node",
"list",
"of",
"a",
"given",
"node",
".",
"This",
"returns",
"Program#body",
"BlockStatement#body",
"or",
"SwitchCase#consequent",
".",
"This",
"is",
"used",
"to",
"check",
"whether",
"a",
"node",
"is",
"the",
"first",
"/",
"las... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi-style.js#L35-L45 | train | Get the children of a node | [
30522,
3853,
2131,
19339,
7389,
1006,
13045,
1007,
1063,
9530,
3367,
1056,
1027,
13045,
1012,
2828,
1025,
2065,
1006,
1056,
1027,
1027,
1027,
1000,
5991,
12259,
3672,
1000,
1064,
1064,
1056,
1027,
1027,
1027,
1000,
2565,
1000,
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... |
aws/aws-sdk-js | lib/services/s3.js | addContentType | function addContentType(req) {
var httpRequest = req.httpRequest;
if (httpRequest.method === 'GET' || httpRequest.method === 'HEAD') {
// Content-Type is not set in GET/HEAD requests
delete httpRequest.headers['Content-Type'];
return;
}
if (!httpRequest.headers['Content-Type']) { // always have a Content-Type
httpRequest.headers['Content-Type'] = 'application/octet-stream';
}
var contentType = httpRequest.headers['Content-Type'];
if (AWS.util.isBrowser()) {
if (typeof httpRequest.body === 'string' && !contentType.match(/;\s*charset=/)) {
var charset = '; charset=UTF-8';
httpRequest.headers['Content-Type'] += charset;
} else {
var replaceFn = function(_, prefix, charsetName) {
return prefix + charsetName.toUpperCase();
};
httpRequest.headers['Content-Type'] =
contentType.replace(/(;\s*charset=)(.+)$/, replaceFn);
}
}
} | javascript | function addContentType(req) {
var httpRequest = req.httpRequest;
if (httpRequest.method === 'GET' || httpRequest.method === 'HEAD') {
// Content-Type is not set in GET/HEAD requests
delete httpRequest.headers['Content-Type'];
return;
}
if (!httpRequest.headers['Content-Type']) { // always have a Content-Type
httpRequest.headers['Content-Type'] = 'application/octet-stream';
}
var contentType = httpRequest.headers['Content-Type'];
if (AWS.util.isBrowser()) {
if (typeof httpRequest.body === 'string' && !contentType.match(/;\s*charset=/)) {
var charset = '; charset=UTF-8';
httpRequest.headers['Content-Type'] += charset;
} else {
var replaceFn = function(_, prefix, charsetName) {
return prefix + charsetName.toUpperCase();
};
httpRequest.headers['Content-Type'] =
contentType.replace(/(;\s*charset=)(.+)$/, replaceFn);
}
}
} | [
"function",
"addContentType",
"(",
"req",
")",
"{",
"var",
"httpRequest",
"=",
"req",
".",
"httpRequest",
";",
"if",
"(",
"httpRequest",
".",
"method",
"===",
"'GET'",
"||",
"httpRequest",
".",
"method",
"===",
"'HEAD'",
")",
"{",
"// Content-Type is not set i... | Adds a default content type if none is supplied.
@api private | [
"Adds",
"a",
"default",
"content",
"type",
"if",
"none",
"is",
"supplied",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L272-L298 | train | Add Content - Type header | [
30522,
3853,
5587,
8663,
6528,
15353,
5051,
1006,
2128,
4160,
1007,
1063,
13075,
8299,
2890,
15500,
1027,
2128,
4160,
1012,
8299,
2890,
15500,
1025,
2065,
1006,
8299,
2890,
15500,
1012,
4118,
1027,
1027,
1027,
1005,
2131,
1005,
30524,
4118,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/services/s3.js | upload | function upload(params, options, callback) {
if (typeof options === 'function' && callback === undefined) {
callback = options;
options = null;
}
options = options || {};
options = AWS.util.merge(options || {}, {service: this, params: params});
var uploader = new AWS.S3.ManagedUpload(options);
if (typeof callback === 'function') uploader.send(callback);
return uploader;
} | javascript | function upload(params, options, callback) {
if (typeof options === 'function' && callback === undefined) {
callback = options;
options = null;
}
options = options || {};
options = AWS.util.merge(options || {}, {service: this, params: params});
var uploader = new AWS.S3.ManagedUpload(options);
if (typeof callback === 'function') uploader.send(callback);
return uploader;
} | [
"function",
"upload",
"(",
"params",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
"&&",
"callback",
"===",
"undefined",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"null",
";",
"}",
"optio... | @see AWS.S3.ManagedUpload
@overload upload(params = {}, [options], [callback])
Uploads an arbitrarily sized buffer, blob, or stream, using intelligent
concurrent handling of parts if the payload is large enough. You can
configure the concurrent queue size by setting `options`. Note that this
is the only operation for which the SDK can retry requests with stream
bodies.
@param (see AWS.S3.putObject)
@option (see AWS.S3.ManagedUpload.constructor)
@return [AWS.S3.ManagedUpload] the managed upload object that can call
`send()` or track progress.
@example Uploading a stream object
var params = {Bucket: 'bucket', Key: 'key', Body: stream};
s3.upload(params, function(err, data) {
console.log(err, data);
});
@example Uploading a stream with concurrency of 1 and partSize of 10mb
var params = {Bucket: 'bucket', Key: 'key', Body: stream};
var options = {partSize: 10 * 1024 * 1024, queueSize: 1};
s3.upload(params, options, function(err, data) {
console.log(err, data);
});
@callback callback function(err, data)
@param err [Error] an error or null if no error occurred.
@param data [map] The response data from the successful upload:
@param data.Location [String] the URL of the uploaded object
@param data.ETag [String] the ETag of the uploaded object
@param data.Bucket [String] the bucket to which the object was uploaded
@param data.Key [String] the key to which the object was uploaded | [
"@see",
"AWS",
".",
"S3",
".",
"ManagedUpload",
"@overload",
"upload",
"(",
"params",
"=",
"{}",
"[",
"options",
"]",
"[",
"callback",
"]",
")",
"Uploads",
"an",
"arbitrarily",
"sized",
"buffer",
"blob",
"or",
"stream",
"using",
"intelligent",
"concurrent",
... | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L1072-L1084 | train | Upload a new resource to the specified bucket | [
30522,
3853,
2039,
11066,
1006,
11498,
5244,
1010,
7047,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
2828,
11253,
7047,
1027,
1027,
1027,
1005,
3853,
1005,
1004,
1004,
2655,
5963,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
2655,
5963,
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... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (wait, hold, route)
{
this.wait = wait || this.wait;
this.hold = hold || this.hold;
this.errors = 0;
// build the body tag
var body = this._buildBody().attrs({
to: this._conn.domain,
"xml:lang": "en",
wait: this.wait,
hold: this.hold,
content: "text/xml; charset=utf-8",
ver: "1.6",
"xmpp:version": "1.0",
"xmlns:xmpp": Strophe.NS.BOSH
});
if(route){
body.attrs({
route: route
});
}
var _connect_cb = this._conn._connect_cb;
this._requests.push(
new Strophe.Request(body.tree(),
this._onRequestStateChange.bind(
this, _connect_cb.bind(this._conn)),
body.tree().getAttribute("rid")));
this._throttledRequestHandler();
} | javascript | function (wait, hold, route)
{
this.wait = wait || this.wait;
this.hold = hold || this.hold;
this.errors = 0;
// build the body tag
var body = this._buildBody().attrs({
to: this._conn.domain,
"xml:lang": "en",
wait: this.wait,
hold: this.hold,
content: "text/xml; charset=utf-8",
ver: "1.6",
"xmpp:version": "1.0",
"xmlns:xmpp": Strophe.NS.BOSH
});
if(route){
body.attrs({
route: route
});
}
var _connect_cb = this._conn._connect_cb;
this._requests.push(
new Strophe.Request(body.tree(),
this._onRequestStateChange.bind(
this, _connect_cb.bind(this._conn)),
body.tree().getAttribute("rid")));
this._throttledRequestHandler();
} | [
"function",
"(",
"wait",
",",
"hold",
",",
"route",
")",
"{",
"this",
".",
"wait",
"=",
"wait",
"||",
"this",
".",
"wait",
";",
"this",
".",
"hold",
"=",
"hold",
"||",
"this",
".",
"hold",
";",
"this",
".",
"errors",
"=",
"0",
";",
"// build the ... | PrivateFunction: _connect
_Private_ function that initializes the BOSH connection.
Creates and sends the Request that initializes the BOSH connection. | [
"PrivateFunction",
":",
"_connect",
"_Private_",
"function",
"that",
"initializes",
"the",
"BOSH",
"connection",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4067-L4099 | train | An object that represents a single node in the cluster. | [
30522,
3853,
1006,
3524,
1010,
2907,
1010,
2799,
1007,
1063,
2023,
1012,
3524,
1027,
3524,
1064,
1064,
2023,
1012,
3524,
1025,
2023,
1012,
2907,
1027,
2907,
1064,
1064,
2023,
1012,
2907,
1025,
2023,
1012,
10697,
1027,
1014,
1025,
1013,
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... | |
aws/aws-sdk-js | lib/param_validator.js | ParamValidator | function ParamValidator(validation) {
if (validation === true || validation === undefined) {
validation = {'min': true};
}
this.validation = validation;
} | javascript | function ParamValidator(validation) {
if (validation === true || validation === undefined) {
validation = {'min': true};
}
this.validation = validation;
} | [
"function",
"ParamValidator",
"(",
"validation",
")",
"{",
"if",
"(",
"validation",
"===",
"true",
"||",
"validation",
"===",
"undefined",
")",
"{",
"validation",
"=",
"{",
"'min'",
":",
"true",
"}",
";",
"}",
"this",
".",
"validation",
"=",
"validation",
... | Create a new validator object.
@param validation [Boolean|map] whether input parameters should be
validated against the operation description before sending the
request. Pass a map to enable any of the following specific
validation features:
* **min** [Boolean] — Validates that a value meets the min
constraint. This is enabled by default when paramValidation is set
to `true`.
* **max** [Boolean] — Validates that a value meets the max
constraint.
* **pattern** [Boolean] — Validates that a string value matches a
regular expression.
* **enum** [Boolean] — Validates that a string value matches one
of the allowable enum values. | [
"Create",
"a",
"new",
"validator",
"object",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/param_validator.js#L25-L30 | train | A validator for the param | [
30522,
3853,
11498,
2213,
10175,
8524,
4263,
1006,
27354,
1007,
1063,
2065,
1006,
27354,
1027,
1027,
1027,
2995,
1064,
1064,
27354,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
27354,
1027,
1063,
1005,
8117,
1005,
1024,
2995,
1065,
1025,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/Painter.js | function (cb, context) {
var zlevelList = this._zlevelList;
var z;
var i;
for (i = 0; i < zlevelList.length; i++) {
z = zlevelList[i];
cb.call(context, this._layers[z], z);
}
} | javascript | function (cb, context) {
var zlevelList = this._zlevelList;
var z;
var i;
for (i = 0; i < zlevelList.length; i++) {
z = zlevelList[i];
cb.call(context, this._layers[z], z);
}
} | [
"function",
"(",
"cb",
",",
"context",
")",
"{",
"var",
"zlevelList",
"=",
"this",
".",
"_zlevelList",
";",
"var",
"z",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"zlevelList",
".",
"length",
";",
"i",
"++",
")",
"{",
"z",
... | Iterate each layer | [
"Iterate",
"each",
"layer"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/Painter.js#L634-L642 | train | call the callback for each layer | [
30522,
3853,
1006,
17324,
1010,
6123,
1007,
1063,
13075,
1062,
20414,
13348,
3367,
1027,
2023,
1012,
1035,
1062,
20414,
13348,
3367,
1025,
13075,
1062,
1025,
13075,
1045,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
1062,
20414,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aws/aws-sdk-js | lib/credentials/chainable_temporary_credentials.js | ChainableTemporaryCredentials | function ChainableTemporaryCredentials(options) {
AWS.Credentials.call(this);
options = options || {};
this.errorCode = 'ChainableTemporaryCredentialsProviderFailure';
this.expired = true;
this.tokenCodeFn = null;
var params = AWS.util.copy(options.params) || {};
if (params.RoleArn) {
params.RoleSessionName = params.RoleSessionName || 'temporary-credentials';
}
if (params.SerialNumber) {
if (!options.tokenCodeFn || (typeof options.tokenCodeFn !== 'function')) {
throw new AWS.util.error(
new Error('tokenCodeFn must be a function when params.SerialNumber is given'),
{code: this.errorCode}
);
} else {
this.tokenCodeFn = options.tokenCodeFn;
}
}
this.service = new STS({
params: params,
credentials: options.masterCredentials || AWS.config.credentials
});
} | javascript | function ChainableTemporaryCredentials(options) {
AWS.Credentials.call(this);
options = options || {};
this.errorCode = 'ChainableTemporaryCredentialsProviderFailure';
this.expired = true;
this.tokenCodeFn = null;
var params = AWS.util.copy(options.params) || {};
if (params.RoleArn) {
params.RoleSessionName = params.RoleSessionName || 'temporary-credentials';
}
if (params.SerialNumber) {
if (!options.tokenCodeFn || (typeof options.tokenCodeFn !== 'function')) {
throw new AWS.util.error(
new Error('tokenCodeFn must be a function when params.SerialNumber is given'),
{code: this.errorCode}
);
} else {
this.tokenCodeFn = options.tokenCodeFn;
}
}
this.service = new STS({
params: params,
credentials: options.masterCredentials || AWS.config.credentials
});
} | [
"function",
"ChainableTemporaryCredentials",
"(",
"options",
")",
"{",
"AWS",
".",
"Credentials",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"errorCode",
"=",
"'ChainableTemporaryCredentialsProviderFailure'",
... | Creates a new temporary credentials object.
@param options [map] a set of options
@option options params [map] ({}) a map of options that are passed to the
{AWS.STS.assumeRole} or {AWS.STS.getSessionToken} operations.
If a `RoleArn` parameter is passed in, credentials will be based on the
IAM role. If a `SerialNumber` parameter is passed in, {tokenCodeFn} must
also be passed in or an error will be thrown.
@option options masterCredentials [AWS.Credentials] the master credentials
used to get and refresh temporary credentials from AWS STS. By default,
AWS.config.credentials or AWS.config.credentialProvider will be used.
@option options tokenCodeFn [Function] (null) Function to provide
`TokenCode`, if `SerialNumber` is provided for profile in {params}. Function
is called with value of `SerialNumber` and `callback`, and should provide
the `TokenCode` or an error to the callback in the format
`callback(err, token)`.
@example Creating a new credentials object for generic temporary credentials
AWS.config.credentials = new AWS.ChainableTemporaryCredentials();
@example Creating a new credentials object for an IAM role
AWS.config.credentials = new AWS.ChainableTemporaryCredentials({
params: {
RoleArn: 'arn:aws:iam::1234567890:role/TemporaryCredentials'
}
});
@see AWS.STS.assumeRole
@see AWS.STS.getSessionToken | [
"Creates",
"a",
"new",
"temporary",
"credentials",
"object",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/chainable_temporary_credentials.js#L101-L126 | train | Creates a new temporary credentials object. | [
30522,
3853,
4677,
3085,
18532,
17822,
5649,
16748,
16454,
26340,
1006,
7047,
1007,
1063,
22091,
2015,
1012,
22496,
1012,
2655,
1006,
2023,
1007,
1025,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2023,
1012,
7561,
16044,
1027,
1005,
467... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/strict.js | reportSlice | function reportSlice(nodes, start, end, messageId, fix) {
nodes.slice(start, end).forEach(node => {
context.report({ node, messageId, fix: fix ? getFixFunction(node) : null });
});
} | javascript | function reportSlice(nodes, start, end, messageId, fix) {
nodes.slice(start, end).forEach(node => {
context.report({ node, messageId, fix: fix ? getFixFunction(node) : null });
});
} | [
"function",
"reportSlice",
"(",
"nodes",
",",
"start",
",",
"end",
",",
"messageId",
",",
"fix",
")",
"{",
"nodes",
".",
"slice",
"(",
"start",
",",
"end",
")",
".",
"forEach",
"(",
"node",
"=>",
"{",
"context",
".",
"report",
"(",
"{",
"node",
","... | Report a slice of an array of nodes with a given message.
@param {ASTNode[]} nodes Nodes.
@param {string} start Index to start from.
@param {string} end Index to end before.
@param {string} messageId Message to display.
@param {boolean} fix `true` if the directive should be fixed (i.e. removed)
@returns {void} | [
"Report",
"a",
"slice",
"of",
"an",
"array",
"of",
"nodes",
"with",
"a",
"given",
"message",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/strict.js#L140-L144 | train | Reports a slice of nodes | [
30522,
3853,
4311,
13231,
1006,
14164,
1010,
2707,
1010,
2203,
1010,
4471,
3593,
1010,
8081,
1007,
1063,
14164,
1012,
14704,
1006,
2707,
1010,
2203,
1007,
1012,
18921,
6776,
1006,
13045,
1027,
1028,
1063,
6123,
1012,
3189,
1006,
1063,
13045... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/data/importer/index.js | function (items) {
return '+(' + _.reduce(items, function (memo, ext) {
return memo !== '' ? memo + '|' + ext : ext;
}, '') + ')';
} | javascript | function (items) {
return '+(' + _.reduce(items, function (memo, ext) {
return memo !== '' ? memo + '|' + ext : ext;
}, '') + ')';
} | [
"function",
"(",
"items",
")",
"{",
"return",
"'+('",
"+",
"_",
".",
"reduce",
"(",
"items",
",",
"function",
"(",
"memo",
",",
"ext",
")",
"{",
"return",
"memo",
"!==",
"''",
"?",
"memo",
"+",
"'|'",
"+",
"ext",
":",
"ext",
";",
"}",
",",
"''"... | Convert items into a glob string
@param {String[]} items
@returns {String} | [
"Convert",
"items",
"into",
"a",
"glob",
"string"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/data/importer/index.js#L72-L76 | train | Returns a string that can be used to create a log file for a log file. | [
30522,
3853,
1006,
5167,
1007,
1063,
2709,
1005,
1009,
1006,
1005,
1009,
1035,
1012,
5547,
1006,
5167,
1010,
3853,
1006,
24443,
1010,
4654,
2102,
1007,
1063,
2709,
24443,
999,
1027,
1027,
1005,
1005,
1029,
24443,
1009,
1005,
1064,
1005,
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... | |
electron/electron | lib/renderer/api/remote.js | proxyFunctionProperties | function proxyFunctionProperties (remoteMemberFunction, metaId, name) {
let loaded = false
// Lazily load function properties
const loadRemoteProperties = () => {
if (loaded) return
loaded = true
const command = 'ELECTRON_BROWSER_MEMBER_GET'
const meta = ipcRendererInternal.sendSync(command, contextId, metaId, name)
setObjectMembers(remoteMemberFunction, remoteMemberFunction, meta.id, meta.members)
}
return new Proxy(remoteMemberFunction, {
set: (target, property, value, receiver) => {
if (property !== 'ref') loadRemoteProperties()
target[property] = value
return true
},
get: (target, property, receiver) => {
if (!target.hasOwnProperty(property)) loadRemoteProperties()
const value = target[property]
if (property === 'toString' && typeof value === 'function') {
return value.bind(target)
}
return value
},
ownKeys: (target) => {
loadRemoteProperties()
return Object.getOwnPropertyNames(target)
},
getOwnPropertyDescriptor: (target, property) => {
const descriptor = Object.getOwnPropertyDescriptor(target, property)
if (descriptor) return descriptor
loadRemoteProperties()
return Object.getOwnPropertyDescriptor(target, property)
}
})
} | javascript | function proxyFunctionProperties (remoteMemberFunction, metaId, name) {
let loaded = false
// Lazily load function properties
const loadRemoteProperties = () => {
if (loaded) return
loaded = true
const command = 'ELECTRON_BROWSER_MEMBER_GET'
const meta = ipcRendererInternal.sendSync(command, contextId, metaId, name)
setObjectMembers(remoteMemberFunction, remoteMemberFunction, meta.id, meta.members)
}
return new Proxy(remoteMemberFunction, {
set: (target, property, value, receiver) => {
if (property !== 'ref') loadRemoteProperties()
target[property] = value
return true
},
get: (target, property, receiver) => {
if (!target.hasOwnProperty(property)) loadRemoteProperties()
const value = target[property]
if (property === 'toString' && typeof value === 'function') {
return value.bind(target)
}
return value
},
ownKeys: (target) => {
loadRemoteProperties()
return Object.getOwnPropertyNames(target)
},
getOwnPropertyDescriptor: (target, property) => {
const descriptor = Object.getOwnPropertyDescriptor(target, property)
if (descriptor) return descriptor
loadRemoteProperties()
return Object.getOwnPropertyDescriptor(target, property)
}
})
} | [
"function",
"proxyFunctionProperties",
"(",
"remoteMemberFunction",
",",
"metaId",
",",
"name",
")",
"{",
"let",
"loaded",
"=",
"false",
"// Lazily load function properties",
"const",
"loadRemoteProperties",
"=",
"(",
")",
"=>",
"{",
"if",
"(",
"loaded",
")",
"ret... | Wrap function in Proxy for accessing remote properties | [
"Wrap",
"function",
"in",
"Proxy",
"for",
"accessing",
"remote",
"properties"
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/lib/renderer/api/remote.js#L174-L211 | train | Proxy function properties to the remote member function | [
30522,
3853,
24540,
11263,
27989,
21572,
4842,
7368,
1006,
6556,
4168,
21784,
11263,
27989,
1010,
18804,
3593,
1010,
2171,
1007,
1063,
2292,
8209,
1027,
6270,
1013,
1013,
2474,
28431,
7170,
3853,
5144,
9530,
3367,
7170,
28578,
12184,
21572,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc | examples/node/dynamic_codegen/route_guide/route_guide_client.js | runListFeatures | function runListFeatures(callback) {
var rectangle = {
lo: {
latitude: 400000000,
longitude: -750000000
},
hi: {
latitude: 420000000,
longitude: -730000000
}
};
console.log('Looking for features between 40, -75 and 42, -73');
var call = client.listFeatures(rectangle);
call.on('data', function(feature) {
console.log('Found feature called "' + feature.name + '" at ' +
feature.location.latitude/COORD_FACTOR + ', ' +
feature.location.longitude/COORD_FACTOR);
});
call.on('end', callback);
} | javascript | function runListFeatures(callback) {
var rectangle = {
lo: {
latitude: 400000000,
longitude: -750000000
},
hi: {
latitude: 420000000,
longitude: -730000000
}
};
console.log('Looking for features between 40, -75 and 42, -73');
var call = client.listFeatures(rectangle);
call.on('data', function(feature) {
console.log('Found feature called "' + feature.name + '" at ' +
feature.location.latitude/COORD_FACTOR + ', ' +
feature.location.longitude/COORD_FACTOR);
});
call.on('end', callback);
} | [
"function",
"runListFeatures",
"(",
"callback",
")",
"{",
"var",
"rectangle",
"=",
"{",
"lo",
":",
"{",
"latitude",
":",
"400000000",
",",
"longitude",
":",
"-",
"750000000",
"}",
",",
"hi",
":",
"{",
"latitude",
":",
"420000000",
",",
"longitude",
":",
... | Run the listFeatures demo. Calls listFeatures with a rectangle containing all
of the features in the pre-generated database. Prints each response as it
comes in.
@param {function} callback Called when this demo is complete | [
"Run",
"the",
"listFeatures",
"demo",
".",
"Calls",
"listFeatures",
"with",
"a",
"rectangle",
"containing",
"all",
"of",
"the",
"features",
"in",
"the",
"pre",
"-",
"generated",
"database",
".",
"Prints",
"each",
"response",
"as",
"it",
"comes",
"in",
"."
] | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/dynamic_codegen/route_guide/route_guide_client.js#L83-L102 | train | List features between 40 - 75 and 42 - 74 | [
30522,
3853,
2448,
9863,
7959,
4017,
14900,
1006,
2655,
5963,
1007,
1063,
13075,
28667,
23395,
1027,
1063,
8840,
1024,
1063,
15250,
1024,
20143,
8889,
8889,
2692,
1010,
20413,
1024,
1011,
9683,
8889,
8889,
8889,
1065,
1010,
7632,
1024,
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... |
grpc/grpc-node | packages/grpc-native-core/src/server.js | Server | function Server(options) {
this.handlers = {};
var server = new grpc.Server(options);
this._server = server;
this.started = false;
} | javascript | function Server(options) {
this.handlers = {};
var server = new grpc.Server(options);
this._server = server;
this.started = false;
} | [
"function",
"Server",
"(",
"options",
")",
"{",
"this",
".",
"handlers",
"=",
"{",
"}",
";",
"var",
"server",
"=",
"new",
"grpc",
".",
"Server",
"(",
"options",
")",
";",
"this",
".",
"_server",
"=",
"server",
";",
"this",
".",
"started",
"=",
"fal... | Constructs a server object that stores request handlers and delegates
incoming requests to those handlers
@memberof grpc
@constructor
@param {Object=} options Options that should be passed to the internal server
implementation
@example
var server = new grpc.Server();
server.addProtoService(protobuf_service_descriptor, service_implementation);
server.bind('address:port', server_credential);
server.start(); | [
"Constructs",
"a",
"server",
"object",
"that",
"stores",
"request",
"handlers",
"and",
"delegates",
"incoming",
"requests",
"to",
"those",
"handlers"
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/server.js#L729-L734 | train | A server that can be used to listen for messages | [
30522,
3853,
8241,
1006,
7047,
1007,
1063,
2023,
1012,
28213,
2015,
1027,
1063,
1065,
1025,
13075,
8241,
1027,
2047,
24665,
15042,
1012,
8241,
1006,
7047,
1007,
1025,
2023,
1012,
1035,
8241,
1027,
8241,
1025,
2023,
1012,
2318,
1027,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
exceljs/exceljs | lib/xlsx/xform/style/styles-xform.js | function(border) {
var xml = this.map.border.toXml(border);
var index = this.index.border[xml];
if (index === undefined) {
index = this.index.border[xml] = this.model.borders.length;
this.model.borders.push(xml);
}
return index;
} | javascript | function(border) {
var xml = this.map.border.toXml(border);
var index = this.index.border[xml];
if (index === undefined) {
index = this.index.border[xml] = this.model.borders.length;
this.model.borders.push(xml);
}
return index;
} | [
"function",
"(",
"border",
")",
"{",
"var",
"xml",
"=",
"this",
".",
"map",
".",
"border",
".",
"toXml",
"(",
"border",
")",
";",
"var",
"index",
"=",
"this",
".",
"index",
".",
"border",
"[",
"xml",
"]",
";",
"if",
"(",
"index",
"===",
"undefine... | ========================================================================= Borders | [
"=========================================================================",
"Borders"
] | c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2 | https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/xlsx/xform/style/styles-xform.js#L379-L387 | train | Returns the index of the border | [
30522,
3853,
1006,
3675,
1007,
1063,
13075,
20950,
1027,
2023,
1012,
4949,
1012,
3675,
1012,
2000,
2595,
19968,
1006,
3675,
1007,
1025,
13075,
5950,
1027,
2023,
1012,
5950,
1012,
3675,
1031,
20950,
1033,
1025,
2065,
1006,
5950,
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... | |
angular/material | src/components/progressCircular/js/progressCircularDirective.js | getSvgArc | function getSvgArc(diameter, strokeWidth, indeterminate) {
var radius = diameter / 2;
var offset = strokeWidth / 2;
var start = radius + ',' + offset; // ie: (25, 2.5) or 12 o'clock
var end = offset + ',' + radius; // ie: (2.5, 25) or 9 o'clock
var arcRadius = radius - offset;
return 'M' + start
+ 'A' + arcRadius + ',' + arcRadius + ' 0 1 1 ' + end // 75% circle
+ (indeterminate ? '' : 'A' + arcRadius + ',' + arcRadius + ' 0 0 1 ' + start); // loop to start
} | javascript | function getSvgArc(diameter, strokeWidth, indeterminate) {
var radius = diameter / 2;
var offset = strokeWidth / 2;
var start = radius + ',' + offset; // ie: (25, 2.5) or 12 o'clock
var end = offset + ',' + radius; // ie: (2.5, 25) or 9 o'clock
var arcRadius = radius - offset;
return 'M' + start
+ 'A' + arcRadius + ',' + arcRadius + ' 0 1 1 ' + end // 75% circle
+ (indeterminate ? '' : 'A' + arcRadius + ',' + arcRadius + ' 0 0 1 ' + start); // loop to start
} | [
"function",
"getSvgArc",
"(",
"diameter",
",",
"strokeWidth",
",",
"indeterminate",
")",
"{",
"var",
"radius",
"=",
"diameter",
"/",
"2",
";",
"var",
"offset",
"=",
"strokeWidth",
"/",
"2",
";",
"var",
"start",
"=",
"radius",
"+",
"','",
"+",
"offset",
... | Returns SVG path data for progress circle
Syntax spec: https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
@param {number} diameter Diameter of the container.
@param {number} strokeWidth Stroke width to be used when drawing circle
@param {boolean} indeterminate Use if progress circle will be used for indeterminate
@returns {string} String representation of an SVG arc. | [
"Returns",
"SVG",
"path",
"data",
"for",
"progress",
"circle",
"Syntax",
"spec",
":",
"https",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"SVG",
"/",
"paths",
".",
"html#PathDataEllipticalArcCommands"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/progressCircular/js/progressCircularDirective.js#L316-L325 | train | get svg arc | [
30522,
3853,
4152,
2615,
6843,
2278,
1006,
6705,
1010,
6909,
9148,
11927,
2232,
1010,
27427,
15141,
19269,
1007,
1063,
13075,
12177,
1027,
6705,
1013,
1016,
1025,
13075,
16396,
1027,
6909,
9148,
11927,
2232,
1013,
1016,
1025,
13075,
2707,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/model/Series.js | autoSeriesName | function autoSeriesName(seriesModel) {
// User specified name has higher priority, otherwise it may cause
// series can not be queried unexpectedly.
var name = seriesModel.name;
if (!modelUtil.isNameSpecified(seriesModel)) {
seriesModel.name = getSeriesAutoName(seriesModel) || name;
}
} | javascript | function autoSeriesName(seriesModel) {
// User specified name has higher priority, otherwise it may cause
// series can not be queried unexpectedly.
var name = seriesModel.name;
if (!modelUtil.isNameSpecified(seriesModel)) {
seriesModel.name = getSeriesAutoName(seriesModel) || name;
}
} | [
"function",
"autoSeriesName",
"(",
"seriesModel",
")",
"{",
"// User specified name has higher priority, otherwise it may cause",
"// series can not be queried unexpectedly.",
"var",
"name",
"=",
"seriesModel",
".",
"name",
";",
"if",
"(",
"!",
"modelUtil",
".",
"isNameSpecif... | MUST be called after `prepareSource` called
Here we need to make auto series, especially for auto legend. But we
do not modify series.name in option to avoid side effects. | [
"MUST",
"be",
"called",
"after",
"prepareSource",
"called",
"Here",
"we",
"need",
"to",
"make",
"auto",
"series",
"especially",
"for",
"auto",
"legend",
".",
"But",
"we",
"do",
"not",
"modify",
"series",
".",
"name",
"in",
"option",
"to",
"avoid",
"side",
... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Series.js#L550-L557 | train | Auto - sets seriesModel. name if not set | [
30522,
3853,
8285,
8043,
3111,
18442,
1006,
2186,
5302,
9247,
1007,
1063,
1013,
1013,
5310,
9675,
2171,
2038,
3020,
9470,
1010,
4728,
2009,
2089,
3426,
1013,
1013,
2186,
2064,
2025,
2022,
10861,
11998,
14153,
1012,
13075,
2171,
1027,
2186,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js | getHeaderValue | function getHeaderValue(sHeaders, sHeaderName) {
var i,
aHeaderParts,
aHeaders = sHeaders.split("\r\n");
for (i = 0; i < aHeaders.length; i += 1) {
aHeaderParts = aHeaders[i].split(":");
if (aHeaderParts[0].toLowerCase().trim() === sHeaderName) {
return aHeaderParts[1].trim();
}
}
} | javascript | function getHeaderValue(sHeaders, sHeaderName) {
var i,
aHeaderParts,
aHeaders = sHeaders.split("\r\n");
for (i = 0; i < aHeaders.length; i += 1) {
aHeaderParts = aHeaders[i].split(":");
if (aHeaderParts[0].toLowerCase().trim() === sHeaderName) {
return aHeaderParts[1].trim();
}
}
} | [
"function",
"getHeaderValue",
"(",
"sHeaders",
",",
"sHeaderName",
")",
"{",
"var",
"i",
",",
"aHeaderParts",
",",
"aHeaders",
"=",
"sHeaders",
".",
"split",
"(",
"\"\\r\\n\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"aHeaders",
".",
"lengt... | Returns value of the header with the specified <code>sHeaderName</code> from
the specified <code>sHeaders</code> section of MIME part.
@param {string} sHeaders
Section of MIME part representing HTTP headers
@param {string} sHeaderName
Name of HTTP header in lower case
@returns {string} The HTTP header value | [
"Returns",
"value",
"of",
"the",
"header",
"with",
"the",
"specified",
"<code",
">",
"sHeaderName<",
"/",
"code",
">",
"from",
"the",
"specified",
"<code",
">",
"sHeaders<",
"/",
"code",
">",
"section",
"of",
"MIME",
"part",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js#L117-L129 | train | Get the value of a header | [
30522,
3853,
2131,
4974,
2121,
10175,
5657,
1006,
16994,
13375,
1010,
16994,
25888,
14074,
1007,
1063,
13075,
1045,
1010,
3805,
2121,
26950,
1010,
3805,
2545,
1027,
16994,
13375,
1012,
3975,
1006,
1000,
1032,
1054,
1032,
1050,
1000,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/examples/grapheditor/www/js/EditorUi.js | nudge | function nudge(keyCode, stepSize, resize)
{
queue.push(function()
{
if (!graph.isSelectionEmpty() && graph.isEnabled())
{
stepSize = (stepSize != null) ? stepSize : 1;
if (resize)
{
// Resizes all selected vertices
graph.getModel().beginUpdate();
try
{
var cells = graph.getSelectionCells();
for (var i = 0; i < cells.length; i++)
{
if (graph.getModel().isVertex(cells[i]) && graph.isCellResizable(cells[i]))
{
var geo = graph.getCellGeometry(cells[i]);
if (geo != null)
{
geo = geo.clone();
if (keyCode == 37)
{
geo.width = Math.max(0, geo.width - stepSize);
}
else if (keyCode == 38)
{
geo.height = Math.max(0, geo.height - stepSize);
}
else if (keyCode == 39)
{
geo.width += stepSize;
}
else if (keyCode == 40)
{
geo.height += stepSize;
}
graph.getModel().setGeometry(cells[i], geo);
}
}
}
}
finally
{
graph.getModel().endUpdate();
}
}
else
{
// Moves vertices up/down in a stack layout
var cell = graph.getSelectionCell();
var parent = graph.model.getParent(cell);
var layout = null;
if (graph.getSelectionCount() == 1 && graph.model.isVertex(cell) &&
graph.layoutManager != null && !graph.isCellLocked(cell))
{
layout = graph.layoutManager.getLayout(parent);
}
if (layout != null && layout.constructor == mxStackLayout)
{
var index = parent.getIndex(cell);
if (keyCode == 37 || keyCode == 38)
{
graph.model.add(parent, cell, Math.max(0, index - 1));
}
else if (keyCode == 39 ||keyCode == 40)
{
graph.model.add(parent, cell, Math.min(graph.model.getChildCount(parent), index + 1));
}
}
else
{
var dx = 0;
var dy = 0;
if (keyCode == 37)
{
dx = -stepSize;
}
else if (keyCode == 38)
{
dy = -stepSize;
}
else if (keyCode == 39)
{
dx = stepSize;
}
else if (keyCode == 40)
{
dy = stepSize;
}
graph.moveCells(graph.getMovableCells(graph.getSelectionCells()), dx, dy);
}
}
}
});
if (thread != null)
{
window.clearTimeout(thread);
}
thread = window.setTimeout(function()
{
if (queue.length > 0)
{
graph.getModel().beginUpdate();
try
{
for (var i = 0; i < queue.length; i++)
{
queue[i]();
}
queue = [];
}
finally
{
graph.getModel().endUpdate();
}
graph.scrollCellToVisible(graph.getSelectionCell());
}
}, 200);
} | javascript | function nudge(keyCode, stepSize, resize)
{
queue.push(function()
{
if (!graph.isSelectionEmpty() && graph.isEnabled())
{
stepSize = (stepSize != null) ? stepSize : 1;
if (resize)
{
// Resizes all selected vertices
graph.getModel().beginUpdate();
try
{
var cells = graph.getSelectionCells();
for (var i = 0; i < cells.length; i++)
{
if (graph.getModel().isVertex(cells[i]) && graph.isCellResizable(cells[i]))
{
var geo = graph.getCellGeometry(cells[i]);
if (geo != null)
{
geo = geo.clone();
if (keyCode == 37)
{
geo.width = Math.max(0, geo.width - stepSize);
}
else if (keyCode == 38)
{
geo.height = Math.max(0, geo.height - stepSize);
}
else if (keyCode == 39)
{
geo.width += stepSize;
}
else if (keyCode == 40)
{
geo.height += stepSize;
}
graph.getModel().setGeometry(cells[i], geo);
}
}
}
}
finally
{
graph.getModel().endUpdate();
}
}
else
{
// Moves vertices up/down in a stack layout
var cell = graph.getSelectionCell();
var parent = graph.model.getParent(cell);
var layout = null;
if (graph.getSelectionCount() == 1 && graph.model.isVertex(cell) &&
graph.layoutManager != null && !graph.isCellLocked(cell))
{
layout = graph.layoutManager.getLayout(parent);
}
if (layout != null && layout.constructor == mxStackLayout)
{
var index = parent.getIndex(cell);
if (keyCode == 37 || keyCode == 38)
{
graph.model.add(parent, cell, Math.max(0, index - 1));
}
else if (keyCode == 39 ||keyCode == 40)
{
graph.model.add(parent, cell, Math.min(graph.model.getChildCount(parent), index + 1));
}
}
else
{
var dx = 0;
var dy = 0;
if (keyCode == 37)
{
dx = -stepSize;
}
else if (keyCode == 38)
{
dy = -stepSize;
}
else if (keyCode == 39)
{
dx = stepSize;
}
else if (keyCode == 40)
{
dy = stepSize;
}
graph.moveCells(graph.getMovableCells(graph.getSelectionCells()), dx, dy);
}
}
}
});
if (thread != null)
{
window.clearTimeout(thread);
}
thread = window.setTimeout(function()
{
if (queue.length > 0)
{
graph.getModel().beginUpdate();
try
{
for (var i = 0; i < queue.length; i++)
{
queue[i]();
}
queue = [];
}
finally
{
graph.getModel().endUpdate();
}
graph.scrollCellToVisible(graph.getSelectionCell());
}
}, 200);
} | [
"function",
"nudge",
"(",
"keyCode",
",",
"stepSize",
",",
"resize",
")",
"{",
"queue",
".",
"push",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"graph",
".",
"isSelectionEmpty",
"(",
")",
"&&",
"graph",
".",
"isEnabled",
"(",
")",
")",
"{",
"s... | Helper function to move cells with the cursor keys | [
"Helper",
"function",
"to",
"move",
"cells",
"with",
"the",
"cursor",
"keys"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/examples/grapheditor/www/js/EditorUi.js#L3842-L3975 | train | This function is called when a key is pressed on a cell. | [
30522,
3853,
16371,
11818,
1006,
3145,
16044,
1010,
4084,
4697,
1010,
24501,
4697,
1007,
1063,
24240,
1012,
5245,
1006,
3853,
1006,
1007,
1063,
2065,
1006,
999,
10629,
1012,
26354,
12260,
7542,
6633,
13876,
2100,
1006,
1007,
1004,
1004,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_EncInfoAgl | function parse_EncInfoAgl(blob) {
var KeyData = ["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];
blob.l+=4;
var xml = blob.read_shift(blob.length - blob.l, 'utf8');
var o = {};
xml.replace(tagregex, function xml_agile(x) {
var y = parsexmltag(x);
switch(strip_ns(y[0])) {
case '<?xml': break;
case '<encryption': case '</encryption>': break;
case '<keyData': KeyData.forEach(function(k) { o[k] = y[k]; }); break;
case '<dataIntegrity': o.encryptedHmacKey = y.encryptedHmacKey; o.encryptedHmacValue = y.encryptedHmacValue; break;
case '<keyEncryptors>': case '<keyEncryptors': o.encs = []; break;
case '</keyEncryptors>': break;
case '<keyEncryptor': o.uri = y.uri; break;
case '</keyEncryptor>': break;
case '<encryptedKey': o.encs.push(y); break;
default: throw y[0];
}
});
return o;
} | javascript | function parse_EncInfoAgl(blob) {
var KeyData = ["saltSize","blockSize","keyBits","hashSize","cipherAlgorithm","cipherChaining","hashAlgorithm","saltValue"];
blob.l+=4;
var xml = blob.read_shift(blob.length - blob.l, 'utf8');
var o = {};
xml.replace(tagregex, function xml_agile(x) {
var y = parsexmltag(x);
switch(strip_ns(y[0])) {
case '<?xml': break;
case '<encryption': case '</encryption>': break;
case '<keyData': KeyData.forEach(function(k) { o[k] = y[k]; }); break;
case '<dataIntegrity': o.encryptedHmacKey = y.encryptedHmacKey; o.encryptedHmacValue = y.encryptedHmacValue; break;
case '<keyEncryptors>': case '<keyEncryptors': o.encs = []; break;
case '</keyEncryptors>': break;
case '<keyEncryptor': o.uri = y.uri; break;
case '</keyEncryptor>': break;
case '<encryptedKey': o.encs.push(y); break;
default: throw y[0];
}
});
return o;
} | [
"function",
"parse_EncInfoAgl",
"(",
"blob",
")",
"{",
"var",
"KeyData",
"=",
"[",
"\"saltSize\"",
",",
"\"blockSize\"",
",",
"\"keyBits\"",
",",
"\"hashSize\"",
",",
"\"cipherAlgorithm\"",
",",
"\"cipherChaining\"",
",",
"\"hashAlgorithm\"",
",",
"\"saltValue\"",
"... | /* [MS-OFFCRYPTO] 2.3.4.10 EncryptionInfo Stream (Agile Encryption) | [
"/",
"*",
"[",
"MS",
"-",
"OFFCRYPTO",
"]",
"2",
".",
"3",
".",
"4",
".",
"10",
"EncryptionInfo",
"Stream",
"(",
"Agile",
"Encryption",
")"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L8256-L8278 | train | Parse the XML tag | [
30522,
3853,
11968,
3366,
1035,
4372,
15459,
14876,
8490,
2140,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
3145,
2850,
2696,
1027,
1031,
1000,
23480,
4697,
1000,
1010,
1000,
5991,
4697,
1000,
1010,
1000,
3145,
16313,
2015,
1000,
1010,
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... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js | function(oAtt, aResult){
if (!oAtt.getSelected()) {
return;
}
aResult.push(oAtt);
var aValues = oAtt.getAttributesInternal();
for (var idx = 0; idx < aValues.length; idx++) {
_computeSelectedAttributes(aValues[idx], aResult);
}
} | javascript | function(oAtt, aResult){
if (!oAtt.getSelected()) {
return;
}
aResult.push(oAtt);
var aValues = oAtt.getAttributesInternal();
for (var idx = 0; idx < aValues.length; idx++) {
_computeSelectedAttributes(aValues[idx], aResult);
}
} | [
"function",
"(",
"oAtt",
",",
"aResult",
")",
"{",
"if",
"(",
"!",
"oAtt",
".",
"getSelected",
"(",
")",
")",
"{",
"return",
";",
"}",
"aResult",
".",
"push",
"(",
"oAtt",
")",
";",
"var",
"aValues",
"=",
"oAtt",
".",
"getAttributesInternal",
"(",
... | Computes recursivly all selected attributes and adds them to the given result list | [
"Computes",
"recursivly",
"all",
"selected",
"attributes",
"and",
"adds",
"them",
"to",
"the",
"given",
"result",
"list"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js#L861-L870 | train | Compute selected attributes | [
30522,
3853,
1006,
1051,
19321,
1010,
23631,
11314,
1007,
1063,
2065,
1006,
999,
1051,
19321,
1012,
4152,
12260,
10985,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
23631,
11314,
1012,
5245,
1006,
1051,
19321,
1007,
1025,
13075,
10927,
7630,
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... | |
chartjs/Chart.js | src/core/core.interaction.js | getNearestItems | function getNearestItems(chart, position, intersect, distanceMetric) {
var minDistance = Number.POSITIVE_INFINITY;
var nearestItems = [];
parseVisibleItems(chart, function(element) {
if (intersect && !element.inRange(position.x, position.y)) {
return;
}
var center = element.getCenterPoint();
var distance = distanceMetric(position, center);
if (distance < minDistance) {
nearestItems = [element];
minDistance = distance;
} else if (distance === minDistance) {
// Can have multiple items at the same distance in which case we sort by size
nearestItems.push(element);
}
});
return nearestItems;
} | javascript | function getNearestItems(chart, position, intersect, distanceMetric) {
var minDistance = Number.POSITIVE_INFINITY;
var nearestItems = [];
parseVisibleItems(chart, function(element) {
if (intersect && !element.inRange(position.x, position.y)) {
return;
}
var center = element.getCenterPoint();
var distance = distanceMetric(position, center);
if (distance < minDistance) {
nearestItems = [element];
minDistance = distance;
} else if (distance === minDistance) {
// Can have multiple items at the same distance in which case we sort by size
nearestItems.push(element);
}
});
return nearestItems;
} | [
"function",
"getNearestItems",
"(",
"chart",
",",
"position",
",",
"intersect",
",",
"distanceMetric",
")",
"{",
"var",
"minDistance",
"=",
"Number",
".",
"POSITIVE_INFINITY",
";",
"var",
"nearestItems",
"=",
"[",
"]",
";",
"parseVisibleItems",
"(",
"chart",
"... | Helper function to get the items nearest to the event position considering all visible items in teh chart
@param {Chart} chart - the chart to look at elements from
@param {object} position - the point to be nearest to
@param {boolean} intersect - if true, only consider items that intersect the position
@param {function} distanceMetric - function to provide the distance between points
@return {ChartElement[]} the nearest items | [
"Helper",
"function",
"to",
"get",
"the",
"items",
"nearest",
"to",
"the",
"event",
"position",
"considering",
"all",
"visible",
"items",
"in",
"teh",
"chart"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.interaction.js#L72-L93 | train | Returns an array of items that are closest to the given position | [
30522,
3853,
2131,
22084,
28533,
4221,
5244,
1006,
3673,
1010,
2597,
1010,
29261,
1010,
3292,
12589,
1007,
1063,
13075,
2568,
23137,
3401,
1027,
2193,
1012,
3893,
1035,
15579,
1025,
13075,
7205,
4221,
5244,
1027,
1031,
1033,
1025,
11968,
33... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Dogfalo/materialize | dist/js/materialize.js | _createToast | function _createToast() {
var toast = document.createElement('div');
toast.classList.add('toast');
// Add custom classes onto toast
if (!!this.options.classes.length) {
$(toast).addClass(this.options.classes);
}
// Set content
if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') {
toast.appendChild(this.message);
// Check if it is jQuery object
} else if (!!this.message.jquery) {
$(toast).append(this.message[0]);
// Insert as html;
} else {
toast.innerHTML = this.message;
}
// Append toasft
Toast._container.appendChild(toast);
return toast;
} | javascript | function _createToast() {
var toast = document.createElement('div');
toast.classList.add('toast');
// Add custom classes onto toast
if (!!this.options.classes.length) {
$(toast).addClass(this.options.classes);
}
// Set content
if (typeof HTMLElement === 'object' ? this.message instanceof HTMLElement : this.message && typeof this.message === 'object' && this.message !== null && this.message.nodeType === 1 && typeof this.message.nodeName === 'string') {
toast.appendChild(this.message);
// Check if it is jQuery object
} else if (!!this.message.jquery) {
$(toast).append(this.message[0]);
// Insert as html;
} else {
toast.innerHTML = this.message;
}
// Append toasft
Toast._container.appendChild(toast);
return toast;
} | [
"function",
"_createToast",
"(",
")",
"{",
"var",
"toast",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"toast",
".",
"classList",
".",
"add",
"(",
"'toast'",
")",
";",
"// Add custom classes onto toast",
"if",
"(",
"!",
"!",
"this",
".",... | Create toast and append it to toast container | [
"Create",
"toast",
"and",
"append",
"it",
"to",
"toast",
"container"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L5163-L5188 | train | Create the toast | [
30522,
3853,
1035,
3443,
3406,
14083,
1006,
1007,
1063,
13075,
15174,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
15174,
1012,
2465,
9863,
1012,
5587,
1006,
1005,
15174,
1005,
1007,
1025,
1013,
1013,
5587,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/dialog/dialog.js | getParents | function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if it is an ascendant of the dialog
// a script or style tag, or a live region.
if (element !== children[i] &&
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) &&
!children[i].hasAttribute('aria-live')) {
parents.push(children[i]);
}
}
element = element.parentNode;
}
return parents;
} | javascript | function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if it is an ascendant of the dialog
// a script or style tag, or a live region.
if (element !== children[i] &&
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) &&
!children[i].hasAttribute('aria-live')) {
parents.push(children[i]);
}
}
element = element.parentNode;
}
return parents;
} | [
"function",
"getParents",
"(",
"element",
")",
"{",
"var",
"parents",
"=",
"[",
"]",
";",
"while",
"(",
"element",
".",
"parentNode",
")",
"{",
"if",
"(",
"element",
"===",
"document",
".",
"body",
")",
"{",
"return",
"parents",
";",
"}",
"var",
"chi... | Get all of an element's parent elements up the DOM tree
@return {Array} The parent elements | [
"Get",
"all",
"of",
"an",
"element",
"s",
"parent",
"elements",
"up",
"the",
"DOM",
"tree"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L1159-L1178 | train | get parents of element | [
30522,
3853,
2131,
19362,
11187,
1006,
5783,
1007,
1063,
13075,
3008,
1027,
1031,
1033,
1025,
2096,
1006,
5783,
1012,
6687,
3630,
3207,
1007,
1063,
2065,
1006,
5783,
1027,
1027,
1027,
6254,
1012,
2303,
1007,
1063,
2709,
3008,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
if (this._oFilterExpression == null) {
var oEntityType = this._oParameter.getContainingParameterization().getEntityType();
var oModel = this._oParameter.getContainingParameterization().getTargetQueryResult().getModel();
this._oFilterExpression = new odata4analytics.FilterExpression(oModel, oEntityType
.getSchema(), oEntityType);
}
return this._oFilterExpression;
} | javascript | function() {
if (this._oFilterExpression == null) {
var oEntityType = this._oParameter.getContainingParameterization().getEntityType();
var oModel = this._oParameter.getContainingParameterization().getTargetQueryResult().getModel();
this._oFilterExpression = new odata4analytics.FilterExpression(oModel, oEntityType
.getSchema(), oEntityType);
}
return this._oFilterExpression;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_oFilterExpression",
"==",
"null",
")",
"{",
"var",
"oEntityType",
"=",
"this",
".",
"_oParameter",
".",
"getContainingParameterization",
"(",
")",
".",
"getEntityType",
"(",
")",
";",
"var",
"oModel",
"=... | Get the filter expression for this request.
Expressions are represented by separate objects. If none exists so far, a
new expression object gets created.
@returns {sap.ui.model.analytics.odata4analytics.FilterExpression} The filter object
associated to this request.
@public
@function
@name sap.ui.model.analytics.odata4analytics.ParameterValueSetRequest#getFilterExpression | [
"Get",
"the",
"filter",
"expression",
"for",
"this",
"request",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L4974-L4982 | train | Returns the filter expression for the parameterization | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
1997,
4014,
3334,
10288,
20110,
3258,
1027,
1027,
19701,
1007,
1063,
13075,
1051,
4765,
3012,
13874,
1027,
2023,
1012,
1035,
6728,
5400,
22828,
1012,
2131,
8663,
18249,
2075,
2868... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
chartjs/Chart.js | src/controllers/controller.bar.js | function(datasetIndex, index) {
var me = this;
var chart = me.chart;
var meta = me.getMeta();
var scale = me._getValueScale();
var isHorizontal = scale.isHorizontal();
var datasets = chart.data.datasets;
var value = +scale.getRightValue(datasets[datasetIndex].data[index]);
var minBarLength = scale.options.minBarLength;
var stacked = scale.options.stacked;
var stack = meta.stack;
var start = 0;
var i, imeta, ivalue, base, head, size;
if (stacked || (stacked === undefined && stack !== undefined)) {
for (i = 0; i < datasetIndex; ++i) {
imeta = chart.getDatasetMeta(i);
if (imeta.bar &&
imeta.stack === stack &&
imeta.controller._getValueScaleId() === scale.id &&
chart.isDatasetVisible(i)) {
ivalue = +scale.getRightValue(datasets[i].data[index]);
if ((value < 0 && ivalue < 0) || (value >= 0 && ivalue > 0)) {
start += ivalue;
}
}
}
}
base = scale.getPixelForValue(start);
head = scale.getPixelForValue(start + value);
size = head - base;
if (minBarLength !== undefined && Math.abs(size) < minBarLength) {
size = minBarLength;
if (value >= 0 && !isHorizontal || value < 0 && isHorizontal) {
head = base - minBarLength;
} else {
head = base + minBarLength;
}
}
return {
size: size,
base: base,
head: head,
center: head + size / 2
};
} | javascript | function(datasetIndex, index) {
var me = this;
var chart = me.chart;
var meta = me.getMeta();
var scale = me._getValueScale();
var isHorizontal = scale.isHorizontal();
var datasets = chart.data.datasets;
var value = +scale.getRightValue(datasets[datasetIndex].data[index]);
var minBarLength = scale.options.minBarLength;
var stacked = scale.options.stacked;
var stack = meta.stack;
var start = 0;
var i, imeta, ivalue, base, head, size;
if (stacked || (stacked === undefined && stack !== undefined)) {
for (i = 0; i < datasetIndex; ++i) {
imeta = chart.getDatasetMeta(i);
if (imeta.bar &&
imeta.stack === stack &&
imeta.controller._getValueScaleId() === scale.id &&
chart.isDatasetVisible(i)) {
ivalue = +scale.getRightValue(datasets[i].data[index]);
if ((value < 0 && ivalue < 0) || (value >= 0 && ivalue > 0)) {
start += ivalue;
}
}
}
}
base = scale.getPixelForValue(start);
head = scale.getPixelForValue(start + value);
size = head - base;
if (minBarLength !== undefined && Math.abs(size) < minBarLength) {
size = minBarLength;
if (value >= 0 && !isHorizontal || value < 0 && isHorizontal) {
head = base - minBarLength;
} else {
head = base + minBarLength;
}
}
return {
size: size,
base: base,
head: head,
center: head + size / 2
};
} | [
"function",
"(",
"datasetIndex",
",",
"index",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"chart",
"=",
"me",
".",
"chart",
";",
"var",
"meta",
"=",
"me",
".",
"getMeta",
"(",
")",
";",
"var",
"scale",
"=",
"me",
".",
"_getValueScale",
"(",
... | Note: pixel values are not clamped to the scale area.
@private | [
"Note",
":",
"pixel",
"values",
"are",
"not",
"clamped",
"to",
"the",
"scale",
"area",
"."
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/controllers/controller.bar.js#L281-L331 | train | Get the center of the bar at the given index | [
30522,
3853,
1006,
2951,
13462,
22254,
10288,
1010,
5950,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
13075,
3673,
1027,
2033,
1012,
3673,
1025,
13075,
18804,
1027,
2033,
1012,
2131,
11368,
2050,
1006,
1007,
1025,
13075,
4094,
1027,
2033,
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;
var args = arguments;
var seek, id;
// Determine the values based on arguments.
if (args.length === 0) {
// We will simply return the current position of the first node.
id = self._sounds[0]._id;
} else if (args.length === 1) {
// First check if this is an ID, and if not, assume it is a new seek position.
var ids = self._getSoundIds();
var index = ids.indexOf(args[0]);
if (index >= 0) {
id = parseInt(args[0], 10);
} else if (self._sounds.length) {
id = self._sounds[0]._id;
seek = parseFloat(args[0]);
}
} else if (args.length === 2) {
seek = parseFloat(args[0]);
id = parseInt(args[1], 10);
}
// If there is no ID, bail out.
if (typeof id === 'undefined') {
return self;
}
// If the sound hasn't loaded, add it to the load queue to seek when capable.
if (self._state !== 'loaded' || self._playLock) {
self._queue.push({
event: 'seek',
action: function() {
self.seek.apply(self, args);
}
});
return self;
}
// Get the sound.
var sound = self._soundById(id);
if (sound) {
if (typeof seek === 'number' && seek >= 0) {
// Pause the sound and update position for restarting playback.
var playing = self.playing(id);
if (playing) {
self.pause(id, true);
}
// Move the position of the track and cancel timer.
sound._seek = seek;
sound._ended = false;
self._clearTimer(id);
// Update the seek position for HTML5 Audio.
if (!self._webAudio && sound._node && !isNaN(sound._node.duration)) {
sound._node.currentTime = seek;
}
// Seek and emit when ready.
var seekAndEmit = function() {
self._emit('seek', id);
// Restart the playback if the sound was playing.
if (playing) {
self.play(id, true);
}
};
// Wait for the play lock to be unset before emitting (HTML5 Audio).
if (playing && !self._webAudio) {
var emitSeek = function() {
if (!self._playLock) {
seekAndEmit();
} else {
setTimeout(emitSeek, 0);
}
};
setTimeout(emitSeek, 0);
} else {
seekAndEmit();
}
} else {
if (self._webAudio) {
var realTime = self.playing(id) ? Howler.ctx.currentTime - sound._playStart : 0;
var rateSeek = sound._rateSeek ? sound._rateSeek - sound._seek : 0;
return sound._seek + (rateSeek + realTime * Math.abs(sound._rate));
} else {
return sound._node.currentTime;
}
}
}
return self;
} | javascript | function() {
var self = this;
var args = arguments;
var seek, id;
// Determine the values based on arguments.
if (args.length === 0) {
// We will simply return the current position of the first node.
id = self._sounds[0]._id;
} else if (args.length === 1) {
// First check if this is an ID, and if not, assume it is a new seek position.
var ids = self._getSoundIds();
var index = ids.indexOf(args[0]);
if (index >= 0) {
id = parseInt(args[0], 10);
} else if (self._sounds.length) {
id = self._sounds[0]._id;
seek = parseFloat(args[0]);
}
} else if (args.length === 2) {
seek = parseFloat(args[0]);
id = parseInt(args[1], 10);
}
// If there is no ID, bail out.
if (typeof id === 'undefined') {
return self;
}
// If the sound hasn't loaded, add it to the load queue to seek when capable.
if (self._state !== 'loaded' || self._playLock) {
self._queue.push({
event: 'seek',
action: function() {
self.seek.apply(self, args);
}
});
return self;
}
// Get the sound.
var sound = self._soundById(id);
if (sound) {
if (typeof seek === 'number' && seek >= 0) {
// Pause the sound and update position for restarting playback.
var playing = self.playing(id);
if (playing) {
self.pause(id, true);
}
// Move the position of the track and cancel timer.
sound._seek = seek;
sound._ended = false;
self._clearTimer(id);
// Update the seek position for HTML5 Audio.
if (!self._webAudio && sound._node && !isNaN(sound._node.duration)) {
sound._node.currentTime = seek;
}
// Seek and emit when ready.
var seekAndEmit = function() {
self._emit('seek', id);
// Restart the playback if the sound was playing.
if (playing) {
self.play(id, true);
}
};
// Wait for the play lock to be unset before emitting (HTML5 Audio).
if (playing && !self._webAudio) {
var emitSeek = function() {
if (!self._playLock) {
seekAndEmit();
} else {
setTimeout(emitSeek, 0);
}
};
setTimeout(emitSeek, 0);
} else {
seekAndEmit();
}
} else {
if (self._webAudio) {
var realTime = self.playing(id) ? Howler.ctx.currentTime - sound._playStart : 0;
var rateSeek = sound._rateSeek ? sound._rateSeek - sound._seek : 0;
return sound._seek + (rateSeek + realTime * Math.abs(sound._rate));
} else {
return sound._node.currentTime;
}
}
}
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"args",
"=",
"arguments",
";",
"var",
"seek",
",",
"id",
";",
"// Determine the values based on arguments.",
"if",
"(",
"args",
".",
"length",
"===",
"0",
")",
"{",
"// We will simply return ... | Get/set the seek position of a sound. This method can optionally take 0, 1 or 2 arguments.
seek() -> Returns the first sound node's current seek position.
seek(id) -> Returns the sound id's current seek position.
seek(seek) -> Sets the seek position of the first sound node.
seek(seek, id) -> Sets the seek position of passed sound id.
@return {Howl/Number} Returns self or the current seek position. | [
"Get",
"/",
"set",
"the",
"seek",
"position",
"of",
"a",
"sound",
".",
"This",
"method",
"can",
"optionally",
"take",
"0",
"1",
"or",
"2",
"arguments",
".",
"seek",
"()",
"-",
">",
"Returns",
"the",
"first",
"sound",
"node",
"s",
"current",
"seek",
"... | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L1549-L1646 | train | Seek to the specified position. | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
12098,
5620,
1027,
9918,
1025,
13075,
6148,
1010,
8909,
1025,
1013,
1013,
5646,
1996,
5300,
2241,
2006,
9918,
1012,
2065,
1006,
12098,
5620,
1012,
3091,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
marcuswestin/store.js | src/store-engine.js | function(callback) {
var self = this
this.storage.each(function(val, namespacedKey) {
callback.call(self, self._deserialize(val), (namespacedKey || '').replace(self._namespaceRegexp, ''))
})
} | javascript | function(callback) {
var self = this
this.storage.each(function(val, namespacedKey) {
callback.call(self, self._deserialize(val), (namespacedKey || '').replace(self._namespaceRegexp, ''))
})
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
"this",
".",
"storage",
".",
"each",
"(",
"function",
"(",
"val",
",",
"namespacedKey",
")",
"{",
"callback",
".",
"call",
"(",
"self",
",",
"self",
".",
"_deserialize",
"(",
"val",
"... | each will call the given callback once for each key-value pair in this store. | [
"each",
"will",
"call",
"the",
"given",
"callback",
"once",
"for",
"each",
"key",
"-",
"value",
"pair",
"in",
"this",
"store",
"."
] | b8e22fea8738fc19da4d9e7dbf1cda6e5185c481 | https://github.com/marcuswestin/store.js/blob/b8e22fea8738fc19da4d9e7dbf1cda6e5185c481/src/store-engine.js#L43-L48 | train | This function is called by the store to retrieve all the items in the storage | [
30522,
3853,
1006,
2655,
5963,
1007,
1063,
13075,
2969,
1027,
2023,
2023,
1012,
5527,
1012,
2169,
1006,
3853,
1006,
11748,
1010,
3415,
15327,
2094,
14839,
1007,
1063,
2655,
5963,
1012,
2655,
1006,
2969,
1010,
2969,
1012,
1035,
4078,
11610,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LabelEnablement.js | refreshMapping | function refreshMapping(oLabel, bDestroy){
var sLabelId = oLabel.getId();
var sOldId = oLabel.__sLabeledControl;
var sNewId = bDestroy ? null : findLabelForControl(oLabel);
if (sOldId == sNewId) {
return;
}
//Invalidate the label itself (see setLabelFor, setAlternativeLabelFor)
if (!bDestroy) {
oLabel.invalidate();
}
//Update the label to control mapping (1-1 mapping)
if (sNewId) {
oLabel.__sLabeledControl = sNewId;
} else {
delete oLabel.__sLabeledControl;
}
//Update the control to label mapping (1-n mapping)
var aLabelsOfControl;
if (sOldId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sOldId];
if (aLabelsOfControl) {
aLabelsOfControl = aLabelsOfControl.filter(function(sCurrentLabelId) {
return sCurrentLabelId != sLabelId;
});
if (aLabelsOfControl.length) {
CONTROL_TO_LABELS_MAPPING[sOldId] = aLabelsOfControl;
} else {
delete CONTROL_TO_LABELS_MAPPING[sOldId];
}
}
}
if (sNewId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sNewId] || [];
aLabelsOfControl.push(sLabelId);
CONTROL_TO_LABELS_MAPPING[sNewId] = aLabelsOfControl;
}
//Invalidate related controls
var oOldControl = toControl(sOldId, true);
var oNewControl = toControl(sNewId, true);
if (oOldControl) {
oLabel.detachRequiredChange(oOldControl);
}
if (oNewControl) {
oLabel.attachRequiredChange(oNewControl);
}
} | javascript | function refreshMapping(oLabel, bDestroy){
var sLabelId = oLabel.getId();
var sOldId = oLabel.__sLabeledControl;
var sNewId = bDestroy ? null : findLabelForControl(oLabel);
if (sOldId == sNewId) {
return;
}
//Invalidate the label itself (see setLabelFor, setAlternativeLabelFor)
if (!bDestroy) {
oLabel.invalidate();
}
//Update the label to control mapping (1-1 mapping)
if (sNewId) {
oLabel.__sLabeledControl = sNewId;
} else {
delete oLabel.__sLabeledControl;
}
//Update the control to label mapping (1-n mapping)
var aLabelsOfControl;
if (sOldId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sOldId];
if (aLabelsOfControl) {
aLabelsOfControl = aLabelsOfControl.filter(function(sCurrentLabelId) {
return sCurrentLabelId != sLabelId;
});
if (aLabelsOfControl.length) {
CONTROL_TO_LABELS_MAPPING[sOldId] = aLabelsOfControl;
} else {
delete CONTROL_TO_LABELS_MAPPING[sOldId];
}
}
}
if (sNewId) {
aLabelsOfControl = CONTROL_TO_LABELS_MAPPING[sNewId] || [];
aLabelsOfControl.push(sLabelId);
CONTROL_TO_LABELS_MAPPING[sNewId] = aLabelsOfControl;
}
//Invalidate related controls
var oOldControl = toControl(sOldId, true);
var oNewControl = toControl(sNewId, true);
if (oOldControl) {
oLabel.detachRequiredChange(oOldControl);
}
if (oNewControl) {
oLabel.attachRequiredChange(oNewControl);
}
} | [
"function",
"refreshMapping",
"(",
"oLabel",
",",
"bDestroy",
")",
"{",
"var",
"sLabelId",
"=",
"oLabel",
".",
"getId",
"(",
")",
";",
"var",
"sOldId",
"=",
"oLabel",
".",
"__sLabeledControl",
";",
"var",
"sNewId",
"=",
"bDestroy",
"?",
"null",
":",
"fin... | Updates the mapping tables for the given label, in destroy case only a cleanup is done | [
"Updates",
"the",
"mapping",
"tables",
"for",
"the",
"given",
"label",
"in",
"destroy",
"case",
"only",
"a",
"cleanup",
"is",
"done"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LabelEnablement.js#L40-L94 | train | Refreshes the mapping of the control to the old control | [
30522,
3853,
25416,
21898,
2863,
14853,
1006,
19330,
16336,
2140,
1010,
1038,
6155,
13181,
2100,
1007,
1063,
13075,
17584,
20806,
2094,
1027,
19330,
16336,
2140,
1012,
2131,
3593,
1006,
1007,
1025,
13075,
2853,
3593,
1027,
19330,
16336,
2140,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-base.js | setAppsFolderPaths | function setAppsFolderPaths() {
if (this.applicationType) return;
this.appsFolderPaths = [];
for (let i = 0; i < this.appsFolders.length; i++) {
const path = this.destinationPath(this.directoryPath + this.appsFolders[i]);
this.appsFolderPaths.push(path);
}
} | javascript | function setAppsFolderPaths() {
if (this.applicationType) return;
this.appsFolderPaths = [];
for (let i = 0; i < this.appsFolders.length; i++) {
const path = this.destinationPath(this.directoryPath + this.appsFolders[i]);
this.appsFolderPaths.push(path);
}
} | [
"function",
"setAppsFolderPaths",
"(",
")",
"{",
"if",
"(",
"this",
".",
"applicationType",
")",
"return",
";",
"this",
".",
"appsFolderPaths",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"appsFolders",
".",
"len... | Set Apps Folder Paths | [
"Set",
"Apps",
"Folder",
"Paths"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-base.js#L84-L91 | train | Set the app folder paths | [
30522,
3853,
2275,
29098,
22747,
11614,
2121,
15069,
2015,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
4646,
13874,
1007,
2709,
1025,
2023,
1012,
18726,
10371,
2121,
15069,
2015,
1027,
1031,
1033,
1025,
2005,
1006,
2292,
1045,
1027,
1014,
305... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MasterTreeBaseController.js | function (sId) {
var oItems = this.byId("tree").getItems();
for (var i = 0; i < oItems.length; i++) {
if (oItems[i].getTarget() === sId) {
return oItems[i];
}
}
return null;
} | javascript | function (sId) {
var oItems = this.byId("tree").getItems();
for (var i = 0; i < oItems.length; i++) {
if (oItems[i].getTarget() === sId) {
return oItems[i];
}
}
return null;
} | [
"function",
"(",
"sId",
")",
"{",
"var",
"oItems",
"=",
"this",
".",
"byId",
"(",
"\"tree\"",
")",
".",
"getItems",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"oItems",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
... | Scans the items aggregation of a sap.m.Tree for an item that has custom data with key="topicId" and value=sId
Note: It's important to always fetch the items before searching as they change dynamically when nodes expand/collapse
@param {string} sId
@returns {null}
@private | [
"Scans",
"the",
"items",
"aggregation",
"of",
"a",
"sap",
".",
"m",
".",
"Tree",
"for",
"an",
"item",
"that",
"has",
"custom",
"data",
"with",
"key",
"=",
"topicId",
"and",
"value",
"=",
"sId",
"Note",
":",
"It",
"s",
"important",
"to",
"always",
"fe... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js#L75-L84 | train | Returns the item with the given ID | [
30522,
3853,
1006,
15765,
1007,
1063,
13075,
1051,
4221,
5244,
1027,
2023,
1012,
2011,
3593,
1006,
1000,
3392,
1000,
1007,
1012,
2131,
4221,
5244,
1006,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
1051,
4221,
5244,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | once | function once (fn) {
var called = false;
return function () {
if (!called) {
called = true;
fn.apply(this, arguments);
}
}
} | javascript | function once (fn) {
var called = false;
return function () {
if (!called) {
called = true;
fn.apply(this, arguments);
}
}
} | [
"function",
"once",
"(",
"fn",
")",
"{",
"var",
"called",
"=",
"false",
";",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"called",
")",
"{",
"called",
"=",
"true",
";",
"fn",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
... | Ensure a function is called only once. | [
"Ensure",
"a",
"function",
"is",
"called",
"only",
"once",
"."
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L248-L256 | train | Returns a function that will be called once. | [
30522,
3853,
2320,
1006,
1042,
2078,
1007,
1063,
13075,
2170,
1027,
6270,
1025,
2709,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2170,
1007,
1063,
2170,
1027,
2995,
1025,
1042,
2078,
1012,
6611,
1006,
2023,
1010,
9918,
1007,
1025,
1065,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
thomaspark/bootswatch | docs/_vendor/popper.js/dist/popper.js | findCommonOffsetParent | function findCommonOffsetParent(element1, element2) {
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
return document.documentElement;
}
// Here we make sure to give as "start" the element that comes first in the DOM
const order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
const start = order ? element1 : element2;
const end = order ? element2 : element1;
// Get common ancestor container
const range = document.createRange();
range.setStart(start, 0);
range.setEnd(end, 0);
const { commonAncestorContainer } = range;
// Both nodes are inside #document
if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
if (isOffsetContainer(commonAncestorContainer)) {
return commonAncestorContainer;
}
return getOffsetParent(commonAncestorContainer);
}
// one of the nodes is inside shadowDOM, find which one
const element1root = getRoot(element1);
if (element1root.host) {
return findCommonOffsetParent(element1root.host, element2);
} else {
return findCommonOffsetParent(element1, getRoot(element2).host);
}
} | javascript | function findCommonOffsetParent(element1, element2) {
// This check is needed to avoid errors in case one of the elements isn't defined for any reason
if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
return document.documentElement;
}
// Here we make sure to give as "start" the element that comes first in the DOM
const order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
const start = order ? element1 : element2;
const end = order ? element2 : element1;
// Get common ancestor container
const range = document.createRange();
range.setStart(start, 0);
range.setEnd(end, 0);
const { commonAncestorContainer } = range;
// Both nodes are inside #document
if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
if (isOffsetContainer(commonAncestorContainer)) {
return commonAncestorContainer;
}
return getOffsetParent(commonAncestorContainer);
}
// one of the nodes is inside shadowDOM, find which one
const element1root = getRoot(element1);
if (element1root.host) {
return findCommonOffsetParent(element1root.host, element2);
} else {
return findCommonOffsetParent(element1, getRoot(element2).host);
}
} | [
"function",
"findCommonOffsetParent",
"(",
"element1",
",",
"element2",
")",
"{",
"// This check is needed to avoid errors in case one of the elements isn't defined for any reason",
"if",
"(",
"!",
"element1",
"||",
"!",
"element1",
".",
"nodeType",
"||",
"!",
"element2",
"... | Finds the offset parent common to the two provided nodes
@method
@memberof Popper.Utils
@argument {Element} element1
@argument {Element} element2
@returns {Element} common offset parent | [
"Finds",
"the",
"offset",
"parent",
"common",
"to",
"the",
"two",
"provided",
"nodes"
] | a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd | https://github.com/thomaspark/bootswatch/blob/a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd/docs/_vendor/popper.js/dist/popper.js#L236-L269 | train | Finds the common ancestor container of two elements. | [
30522,
3853,
2424,
9006,
8202,
27475,
3388,
19362,
4765,
1006,
5783,
2487,
1010,
5783,
2475,
1007,
1063,
1013,
1013,
2023,
4638,
2003,
2734,
2000,
4468,
10697,
1999,
2553,
2028,
1997,
1996,
3787,
3475,
1005,
1056,
4225,
2005,
2151,
3114,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | FinderBuilder | function FinderBuilder(newDocument) {
// private
var doc = newDocument;
function buildIdFinder(e) {
if (e.id) {
var id = e.id;
return (function(targetDoc) {
return targetDoc.getElementById(id);
});
}
return null;
}
function buildTagNameFinder(e) {
var elements = doc.getElementsByTagName(e.tagName);
for (var i = 0, n = elements.length; i < n; ++i) {
if (elements[i] === e) {
// both the descendant axis and getElementsByTagName() should
// return elements in document order; hence the following index
// operation is possible
return (function(targetDoc) {
return targetDoc.getElementsByTagName(e.tagName)[i];
});
}
}
return null;
}
// public
this.setDocument = function(newDocument) {
doc = newDocument;
return this;
};
this.build = function(e) {
return (
buildIdFinder(e) ||
buildTagNameFinder(e)
);
};
} | javascript | function FinderBuilder(newDocument) {
// private
var doc = newDocument;
function buildIdFinder(e) {
if (e.id) {
var id = e.id;
return (function(targetDoc) {
return targetDoc.getElementById(id);
});
}
return null;
}
function buildTagNameFinder(e) {
var elements = doc.getElementsByTagName(e.tagName);
for (var i = 0, n = elements.length; i < n; ++i) {
if (elements[i] === e) {
// both the descendant axis and getElementsByTagName() should
// return elements in document order; hence the following index
// operation is possible
return (function(targetDoc) {
return targetDoc.getElementsByTagName(e.tagName)[i];
});
}
}
return null;
}
// public
this.setDocument = function(newDocument) {
doc = newDocument;
return this;
};
this.build = function(e) {
return (
buildIdFinder(e) ||
buildTagNameFinder(e)
);
};
} | [
"function",
"FinderBuilder",
"(",
"newDocument",
")",
"{",
"// private",
"var",
"doc",
"=",
"newDocument",
";",
"function",
"buildIdFinder",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"id",
")",
"{",
"var",
"id",
"=",
"e",
".",
"id",
";",
"return",
"("... | /////////////////////////////////////////////////////////////////////////////
Builds and returns closures that take a document and return a node. | [
"/////////////////////////////////////////////////////////////////////////////",
"Builds",
"and",
"returns",
"closures",
"that",
"take",
"a",
"document",
"and",
"return",
"a",
"node",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L1369-L1414 | train | Constructor for FinderBuilder | [
30522,
3853,
2424,
2121,
8569,
23891,
2099,
1006,
2047,
3527,
24894,
4765,
1007,
1063,
1013,
1013,
2797,
13075,
9986,
1027,
2047,
3527,
24894,
4765,
1025,
3853,
3857,
3593,
23695,
1006,
1041,
1007,
1063,
2065,
1006,
1041,
1012,
8909,
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/components/switch/switch.js | MdSwitch | function MdSwitch(mdCheckboxDirective, $mdUtil, $mdConstant, $parse, $$rAF, $mdGesture, $timeout) {
var checkboxDirective = mdCheckboxDirective[0];
return {
restrict: 'E',
priority: $mdConstant.BEFORE_NG_ARIA,
transclude: true,
template:
'<div class="md-container">' +
'<div class="md-bar"></div>' +
'<div class="md-thumb-container">' +
'<div class="md-thumb" md-ink-ripple md-ink-ripple-checkbox></div>' +
'</div>'+
'</div>' +
'<div ng-transclude class="md-label"></div>',
require: ['^?mdInputContainer', '?ngModel', '?^form'],
compile: mdSwitchCompile
};
function mdSwitchCompile(element, attr) {
var checkboxLink = checkboxDirective.compile(element, attr).post;
// No transition on initial load.
element.addClass('md-dragging');
return function (scope, element, attr, ctrls) {
var containerCtrl = ctrls[0];
var ngModel = ctrls[1] || $mdUtil.fakeNgModel();
var formCtrl = ctrls[2];
var disabledGetter = null;
if (attr.disabled != null) {
disabledGetter = function() { return true; };
} else if (attr.ngDisabled) {
disabledGetter = $parse(attr.ngDisabled);
}
var thumbContainer = angular.element(element[0].querySelector('.md-thumb-container'));
var switchContainer = angular.element(element[0].querySelector('.md-container'));
var labelContainer = angular.element(element[0].querySelector('.md-label'));
// no transition on initial load
$$rAF(function() {
element.removeClass('md-dragging');
});
checkboxLink(scope, element, attr, ctrls);
if (disabledGetter) {
scope.$watch(disabledGetter, function(isDisabled) {
element.attr('tabindex', isDisabled ? -1 : 0);
});
}
attr.$observe('mdInvert', function(newValue) {
var isInverted = $mdUtil.parseAttributeBoolean(newValue);
isInverted ? element.prepend(labelContainer) : element.prepend(switchContainer);
// Toggle a CSS class to update the margin.
element.toggleClass('md-inverted', isInverted);
});
// These events are triggered by setup drag
$mdGesture.register(switchContainer, 'drag');
switchContainer
.on('$md.dragstart', onDragStart)
.on('$md.drag', onDrag)
.on('$md.dragend', onDragEnd);
var drag;
function onDragStart(ev) {
// Don't go if the switch is disabled.
if (disabledGetter && disabledGetter(scope)) return;
ev.stopPropagation();
element.addClass('md-dragging');
drag = {width: thumbContainer.prop('offsetWidth')};
}
function onDrag(ev) {
if (!drag) return;
ev.stopPropagation();
ev.srcEvent && ev.srcEvent.preventDefault();
var percent = ev.pointer.distanceX / drag.width;
// if checked, start from right. else, start from left
var translate = ngModel.$viewValue ? 1 + percent : percent;
// Make sure the switch stays inside its bounds, 0-1%
translate = Math.max(0, Math.min(1, translate));
thumbContainer.css($mdConstant.CSS.TRANSFORM, 'translate3d(' + (100*translate) + '%,0,0)');
drag.translate = translate;
}
function onDragEnd(ev) {
if (!drag) return;
ev.stopPropagation();
element.removeClass('md-dragging');
thumbContainer.css($mdConstant.CSS.TRANSFORM, '');
// We changed if there is no distance (this is a click a click),
// or if the drag distance is >50% of the total.
var isChanged = ngModel.$viewValue ? drag.translate < 0.5 : drag.translate > 0.5;
if (isChanged) {
applyModelValue(!ngModel.$viewValue);
}
drag = null;
// Wait for incoming mouse click
scope.skipToggle = true;
$timeout(function() {
scope.skipToggle = false;
}, 1);
}
function applyModelValue(newValue) {
scope.$apply(function() {
ngModel.$setViewValue(newValue);
ngModel.$render();
});
}
};
}
} | javascript | function MdSwitch(mdCheckboxDirective, $mdUtil, $mdConstant, $parse, $$rAF, $mdGesture, $timeout) {
var checkboxDirective = mdCheckboxDirective[0];
return {
restrict: 'E',
priority: $mdConstant.BEFORE_NG_ARIA,
transclude: true,
template:
'<div class="md-container">' +
'<div class="md-bar"></div>' +
'<div class="md-thumb-container">' +
'<div class="md-thumb" md-ink-ripple md-ink-ripple-checkbox></div>' +
'</div>'+
'</div>' +
'<div ng-transclude class="md-label"></div>',
require: ['^?mdInputContainer', '?ngModel', '?^form'],
compile: mdSwitchCompile
};
function mdSwitchCompile(element, attr) {
var checkboxLink = checkboxDirective.compile(element, attr).post;
// No transition on initial load.
element.addClass('md-dragging');
return function (scope, element, attr, ctrls) {
var containerCtrl = ctrls[0];
var ngModel = ctrls[1] || $mdUtil.fakeNgModel();
var formCtrl = ctrls[2];
var disabledGetter = null;
if (attr.disabled != null) {
disabledGetter = function() { return true; };
} else if (attr.ngDisabled) {
disabledGetter = $parse(attr.ngDisabled);
}
var thumbContainer = angular.element(element[0].querySelector('.md-thumb-container'));
var switchContainer = angular.element(element[0].querySelector('.md-container'));
var labelContainer = angular.element(element[0].querySelector('.md-label'));
// no transition on initial load
$$rAF(function() {
element.removeClass('md-dragging');
});
checkboxLink(scope, element, attr, ctrls);
if (disabledGetter) {
scope.$watch(disabledGetter, function(isDisabled) {
element.attr('tabindex', isDisabled ? -1 : 0);
});
}
attr.$observe('mdInvert', function(newValue) {
var isInverted = $mdUtil.parseAttributeBoolean(newValue);
isInverted ? element.prepend(labelContainer) : element.prepend(switchContainer);
// Toggle a CSS class to update the margin.
element.toggleClass('md-inverted', isInverted);
});
// These events are triggered by setup drag
$mdGesture.register(switchContainer, 'drag');
switchContainer
.on('$md.dragstart', onDragStart)
.on('$md.drag', onDrag)
.on('$md.dragend', onDragEnd);
var drag;
function onDragStart(ev) {
// Don't go if the switch is disabled.
if (disabledGetter && disabledGetter(scope)) return;
ev.stopPropagation();
element.addClass('md-dragging');
drag = {width: thumbContainer.prop('offsetWidth')};
}
function onDrag(ev) {
if (!drag) return;
ev.stopPropagation();
ev.srcEvent && ev.srcEvent.preventDefault();
var percent = ev.pointer.distanceX / drag.width;
// if checked, start from right. else, start from left
var translate = ngModel.$viewValue ? 1 + percent : percent;
// Make sure the switch stays inside its bounds, 0-1%
translate = Math.max(0, Math.min(1, translate));
thumbContainer.css($mdConstant.CSS.TRANSFORM, 'translate3d(' + (100*translate) + '%,0,0)');
drag.translate = translate;
}
function onDragEnd(ev) {
if (!drag) return;
ev.stopPropagation();
element.removeClass('md-dragging');
thumbContainer.css($mdConstant.CSS.TRANSFORM, '');
// We changed if there is no distance (this is a click a click),
// or if the drag distance is >50% of the total.
var isChanged = ngModel.$viewValue ? drag.translate < 0.5 : drag.translate > 0.5;
if (isChanged) {
applyModelValue(!ngModel.$viewValue);
}
drag = null;
// Wait for incoming mouse click
scope.skipToggle = true;
$timeout(function() {
scope.skipToggle = false;
}, 1);
}
function applyModelValue(newValue) {
scope.$apply(function() {
ngModel.$setViewValue(newValue);
ngModel.$render();
});
}
};
}
} | [
"function",
"MdSwitch",
"(",
"mdCheckboxDirective",
",",
"$mdUtil",
",",
"$mdConstant",
",",
"$parse",
",",
"$$rAF",
",",
"$mdGesture",
",",
"$timeout",
")",
"{",
"var",
"checkboxDirective",
"=",
"mdCheckboxDirective",
"[",
"0",
"]",
";",
"return",
"{",
"restr... | @ngdoc directive
@module material.components.switch
@name mdSwitch
@restrict E
The switch directive is used very much like the normal [angular checkbox](https://docs.angularjs.org/api/ng/input/input%5Bcheckbox%5D).
As per the [Material Design spec](https://material.io/archive/guidelines/style/color.html#color-color-system)
the switch is in the accent color by default. The primary color palette may be used with
the `md-primary` class.
@param {expression} ng-model Assignable angular expression to data-bind to.
@param {string=} name Property name of the form under which the control is published.
@param {expression=} ng-true-value The value to which the expression should be set when selected.
@param {expression=} ng-false-value The value to which the expression should be set when not selected.
@param {expression=} ng-change Expression to be executed when the model value changes.
@param {expression=} ng-disabled En/Disable based on the expression.
@param {boolean=} md-no-ink Use of attribute indicates use of ripple ink effects.
@param {string=} aria-label Publish the button label used by screen-readers for accessibility. Defaults to the switch's text.
@param {boolean=} md-invert When set to true, the switch will be inverted.
@usage
<hljs lang="html">
<md-switch ng-model="isActive" aria-label="Finished?">
Finished ?
</md-switch>
<md-switch md-no-ink ng-model="hasInk" aria-label="No Ink Effects">
No Ink Effects
</md-switch>
<md-switch ng-disabled="true" ng-model="isDisabled" aria-label="Disabled">
Disabled
</md-switch>
</hljs> | [
"@ngdoc",
"directive",
"@module",
"material",
".",
"components",
".",
"switch",
"@name",
"mdSwitch",
"@restrict",
"E"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/switch/switch.js#L50-L178 | train | A directive that is used to create a md - switch directive. | [
30522,
3853,
9108,
26760,
20189,
1006,
9108,
5403,
3600,
8758,
4305,
2890,
15277,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
9108,
8663,
12693,
2102,
1010,
1002,
11968,
3366,
1010,
1002,
1002,
7148,
1010,
1002,
9108,
8449,
11244,
1010,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mochajs/mocha | lib/reporters/min.js | Min | function Min(runner, options) {
Base.call(this, runner, options);
runner.on(EVENT_RUN_BEGIN, function() {
// clear screen
process.stdout.write('\u001b[2J');
// set cursor position
process.stdout.write('\u001b[1;3H');
});
runner.once(EVENT_RUN_END, this.epilogue.bind(this));
} | javascript | function Min(runner, options) {
Base.call(this, runner, options);
runner.on(EVENT_RUN_BEGIN, function() {
// clear screen
process.stdout.write('\u001b[2J');
// set cursor position
process.stdout.write('\u001b[1;3H');
});
runner.once(EVENT_RUN_END, this.epilogue.bind(this));
} | [
"function",
"Min",
"(",
"runner",
",",
"options",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
",",
"options",
")",
";",
"runner",
".",
"on",
"(",
"EVENT_RUN_BEGIN",
",",
"function",
"(",
")",
"{",
"// clear screen",
"process",
".",
"stdo... | Constructs a new `Min` reporter instance.
@description
This minimal test reporter is best used with '--watch'.
@public
@class
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options | [
"Constructs",
"a",
"new",
"Min",
"reporter",
"instance",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/min.js#L34-L45 | train | A base class for the min command. | [
30522,
3853,
8117,
1006,
5479,
1010,
7047,
1007,
1063,
2918,
1012,
2655,
1006,
2023,
1010,
5479,
1010,
7047,
1007,
1025,
5479,
1012,
2006,
1006,
2724,
1035,
2448,
1035,
4088,
1010,
3853,
1006,
1007,
1063,
1013,
1013,
3154,
3898,
2832,
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... |
googleapis/google-api-nodejs-client | samples/youtube/search.js | runSample | async function runSample() {
const res = await youtube.search.list({
part: 'id,snippet',
q: 'Node.js on Google Cloud',
});
console.log(res.data);
} | javascript | async function runSample() {
const res = await youtube.search.list({
part: 'id,snippet',
q: 'Node.js on Google Cloud',
});
console.log(res.data);
} | [
"async",
"function",
"runSample",
"(",
")",
"{",
"const",
"res",
"=",
"await",
"youtube",
".",
"search",
".",
"list",
"(",
"{",
"part",
":",
"'id,snippet'",
",",
"q",
":",
"'Node.js on Google Cloud'",
",",
"}",
")",
";",
"console",
".",
"log",
"(",
"re... | a very simple example of searching for youtube videos | [
"a",
"very",
"simple",
"example",
"of",
"searching",
"for",
"youtube",
"videos"
] | e6e632a29d0b246d058e3067de3a5c3827e2b54e | https://github.com/googleapis/google-api-nodejs-client/blob/e6e632a29d0b246d058e3067de3a5c3827e2b54e/samples/youtube/search.js#L26-L32 | train | This is the sample of the sample. | [
30522,
2004,
6038,
2278,
3853,
3216,
16613,
2571,
1006,
1007,
1063,
9530,
3367,
24501,
30524,
29519,
1005,
1010,
1053,
1024,
1005,
13045,
1012,
1046,
2015,
2006,
8224,
6112,
1005,
1010,
1065,
1007,
1025,
10122,
1012,
8833,
1006,
24501,
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... |
fengyuanchen/cropper | dist/cropper.common.js | Cropper | function Cropper(element) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Cropper);
if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
throw new Error('The first argument is required and must be an <img> or <canvas> element.');
}
this.element = element;
this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
this.cropped = false;
this.disabled = false;
this.pointers = {};
this.ready = false;
this.reloading = false;
this.replaced = false;
this.sized = false;
this.sizing = false;
this.init();
} | javascript | function Cropper(element) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Cropper);
if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
throw new Error('The first argument is required and must be an <img> or <canvas> element.');
}
this.element = element;
this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
this.cropped = false;
this.disabled = false;
this.pointers = {};
this.ready = false;
this.reloading = false;
this.replaced = false;
this.sized = false;
this.sizing = false;
this.init();
} | [
"function",
"Cropper",
"(",
"element",
")",
"{",
"var",
"options",
"=",
"arguments",
".",
"length",
">",
"1",
"&&",
"arguments",
"[",
"1",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"1",
"]",
":",
"{",
"}",
";",
"classCallCheck",
"(",
"this",
",... | Create a new Cropper.
@param {Element} element - The target element for cropping.
@param {Object} [options={}] - The configuration options. | [
"Create",
"a",
"new",
"Cropper",
"."
] | 6677332a6a375b647f58808dfc24ea09f5804041 | https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L3266-L3285 | train | Cropper constructor. | [
30522,
3853,
10416,
4842,
1006,
5783,
1007,
1063,
13075,
7047,
1027,
9918,
1012,
3091,
1028,
1015,
1004,
1004,
9918,
1031,
1015,
1033,
999,
1027,
1027,
6151,
28344,
1029,
9918,
1031,
1015,
1033,
1024,
1063,
1065,
1025,
2465,
9289,
29358,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensibility/ExtensionManagerViewModel.js | filterForKeyword | function filterForKeyword(extensionList, word) {
var filteredList = [];
extensionList.forEach(function (id) {
var entry = self._getEntry(id);
if (entry && self._entryMatchesQuery(entry, word)) {
filteredList.push(id);
}
});
return filteredList;
} | javascript | function filterForKeyword(extensionList, word) {
var filteredList = [];
extensionList.forEach(function (id) {
var entry = self._getEntry(id);
if (entry && self._entryMatchesQuery(entry, word)) {
filteredList.push(id);
}
});
return filteredList;
} | [
"function",
"filterForKeyword",
"(",
"extensionList",
",",
"word",
")",
"{",
"var",
"filteredList",
"=",
"[",
"]",
";",
"extensionList",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"var",
"entry",
"=",
"self",
".",
"_getEntry",
"(",
"id",
")",
... | Takes 'extensionList' and returns a version filtered to only those that match 'keyword' | [
"Takes",
"extensionList",
"and",
"returns",
"a",
"version",
"filtered",
"to",
"only",
"those",
"that",
"match",
"keyword"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManagerViewModel.js#L214-L223 | train | filterForKeyword - Filter for a given word | [
30522,
3853,
11307,
29278,
14839,
18351,
1006,
5331,
9863,
1010,
2773,
1007,
1063,
13075,
21839,
9863,
1027,
1031,
1033,
1025,
5331,
9863,
1012,
18921,
6776,
1006,
3853,
1006,
8909,
1007,
1063,
13075,
4443,
1027,
2969,
1012,
1035,
2131,
476... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wangfupeng1988/wangEditor | src/js/menus/index.js | function () {
const menus = this.menus
objForEach(menus, (key, menu) => {
if (menu.tryChangeActive) {
setTimeout(() => {
menu.tryChangeActive()
}, 100)
}
})
} | javascript | function () {
const menus = this.menus
objForEach(menus, (key, menu) => {
if (menu.tryChangeActive) {
setTimeout(() => {
menu.tryChangeActive()
}, 100)
}
})
} | [
"function",
"(",
")",
"{",
"const",
"menus",
"=",
"this",
".",
"menus",
"objForEach",
"(",
"menus",
",",
"(",
"key",
",",
"menu",
")",
"=>",
"{",
"if",
"(",
"menu",
".",
"tryChangeActive",
")",
"{",
"setTimeout",
"(",
"(",
")",
"=>",
"{",
"menu",
... | 尝试修改菜单状态 | [
"尝试修改菜单状态"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/index.js#L113-L122 | train | Try to change active menu | [
30522,
3853,
1006,
1007,
1063,
9530,
3367,
12183,
2015,
1027,
2023,
1012,
12183,
2015,
27885,
3501,
29278,
5243,
2818,
1006,
12183,
2015,
1010,
1006,
3145,
1010,
12183,
1007,
1027,
30524,
1007,
1065,
1010,
2531,
1007,
1065,
1065,
1007,
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... | |
ccxt/ccxt | build/transpile.js | transpileJavaScriptToPythonAndPHP | function transpileJavaScriptToPythonAndPHP (args) {
//-------------------------------------------------------------------------
// transpile JS → Python 3
let python3Body = transpileJavaScriptToPython3 (args)
//-------------------------------------------------------------------------
// remove await from Python 2 body (transpile Python 3 → Python 2)
let python2Body = transpilePython3ToPython2 (python3Body)
//-------------------------------------------------------------------------
// transpile JS → PHP
let phpBody = transpileJavaScriptToPHP (args)
return { python3Body, python2Body, phpBody }
} | javascript | function transpileJavaScriptToPythonAndPHP (args) {
//-------------------------------------------------------------------------
// transpile JS → Python 3
let python3Body = transpileJavaScriptToPython3 (args)
//-------------------------------------------------------------------------
// remove await from Python 2 body (transpile Python 3 → Python 2)
let python2Body = transpilePython3ToPython2 (python3Body)
//-------------------------------------------------------------------------
// transpile JS → PHP
let phpBody = transpileJavaScriptToPHP (args)
return { python3Body, python2Body, phpBody }
} | [
"function",
"transpileJavaScriptToPythonAndPHP",
"(",
"args",
")",
"{",
"//-------------------------------------------------------------------------",
"// transpile JS → Python 3",
"let",
"python3Body",
"=",
"transpileJavaScriptToPython3",
"(",
"args",
")",
"//-------------------------... | ---------------------------------------------------------------------------- | [
"----------------------------------------------------------------------------"
] | 8168069b9180a465532905e225586215e115a565 | https://github.com/ccxt/ccxt/blob/8168069b9180a465532905e225586215e115a565/build/transpile.js#L565-L583 | train | transpile JavaScript to Python and PHP | [
30522,
3853,
9099,
22090,
3900,
12044,
23235,
14399,
22123,
8747,
5685,
8458,
2361,
1006,
12098,
5620,
1007,
1063,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ccxt/ccxt | js/static_dependencies/qs/parse.js | parseQueryStringValues | function parseQueryStringValues(str, options) {
var obj = {};
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
var i;
var charset = options.charset;
if (options.charsetSentinel) {
for (i = 0; i < parts.length; ++i) {
if (parts[i].indexOf('utf8=') === 0) {
if (parts[i] === charsetSentinel) {
charset = 'utf-8';
} else if (parts[i] === isoSentinel) {
charset = 'iso-8859-1';
}
skipIndex = i;
i = parts.length; // The eslint settings do not allow break;
}
}
}
for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
var part = parts[i];
var bracketEqualsPos = part.indexOf(']=');
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
key = options.decoder(part, defaults.decoder, charset);
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);
}
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
val = interpretNumericEntities(val);
}
if (val && options.comma && val.indexOf(',') > -1) {
val = val.split(',');
}
if (has.call(obj, key)) {
obj[key] = utils.combine(obj[key], val);
} else {
obj[key] = val;
}
}
return obj;
} | javascript | function parseQueryStringValues(str, options) {
var obj = {};
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
var i;
var charset = options.charset;
if (options.charsetSentinel) {
for (i = 0; i < parts.length; ++i) {
if (parts[i].indexOf('utf8=') === 0) {
if (parts[i] === charsetSentinel) {
charset = 'utf-8';
} else if (parts[i] === isoSentinel) {
charset = 'iso-8859-1';
}
skipIndex = i;
i = parts.length; // The eslint settings do not allow break;
}
}
}
for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
var part = parts[i];
var bracketEqualsPos = part.indexOf(']=');
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
key = options.decoder(part, defaults.decoder, charset);
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.slice(0, pos), defaults.decoder, charset);
val = options.decoder(part.slice(pos + 1), defaults.decoder, charset);
}
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
val = interpretNumericEntities(val);
}
if (val && options.comma && val.indexOf(',') > -1) {
val = val.split(',');
}
if (has.call(obj, key)) {
obj[key] = utils.combine(obj[key], val);
} else {
obj[key] = val;
}
}
return obj;
} | [
"function",
"parseQueryStringValues",
"(",
"str",
",",
"options",
")",
"{",
"var",
"obj",
"=",
"{",
"}",
";",
"var",
"cleanStr",
"=",
"options",
".",
"ignoreQueryPrefix",
"?",
"str",
".",
"replace",
"(",
"/",
"^\\?",
"/",
",",
"''",
")",
":",
"str",
... | encodeURIComponent('✓') | [
"encodeURIComponent",
"(",
"✓",
")"
] | 8168069b9180a465532905e225586215e115a565 | https://github.com/ccxt/ccxt/blob/8168069b9180a465532905e225586215e115a565/js/static_dependencies/qs/parse.js#L41-L98 | train | Parses a query string into an object | [
30522,
3853,
11968,
3366,
4226,
24769,
18886,
3070,
10175,
15808,
1006,
2358,
2099,
1010,
7047,
1007,
1063,
13075,
27885,
3501,
1027,
1063,
1065,
1025,
13075,
4550,
3367,
2099,
1027,
7047,
1012,
8568,
4226,
2854,
28139,
8873,
2595,
1029,
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... |
adobe/brackets | src/language/JSUtils.js | function (node) {
if (node.right && node.right.type === "FunctionExpression") {
if (node.left && node.left.type === "MemberExpression" && node.left.property) {
_addResult(node.left.property);
}
}
} | javascript | function (node) {
if (node.right && node.right.type === "FunctionExpression") {
if (node.left && node.left.type === "MemberExpression" && node.left.property) {
_addResult(node.left.property);
}
}
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"right",
"&&",
"node",
".",
"right",
".",
"type",
"===",
"\"FunctionExpression\"",
")",
"{",
"if",
"(",
"node",
".",
"left",
"&&",
"node",
".",
"left",
".",
"type",
"===",
"\"MemberExpression\"... | /*
SomeFunction.prototype.<functionName> = function () {} | [
"/",
"*",
"SomeFunction",
".",
"prototype",
".",
"<functionName",
">",
"=",
"function",
"()",
"{}"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSUtils.js#L135-L141 | train | Add a result to the result list | [
30522,
3853,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
2157,
1004,
1004,
13045,
1012,
2157,
1012,
2828,
1027,
1027,
1027,
1000,
3853,
10288,
20110,
3258,
1000,
1007,
1063,
2065,
1006,
13045,
1012,
2187,
1004,
1004,
13045,
1012,
2187... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function(container, x, y)
{
var origin = mxUtils.getScrollOrigin(container, false);
var offset = mxUtils.getOffset(container);
offset.x -= origin.x;
offset.y -= origin.y;
return new mxPoint(x - offset.x, y - offset.y);
} | javascript | function(container, x, y)
{
var origin = mxUtils.getScrollOrigin(container, false);
var offset = mxUtils.getOffset(container);
offset.x -= origin.x;
offset.y -= origin.y;
return new mxPoint(x - offset.x, y - offset.y);
} | [
"function",
"(",
"container",
",",
"x",
",",
"y",
")",
"{",
"var",
"origin",
"=",
"mxUtils",
".",
"getScrollOrigin",
"(",
"container",
",",
"false",
")",
";",
"var",
"offset",
"=",
"mxUtils",
".",
"getOffset",
"(",
"container",
")",
";",
"offset",
".",... | Function: convertPoint
Converts the specified point (x, y) using the offset of the specified
container and returns a new <mxPoint> with the result.
(code)
var pt = mxUtils.convertPoint(graph.container,
mxEvent.getClientX(evt), mxEvent.getClientY(evt));
(end)
Parameters:
container - DOM node to use for the offset.
x - X-coordinate of the point to be converted.
y - Y-coordinate of the point to be converted. | [
"Function",
":",
"convertPoint"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4888-L4897 | train | Returns the absolute position of the container | [
30522,
3853,
1006,
11661,
1010,
1060,
1010,
1061,
1007,
1063,
13075,
4761,
1027,
25630,
21823,
4877,
1012,
4152,
26775,
14511,
10050,
11528,
1006,
11661,
1010,
6270,
1007,
1025,
13075,
16396,
1027,
25630,
21823,
4877,
1012,
2131,
27475,
3388,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/GrowingEnablement.js | function(sChangeReason) {
if (!this._bDataRequested) {
this._bDataRequested = true;
this._onBeforePageLoaded(sChangeReason);
}
// set iItemCount to initial value if not set or no items at the control yet
if (!this._iLimit || this.shouldReset(sChangeReason) || !this._oControl.getItems(true).length) {
this._iLimit = this._oControl.getGrowingThreshold();
}
// send the request to get the context
this._oControl.getBinding("items").getContexts(0, this._iLimit);
} | javascript | function(sChangeReason) {
if (!this._bDataRequested) {
this._bDataRequested = true;
this._onBeforePageLoaded(sChangeReason);
}
// set iItemCount to initial value if not set or no items at the control yet
if (!this._iLimit || this.shouldReset(sChangeReason) || !this._oControl.getItems(true).length) {
this._iLimit = this._oControl.getGrowingThreshold();
}
// send the request to get the context
this._oControl.getBinding("items").getContexts(0, this._iLimit);
} | [
"function",
"(",
"sChangeReason",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_bDataRequested",
")",
"{",
"this",
".",
"_bDataRequested",
"=",
"true",
";",
"this",
".",
"_onBeforePageLoaded",
"(",
"sChangeReason",
")",
";",
"}",
"// set iItemCount to initial value i... | refresh items only for OData model. | [
"refresh",
"items",
"only",
"for",
"OData",
"model",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/GrowingEnablement.js#L450-L463 | train | This method is called when the control has been loaded | [
30522,
3853,
1006,
8040,
18003,
7869,
3022,
2239,
1007,
1063,
2065,
1006,
999,
2023,
1012,
1035,
1038,
2850,
7559,
2063,
15500,
2098,
1007,
1063,
2023,
1012,
1035,
1038,
2850,
7559,
2063,
15500,
2098,
1027,
2995,
1025,
2023,
1012,
1035,
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... | |
ecomfe/zrender | src/animation/Animator.js | function (time /* ms */, props) {
var tracks = this._tracks;
for (var propName in props) {
if (!props.hasOwnProperty(propName)) {
continue;
}
if (!tracks[propName]) {
tracks[propName] = [];
// Invalid value
var value = this._getter(this._target, propName);
if (value == null) {
// zrLog('Invalid property ' + propName);
continue;
}
// If time is 0
// Then props is given initialize value
// Else
// Initialize value from current prop value
if (time !== 0) {
tracks[propName].push({
time: 0,
value: cloneValue(value)
});
}
}
tracks[propName].push({
time: time,
value: props[propName]
});
}
return this;
} | javascript | function (time /* ms */, props) {
var tracks = this._tracks;
for (var propName in props) {
if (!props.hasOwnProperty(propName)) {
continue;
}
if (!tracks[propName]) {
tracks[propName] = [];
// Invalid value
var value = this._getter(this._target, propName);
if (value == null) {
// zrLog('Invalid property ' + propName);
continue;
}
// If time is 0
// Then props is given initialize value
// Else
// Initialize value from current prop value
if (time !== 0) {
tracks[propName].push({
time: 0,
value: cloneValue(value)
});
}
}
tracks[propName].push({
time: time,
value: props[propName]
});
}
return this;
} | [
"function",
"(",
"time",
"/* ms */",
",",
"props",
")",
"{",
"var",
"tracks",
"=",
"this",
".",
"_tracks",
";",
"for",
"(",
"var",
"propName",
"in",
"props",
")",
"{",
"if",
"(",
"!",
"props",
".",
"hasOwnProperty",
"(",
"propName",
")",
")",
"{",
... | 设置动画关键帧
@param {number} time 关键帧时间,单位是ms
@param {Object} props 关键帧的属性值,key-value表示
@return {module:zrender/animation/Animator} | [
"设置动画关键帧"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/animation/Animator.js#L472-L504 | train | Set the value of all tracks | [
30522,
3853,
1006,
2051,
1013,
1008,
5796,
1008,
1013,
1010,
24387,
1007,
1063,
13075,
3162,
1027,
2023,
1012,
1035,
3162,
1025,
2005,
1006,
13075,
17678,
18442,
1999,
24387,
1007,
1063,
2065,
1006,
999,
24387,
1012,
2038,
12384,
21572,
484... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | calcPointToPercentage | function calcPointToPercentage ( calcPoint ) {
var location = calcPoint - offset(scope_Base, options.ort);
var proposal = ( location * 100 ) / baseSize();
return options.dir ? 100 - proposal : proposal;
} | javascript | function calcPointToPercentage ( calcPoint ) {
var location = calcPoint - offset(scope_Base, options.ort);
var proposal = ( location * 100 ) / baseSize();
return options.dir ? 100 - proposal : proposal;
} | [
"function",
"calcPointToPercentage",
"(",
"calcPoint",
")",
"{",
"var",
"location",
"=",
"calcPoint",
"-",
"offset",
"(",
"scope_Base",
",",
"options",
".",
"ort",
")",
";",
"var",
"proposal",
"=",
"(",
"location",
"*",
"100",
")",
"/",
"baseSize",
"(",
... | Translate a coordinate in the document to a percentage on the slider | [
"Translate",
"a",
"coordinate",
"in",
"the",
"document",
"to",
"a",
"percentage",
"on",
"the",
"slider"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1360-L1364 | train | Calculate the percentage of the location in the scope | [
30522,
3853,
10250,
21906,
25785,
14399,
2121,
13013,
4270,
1006,
10250,
30524,
1027,
1006,
3295,
1008,
2531,
1007,
1013,
7888,
4697,
1006,
1007,
1025,
2709,
7047,
1012,
16101,
1029,
2531,
1011,
6378,
1024,
6378,
1025,
1065,
102,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
codemirror/CodeMirror | src/model/changes.js | rebaseHistArray | function rebaseHistArray(array, from, to, diff) {
for (let i = 0; i < array.length; ++i) {
let sub = array[i], ok = true
if (sub.ranges) {
if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }
for (let j = 0; j < sub.ranges.length; j++) {
rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
}
continue
}
for (let j = 0; j < sub.changes.length; ++j) {
let cur = sub.changes[j]
if (to < cur.from.line) {
cur.from = Pos(cur.from.line + diff, cur.from.ch)
cur.to = Pos(cur.to.line + diff, cur.to.ch)
} else if (from <= cur.to.line) {
ok = false
break
}
}
if (!ok) {
array.splice(0, i + 1)
i = 0
}
}
} | javascript | function rebaseHistArray(array, from, to, diff) {
for (let i = 0; i < array.length; ++i) {
let sub = array[i], ok = true
if (sub.ranges) {
if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }
for (let j = 0; j < sub.ranges.length; j++) {
rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
}
continue
}
for (let j = 0; j < sub.changes.length; ++j) {
let cur = sub.changes[j]
if (to < cur.from.line) {
cur.from = Pos(cur.from.line + diff, cur.from.ch)
cur.to = Pos(cur.to.line + diff, cur.to.ch)
} else if (from <= cur.to.line) {
ok = false
break
}
}
if (!ok) {
array.splice(0, i + 1)
i = 0
}
}
} | [
"function",
"rebaseHistArray",
"(",
"array",
",",
"from",
",",
"to",
",",
"diff",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"++",
"i",
")",
"{",
"let",
"sub",
"=",
"array",
"[",
"i",
"]",
",",
"ok... | Tries to rebase an array of history events given a change in the document. If the change touches the same lines as the event, the event, and everything 'behind' it, is discarded. If the change is before the event, the event's positions are updated. Uses a copy-on-write scheme for the positions, to avoid having to reallocate them all on every rebase, but also avoid problems with shared position objects being unsafely updated. | [
"Tries",
"to",
"rebase",
"an",
"array",
"of",
"history",
"events",
"given",
"a",
"change",
"in",
"the",
"document",
".",
"If",
"the",
"change",
"touches",
"the",
"same",
"lines",
"as",
"the",
"event",
"the",
"event",
"and",
"everything",
"behind",
"it",
... | dab6f676107c10ba8d16c654a42f66cae3f27db1 | https://github.com/codemirror/CodeMirror/blob/dab6f676107c10ba8d16c654a42f66cae3f27db1/src/model/changes.js#L292-L318 | train | rebase the history of a range | [
30522,
3853,
2128,
15058,
24158,
7559,
9447,
1006,
9140,
1010,
2013,
1010,
2000,
1010,
4487,
4246,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
9140,
1012,
3091,
1025,
1009,
1009,
1045,
1007,
1063,
2292,
4942,
1027,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-loop-func.js | getTopLoopNode | function getTopLoopNode(node, excludedNode) {
const border = excludedNode ? excludedNode.range[1] : 0;
let retv = node;
let containingLoopNode = node;
while (containingLoopNode && containingLoopNode.range[0] >= border) {
retv = containingLoopNode;
containingLoopNode = getContainingLoopNode(containingLoopNode);
}
return retv;
} | javascript | function getTopLoopNode(node, excludedNode) {
const border = excludedNode ? excludedNode.range[1] : 0;
let retv = node;
let containingLoopNode = node;
while (containingLoopNode && containingLoopNode.range[0] >= border) {
retv = containingLoopNode;
containingLoopNode = getContainingLoopNode(containingLoopNode);
}
return retv;
} | [
"function",
"getTopLoopNode",
"(",
"node",
",",
"excludedNode",
")",
"{",
"const",
"border",
"=",
"excludedNode",
"?",
"excludedNode",
".",
"range",
"[",
"1",
"]",
":",
"0",
";",
"let",
"retv",
"=",
"node",
";",
"let",
"containingLoopNode",
"=",
"node",
... | Gets the containing loop node of a given node.
If the loop was nested, this returns the most outer loop.
@param {ASTNode} node - A node to get. This is a loop node.
@param {ASTNode|null} excludedNode - A node that the result node should not
include.
@returns {ASTNode} The most outer loop node. | [
"Gets",
"the",
"containing",
"loop",
"node",
"of",
"a",
"given",
"node",
".",
"If",
"the",
"loop",
"was",
"nested",
"this",
"returns",
"the",
"most",
"outer",
"loop",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-loop-func.js#L72-L83 | train | Get the top loop node of a node | [
30522,
3853,
2131,
14399,
4135,
7361,
3630,
3207,
1006,
13045,
1010,
12421,
3630,
3207,
1007,
1063,
9530,
3367,
3675,
1027,
12421,
3630,
3207,
1029,
12421,
3630,
3207,
1012,
2846,
1031,
1015,
1033,
1024,
1014,
1025,
2292,
2128,
9189,
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... |
dequelabs/axe-core | lib/core/utils/respondable.js | post | function post(win, topic, message, uuid, keepalive, callback) {
var error;
if (message instanceof Error) {
error = {
name: message.name,
message: message.message,
stack: message.stack
};
message = undefined;
}
var data = {
uuid: uuid,
topic: topic,
message: message,
error: error,
_respondable: true,
_source: _getSource(),
_keepalive: keepalive
};
if (typeof callback === 'function') {
messages[uuid] = callback;
}
win.postMessage(JSON.stringify(data), '*');
} | javascript | function post(win, topic, message, uuid, keepalive, callback) {
var error;
if (message instanceof Error) {
error = {
name: message.name,
message: message.message,
stack: message.stack
};
message = undefined;
}
var data = {
uuid: uuid,
topic: topic,
message: message,
error: error,
_respondable: true,
_source: _getSource(),
_keepalive: keepalive
};
if (typeof callback === 'function') {
messages[uuid] = callback;
}
win.postMessage(JSON.stringify(data), '*');
} | [
"function",
"post",
"(",
"win",
",",
"topic",
",",
"message",
",",
"uuid",
",",
"keepalive",
",",
"callback",
")",
"{",
"var",
"error",
";",
"if",
"(",
"message",
"instanceof",
"Error",
")",
"{",
"error",
"=",
"{",
"name",
":",
"message",
".",
"name"... | Posts the message to correct frame.
This abstraction necessary because IE9 & 10 do not support posting Objects; only strings
@private
@param {Window} win The `window` to post the message to
@param {String} topic The topic of the message
@param {Object} message The message content
@param {String} uuid The UUID, or pseudo-unique ID of the message
@param {Boolean} keepalive Whether to allow multiple responses - default is false
@param {Function} callback The function to invoke when/if the message is responded to | [
"Posts",
"the",
"message",
"to",
"correct",
"frame",
".",
"This",
"abstraction",
"necessary",
"because",
"IE9",
"&",
"10",
"do",
"not",
"support",
"posting",
"Objects",
";",
"only",
"strings"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/respondable.js#L68-L94 | train | post a message to the specified window | [
30522,
3853,
2695,
1006,
2663,
1010,
8476,
1010,
4471,
1010,
1057,
21272,
1010,
2562,
11475,
3726,
1010,
2655,
5963,
1007,
1063,
13075,
7561,
1025,
2065,
1006,
4471,
6013,
11253,
7561,
1007,
1063,
7561,
1027,
1063,
2171,
1024,
4471,
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... |
material-components/material-components-web | scripts/verify-pkg-main.js | verifyPath | function verifyPath(packageJson, jsonPath, packagePropertyKey) {
const isAtRoot = packagePropertyKey === 'module';
const packageJsonPropPath = path.join(path.dirname(jsonPath), packageJson[packagePropertyKey]);
let isInvalid = false;
if (!isAtRoot && packageJsonPropPath.indexOf('dist') === -1) {
isInvalid = true;
logError(`${jsonPath} ${packagePropertyKey} property does not reference a file under dist`);
} else if (isAtRoot && packageJsonPropPath.indexOf('dist') !== -1) {
isInvalid = true;
logError(`${jsonPath} ${packagePropertyKey} property should not reference a file under dist`);
}
if (!fs.existsSync(packageJsonPropPath)) {
isInvalid = true;
logError(`${jsonPath} ${packagePropertyKey} property points to nonexistent ${packageJsonPropPath}`);
}
if (isInvalid) {
// Multiple checks could have failed, but only increment the counter once for one package.
switch (packagePropertyKey) {
case 'main':
invalidMains++;
break;
case 'module':
invalidModules++;
break;
case 'types':
invalidTypes++;
break;
}
}
} | javascript | function verifyPath(packageJson, jsonPath, packagePropertyKey) {
const isAtRoot = packagePropertyKey === 'module';
const packageJsonPropPath = path.join(path.dirname(jsonPath), packageJson[packagePropertyKey]);
let isInvalid = false;
if (!isAtRoot && packageJsonPropPath.indexOf('dist') === -1) {
isInvalid = true;
logError(`${jsonPath} ${packagePropertyKey} property does not reference a file under dist`);
} else if (isAtRoot && packageJsonPropPath.indexOf('dist') !== -1) {
isInvalid = true;
logError(`${jsonPath} ${packagePropertyKey} property should not reference a file under dist`);
}
if (!fs.existsSync(packageJsonPropPath)) {
isInvalid = true;
logError(`${jsonPath} ${packagePropertyKey} property points to nonexistent ${packageJsonPropPath}`);
}
if (isInvalid) {
// Multiple checks could have failed, but only increment the counter once for one package.
switch (packagePropertyKey) {
case 'main':
invalidMains++;
break;
case 'module':
invalidModules++;
break;
case 'types':
invalidTypes++;
break;
}
}
} | [
"function",
"verifyPath",
"(",
"packageJson",
",",
"jsonPath",
",",
"packagePropertyKey",
")",
"{",
"const",
"isAtRoot",
"=",
"packagePropertyKey",
"===",
"'module'",
";",
"const",
"packageJsonPropPath",
"=",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"("... | Verifies that a file exists at the `packagePropertyKey`. If it does not
this function will log an error to the console.
@param {object} packageJson package.json in JSON format
@param {string} jsonPath filepath (relative to the root directory) to a component's package.json
@param {string} packagePropertyKey property key of package.json | [
"Verifies",
"that",
"a",
"file",
"exists",
"at",
"the",
"packagePropertyKey",
".",
"If",
"it",
"does",
"not",
"this",
"function",
"will",
"log",
"an",
"error",
"to",
"the",
"console",
"."
] | 9f8b9ae5103ff86de4f6a5cb02e700d6eb851e5f | https://github.com/material-components/material-components-web/blob/9f8b9ae5103ff86de4f6a5cb02e700d6eb851e5f/scripts/verify-pkg-main.js#L37-L68 | train | Verifies that the path is valid for a package. json file. | [
30522,
3853,
20410,
15069,
1006,
7427,
22578,
2239,
1010,
1046,
3385,
15069,
1010,
7427,
21572,
4842,
3723,
14839,
1007,
1063,
9530,
3367,
18061,
13181,
4140,
1027,
7427,
21572,
4842,
3723,
14839,
1027,
1027,
1027,
1005,
11336,
1005,
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... |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | shouldUpdateValue | function shouldUpdateValue (
elm,
vnode,
checkVal
) {
return (!elm.composing && (
vnode.tag === 'option' ||
isDirty(elm, checkVal) ||
isInputChanged(elm, checkVal)
))
} | javascript | function shouldUpdateValue (
elm,
vnode,
checkVal
) {
return (!elm.composing && (
vnode.tag === 'option' ||
isDirty(elm, checkVal) ||
isInputChanged(elm, checkVal)
))
} | [
"function",
"shouldUpdateValue",
"(",
"elm",
",",
"vnode",
",",
"checkVal",
")",
"{",
"return",
"(",
"!",
"elm",
".",
"composing",
"&&",
"(",
"vnode",
".",
"tag",
"===",
"'option'",
"||",
"isDirty",
"(",
"elm",
",",
"checkVal",
")",
"||",
"isInputChanged... | check platforms/web/util/attrs.js acceptValue | [
"check",
"platforms",
"/",
"web",
"/",
"util",
"/",
"attrs",
".",
"js",
"acceptValue"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L5304-L5314 | train | Check if the value is changed in the node | [
30522,
3853,
2323,
6279,
13701,
10175,
5657,
1006,
17709,
1010,
1058,
3630,
3207,
1010,
4638,
10175,
1007,
1063,
2709,
1006,
999,
17709,
1012,
16572,
1004,
1004,
1006,
1058,
3630,
3207,
1012,
6415,
1027,
1027,
1027,
1005,
5724,
1005,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/models/base/index.js | add | function add(data, unfilteredOptions) {
var options = this.filterOptions(unfilteredOptions, 'add'),
model;
data = this.filterData(data);
model = this.forge(data);
// We allow you to disable timestamps when importing posts so that the new posts `updated_at` value is the same
// as the import json blob. More details refer to https://github.com/TryGhost/Ghost/issues/1696
if (options.importing) {
model.hasTimestamps = false;
}
// Bookshelf determines whether an operation is an update or an insert based on the id
// Ghost auto-generates Object id's, so we need to tell Bookshelf here that we are inserting data
options.method = 'insert';
return model.save(null, options);
} | javascript | function add(data, unfilteredOptions) {
var options = this.filterOptions(unfilteredOptions, 'add'),
model;
data = this.filterData(data);
model = this.forge(data);
// We allow you to disable timestamps when importing posts so that the new posts `updated_at` value is the same
// as the import json blob. More details refer to https://github.com/TryGhost/Ghost/issues/1696
if (options.importing) {
model.hasTimestamps = false;
}
// Bookshelf determines whether an operation is an update or an insert based on the id
// Ghost auto-generates Object id's, so we need to tell Bookshelf here that we are inserting data
options.method = 'insert';
return model.save(null, options);
} | [
"function",
"add",
"(",
"data",
",",
"unfilteredOptions",
")",
"{",
"var",
"options",
"=",
"this",
".",
"filterOptions",
"(",
"unfilteredOptions",
",",
"'add'",
")",
",",
"model",
";",
"data",
"=",
"this",
".",
"filterData",
"(",
"data",
")",
";",
"model... | ### Add
Naive add
@param {Object} data
@param {Object} unfilteredOptions (optional)
@return {Promise(ghostBookshelf.Model)} Newly Added Model | [
"###",
"Add",
"Naive",
"add"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L989-L1006 | train | Add a new post to the database | [
30522,
3853,
5587,
1006,
2951,
1010,
4895,
8873,
21928,
26010,
16790,
2015,
1007,
1063,
13075,
7047,
1027,
2023,
1012,
11307,
7361,
9285,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1010,
1005,
5587,
1005,
1007,
1010,
2944,
1025,
2951,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/cache/LRUPersistentCache.js | cleanAndStore | function cleanAndStore(self, key, value) {
return new Promise(function (resolve, reject) {
var attempt = 0;
_cleanAndStore(self, key, value);
function _cleanAndStore(self, key, value) {
attempt++;
Log.debug("Cache Manager LRUPersistentCache: cleanAndStore: freeing space attempt [" + (attempt) + "]");
deleteItemAndUpdateMetadata(self).then(function (deletedKey) {
Log.debug("Cache Manager LRUPersistentCache: cleanAndStore: deleted item with key [" + deletedKey + "]. Going to put " + key);
return internalSet(self, key, value).then(resolve, function (event) {
if (isQuotaExceeded(event)) {
Log.debug("Cache Manager LRUPersistentCache: cleanAndStore: QuotaExceedError during freeing up space...");
if (getItemCount(self) > 0) {
_cleanAndStore(self, key, value);
} else {
reject("Cache Manager LRUPersistentCache: cleanAndStore: even when the cache is empty, the new item with key [" + key + "] cannot be added");
}
} else {
reject("Cache Manager LRUPersistentCache: cleanAndStore: cannot free space: " + collectErrorData(event));
}
});
}, reject);
}
});
} | javascript | function cleanAndStore(self, key, value) {
return new Promise(function (resolve, reject) {
var attempt = 0;
_cleanAndStore(self, key, value);
function _cleanAndStore(self, key, value) {
attempt++;
Log.debug("Cache Manager LRUPersistentCache: cleanAndStore: freeing space attempt [" + (attempt) + "]");
deleteItemAndUpdateMetadata(self).then(function (deletedKey) {
Log.debug("Cache Manager LRUPersistentCache: cleanAndStore: deleted item with key [" + deletedKey + "]. Going to put " + key);
return internalSet(self, key, value).then(resolve, function (event) {
if (isQuotaExceeded(event)) {
Log.debug("Cache Manager LRUPersistentCache: cleanAndStore: QuotaExceedError during freeing up space...");
if (getItemCount(self) > 0) {
_cleanAndStore(self, key, value);
} else {
reject("Cache Manager LRUPersistentCache: cleanAndStore: even when the cache is empty, the new item with key [" + key + "] cannot be added");
}
} else {
reject("Cache Manager LRUPersistentCache: cleanAndStore: cannot free space: " + collectErrorData(event));
}
});
}, reject);
}
});
} | [
"function",
"cleanAndStore",
"(",
"self",
",",
"key",
",",
"value",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"attempt",
"=",
"0",
";",
"_cleanAndStore",
"(",
"self",
",",
"key",
",",
"value"... | Tries to free space until the given new item is successfully added.
@param {sap.ui.core.cache.LRUPersistentCache} self the instance of the Cache Manager
@param {ItemData} oItem the item to free space for
@returns {Promise} a promise that will resolve if the given item is added, or reject - if not. | [
"Tries",
"to",
"free",
"space",
"until",
"the",
"given",
"new",
"item",
"is",
"successfully",
"added",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/cache/LRUPersistentCache.js#L782-L809 | train | This function is used to clean and store an item in the cache. | [
30522,
3853,
4550,
29560,
19277,
1006,
2969,
1010,
3145,
1010,
3643,
1007,
1063,
2709,
2047,
4872,
1006,
3853,
1006,
10663,
1010,
15454,
1007,
1063,
13075,
3535,
1027,
1014,
1025,
1035,
4550,
29560,
19277,
1006,
2969,
1010,
3145,
1010,
3643... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
socketio/socket.io | lib/client.js | writeToEngine | function writeToEngine(encodedPackets) {
if (opts.volatile && !self.conn.transport.writable) return;
for (var i = 0; i < encodedPackets.length; i++) {
self.conn.write(encodedPackets[i], { compress: opts.compress });
}
} | javascript | function writeToEngine(encodedPackets) {
if (opts.volatile && !self.conn.transport.writable) return;
for (var i = 0; i < encodedPackets.length; i++) {
self.conn.write(encodedPackets[i], { compress: opts.compress });
}
} | [
"function",
"writeToEngine",
"(",
"encodedPackets",
")",
"{",
"if",
"(",
"opts",
".",
"volatile",
"&&",
"!",
"self",
".",
"conn",
".",
"transport",
".",
"writable",
")",
"return",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"encodedPackets",
... | this writes to the actual connection | [
"this",
"writes",
"to",
"the",
"actual",
"connection"
] | 9c1e73c752aec63f48b511330a506d037783d897 | https://github.com/socketio/socket.io/blob/9c1e73c752aec63f48b511330a506d037783d897/lib/client.js#L167-L172 | train | write to engine | [
30522,
3853,
4339,
3406,
13159,
3170,
1006,
12359,
23947,
8454,
1007,
1063,
2065,
1006,
23569,
2015,
1012,
20606,
1004,
1004,
999,
2969,
1012,
9530,
2078,
1012,
3665,
1012,
25697,
3085,
1007,
2709,
1025,
2005,
1006,
13075,
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... |
apache/incubator-echarts | src/chart/tree/TreeView.js | function (ecModel, api) {
/**
* @private
* @type {module:echarts/data/Tree}
*/
this._oldTree;
/**
* @private
* @type {module:zrender/container/Group}
*/
this._mainGroup = new graphic.Group();
/**
* @private
* @type {module:echarts/componet/helper/RoamController}
*/
this._controller = new RoamController(api.getZr());
this._controllerHost = {target: this.group};
this.group.add(this._mainGroup);
} | javascript | function (ecModel, api) {
/**
* @private
* @type {module:echarts/data/Tree}
*/
this._oldTree;
/**
* @private
* @type {module:zrender/container/Group}
*/
this._mainGroup = new graphic.Group();
/**
* @private
* @type {module:echarts/componet/helper/RoamController}
*/
this._controller = new RoamController(api.getZr());
this._controllerHost = {target: this.group};
this.group.add(this._mainGroup);
} | [
"function",
"(",
"ecModel",
",",
"api",
")",
"{",
"/**\n * @private\n * @type {module:echarts/data/Tree}\n */",
"this",
".",
"_oldTree",
";",
"/**\n * @private\n * @type {module:zrender/container/Group}\n */",
"this",
".",
"_mainGroup",
... | Init the chart
@override
@param {module:echarts/model/Global} ecModel
@param {module:echarts/ExtensionAPI} api | [
"Init",
"the",
"chart"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/tree/TreeView.js#L46-L69 | train | A node that contains a node in the tree | [
30522,
3853,
1006,
14925,
5302,
9247,
1010,
17928,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2797,
1008,
1030,
2828,
1063,
11336,
1024,
14925,
10686,
2015,
1013,
2951,
1013,
3392,
1065,
1008,
1013,
2023,
1012,
1035,
2214,
13334,
1025,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/HealthData/HealthDataManager.js | getHealthData | function getHealthData() {
var result = new $.Deferred(),
oneTimeHealthData = {};
oneTimeHealthData.snapshotTime = Date.now();
oneTimeHealthData.os = brackets.platform;
oneTimeHealthData.userAgent = window.navigator.userAgent;
oneTimeHealthData.osLanguage = brackets.app.language;
oneTimeHealthData.bracketsLanguage = brackets.getLocale();
oneTimeHealthData.bracketsVersion = brackets.metadata.version;
$.extend(oneTimeHealthData, HealthLogger.getAggregatedHealthData());
HealthDataUtils.getUserInstalledExtensions()
.done(function (userInstalledExtensions) {
oneTimeHealthData.installedExtensions = userInstalledExtensions;
})
.always(function () {
HealthDataUtils.getUserInstalledTheme()
.done(function (bracketsTheme) {
oneTimeHealthData.bracketsTheme = bracketsTheme;
})
.always(function () {
var userUuid = PreferencesManager.getViewState("UUID");
var olderUuid = PreferencesManager.getViewState("OlderUUID");
if (userUuid && olderUuid) {
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
} else {
// So we are going to get the Machine hash in either of the cases.
if (appshell.app.getMachineHash) {
appshell.app.getMachineHash(function (err, macHash) {
var generatedUuid;
if (err) {
generatedUuid = uuid.v4();
} else {
generatedUuid = macHash;
}
if (!userUuid) {
// Could be a new user. In this case
// both will remain the same.
userUuid = olderUuid = generatedUuid;
} else {
// For existing user, we will still cache
// the older uuid, so that we can improve
// our reporting in terms of figuring out
// the new users accurately.
olderUuid = userUuid;
userUuid = generatedUuid;
}
PreferencesManager.setViewState("UUID", userUuid);
PreferencesManager.setViewState("OlderUUID", olderUuid);
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
});
} else {
// Probably running on older shell, in which case we will
// assign the same uuid to olderuuid.
if (!userUuid) {
oneTimeHealthData.uuid = oneTimeHealthData.olderuuid = uuid.v4();
} else {
oneTimeHealthData.olderuuid = userUuid;
}
PreferencesManager.setViewState("UUID", oneTimeHealthData.uuid);
PreferencesManager.setViewState("OlderUUID", oneTimeHealthData.olderuuid);
return result.resolve(oneTimeHealthData);
}
}
});
});
return result.promise();
} | javascript | function getHealthData() {
var result = new $.Deferred(),
oneTimeHealthData = {};
oneTimeHealthData.snapshotTime = Date.now();
oneTimeHealthData.os = brackets.platform;
oneTimeHealthData.userAgent = window.navigator.userAgent;
oneTimeHealthData.osLanguage = brackets.app.language;
oneTimeHealthData.bracketsLanguage = brackets.getLocale();
oneTimeHealthData.bracketsVersion = brackets.metadata.version;
$.extend(oneTimeHealthData, HealthLogger.getAggregatedHealthData());
HealthDataUtils.getUserInstalledExtensions()
.done(function (userInstalledExtensions) {
oneTimeHealthData.installedExtensions = userInstalledExtensions;
})
.always(function () {
HealthDataUtils.getUserInstalledTheme()
.done(function (bracketsTheme) {
oneTimeHealthData.bracketsTheme = bracketsTheme;
})
.always(function () {
var userUuid = PreferencesManager.getViewState("UUID");
var olderUuid = PreferencesManager.getViewState("OlderUUID");
if (userUuid && olderUuid) {
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
} else {
// So we are going to get the Machine hash in either of the cases.
if (appshell.app.getMachineHash) {
appshell.app.getMachineHash(function (err, macHash) {
var generatedUuid;
if (err) {
generatedUuid = uuid.v4();
} else {
generatedUuid = macHash;
}
if (!userUuid) {
// Could be a new user. In this case
// both will remain the same.
userUuid = olderUuid = generatedUuid;
} else {
// For existing user, we will still cache
// the older uuid, so that we can improve
// our reporting in terms of figuring out
// the new users accurately.
olderUuid = userUuid;
userUuid = generatedUuid;
}
PreferencesManager.setViewState("UUID", userUuid);
PreferencesManager.setViewState("OlderUUID", olderUuid);
oneTimeHealthData.uuid = userUuid;
oneTimeHealthData.olderuuid = olderUuid;
return result.resolve(oneTimeHealthData);
});
} else {
// Probably running on older shell, in which case we will
// assign the same uuid to olderuuid.
if (!userUuid) {
oneTimeHealthData.uuid = oneTimeHealthData.olderuuid = uuid.v4();
} else {
oneTimeHealthData.olderuuid = userUuid;
}
PreferencesManager.setViewState("UUID", oneTimeHealthData.uuid);
PreferencesManager.setViewState("OlderUUID", oneTimeHealthData.olderuuid);
return result.resolve(oneTimeHealthData);
}
}
});
});
return result.promise();
} | [
"function",
"getHealthData",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"oneTimeHealthData",
"=",
"{",
"}",
";",
"oneTimeHealthData",
".",
"snapshotTime",
"=",
"Date",
".",
"now",
"(",
")",
";",
"oneTimeHealthData",
... | Get the Health Data which will be sent to the server. Initially it is only one time data. | [
"Get",
"the",
"Health",
"Data",
"which",
"will",
"be",
"sent",
"to",
"the",
"server",
".",
"Initially",
"it",
"is",
"only",
"one",
"time",
"data",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataManager.js#L51-L130 | train | Get the health data from the appshell | [
30522,
3853,
2131,
20192,
24658,
2850,
2696,
1006,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
2028,
7292,
20192,
24658,
2850,
2696,
1027,
1063,
1065,
1025,
2028,
7292,
20192,
24658,
2850,
2696,
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... |
serverless/serverless | lib/utils/userStats.js | request | function request(url, payload) {
return fetch(url, {
method: 'POST',
// set to 1000 b/c no response needed
timeout: 1000,
body: JSON.stringify(payload),
})
.then((response) => {
if (response.status === 404) {
return BbPromise.reject('404 api not found');
}
return response.json();
})
.then((res) => BbPromise.resolve(res))
.catch((e) => BbPromise.resolve(e));
} | javascript | function request(url, payload) {
return fetch(url, {
method: 'POST',
// set to 1000 b/c no response needed
timeout: 1000,
body: JSON.stringify(payload),
})
.then((response) => {
if (response.status === 404) {
return BbPromise.reject('404 api not found');
}
return response.json();
})
.then((res) => BbPromise.resolve(res))
.catch((e) => BbPromise.resolve(e));
} | [
"function",
"request",
"(",
"url",
",",
"payload",
")",
"{",
"return",
"fetch",
"(",
"url",
",",
"{",
"method",
":",
"'POST'",
",",
"// set to 1000 b/c no response needed",
"timeout",
":",
"1000",
",",
"body",
":",
"JSON",
".",
"stringify",
"(",
"payload",
... | /* note tracking swallows errors | [
"/",
"*",
"note",
"tracking",
"swallows",
"errors"
] | 0626d5b5df06e4ed68969e324f1cb6b1b499c443 | https://github.com/serverless/serverless/blob/0626d5b5df06e4ed68969e324f1cb6b1b499c443/lib/utils/userStats.js#L21-L36 | train | Request an image | [
30522,
3853,
5227,
1006,
24471,
2140,
1010,
18093,
1007,
1063,
2709,
18584,
1006,
24471,
2140,
1010,
1063,
4118,
1024,
1005,
2695,
1005,
1010,
1013,
1013,
2275,
2000,
6694,
1038,
1013,
1039,
2053,
3433,
2734,
2051,
5833,
1024,
6694,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | _disableCache | function _disableCache() {
var result = new $.Deferred();
if (brackets.inBrowser) {
result.resolve();
} else {
var port = brackets.app.getRemoteDebuggingPort ? brackets.app.getRemoteDebuggingPort() : 9234;
Inspector.getDebuggableWindows("127.0.0.1", port)
.fail(result.reject)
.done(function (response) {
var page = response[0];
if (!page || !page.webSocketDebuggerUrl) {
result.reject();
return;
}
var _socket = new WebSocket(page.webSocketDebuggerUrl);
// Disable the cache
_socket.onopen = function _onConnect() {
_socket.send(JSON.stringify({ id: 1, method: "Network.setCacheDisabled", params: { "cacheDisabled": true } }));
};
// The first message will be the confirmation => disconnected to allow remote debugging of Brackets
_socket.onmessage = function _onMessage(e) {
_socket.close();
result.resolve();
};
// In case of an error
_socket.onerror = result.reject;
});
}
return result.promise();
} | javascript | function _disableCache() {
var result = new $.Deferred();
if (brackets.inBrowser) {
result.resolve();
} else {
var port = brackets.app.getRemoteDebuggingPort ? brackets.app.getRemoteDebuggingPort() : 9234;
Inspector.getDebuggableWindows("127.0.0.1", port)
.fail(result.reject)
.done(function (response) {
var page = response[0];
if (!page || !page.webSocketDebuggerUrl) {
result.reject();
return;
}
var _socket = new WebSocket(page.webSocketDebuggerUrl);
// Disable the cache
_socket.onopen = function _onConnect() {
_socket.send(JSON.stringify({ id: 1, method: "Network.setCacheDisabled", params: { "cacheDisabled": true } }));
};
// The first message will be the confirmation => disconnected to allow remote debugging of Brackets
_socket.onmessage = function _onMessage(e) {
_socket.close();
result.resolve();
};
// In case of an error
_socket.onerror = result.reject;
});
}
return result.promise();
} | [
"function",
"_disableCache",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"brackets",
".",
"inBrowser",
")",
"{",
"result",
".",
"resolve",
"(",
")",
";",
"}",
"else",
"{",
"var",
"port",
"=",
"bracket... | Disables Brackets' cache via the remote debugging protocol.
@return {$.Promise} A jQuery promise that will be resolved when the cache is disabled and be rejected in any other case | [
"Disables",
"Brackets",
"cache",
"via",
"the",
"remote",
"debugging",
"protocol",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L1639-L1670 | train | Disable the cache | [
30522,
3853,
1035,
4487,
19150,
3540,
5403,
1006,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
2065,
1006,
19719,
1012,
1999,
12618,
9333,
2121,
1007,
1063,
2765,
1012,
10663,
1006,
1007,
1025,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/node/selenium-webdriver/lib/capabilities.js | toMap | function toMap(hash) {
let m = new Map;
for (let key in hash) {
if (hash.hasOwnProperty(key)) {
m.set(key, hash[key]);
}
}
return m;
} | javascript | function toMap(hash) {
let m = new Map;
for (let key in hash) {
if (hash.hasOwnProperty(key)) {
m.set(key, hash[key]);
}
}
return m;
} | [
"function",
"toMap",
"(",
"hash",
")",
"{",
"let",
"m",
"=",
"new",
"Map",
";",
"for",
"(",
"let",
"key",
"in",
"hash",
")",
"{",
"if",
"(",
"hash",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"m",
".",
"set",
"(",
"key",
",",
"hash",
"... | Converts a generic hash object to a map.
@param {!Object<string, ?>} hash The hash object.
@return {!Map<string, ?>} The converted map. | [
"Converts",
"a",
"generic",
"hash",
"object",
"to",
"a",
"map",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/lib/capabilities.js#L223-L231 | train | Convert a hash to a Map | [
30522,
3853,
3419,
9331,
1006,
23325,
1007,
1063,
2292,
1049,
1027,
2047,
4949,
1025,
2005,
1006,
2292,
3145,
1999,
23325,
1007,
1063,
2065,
1006,
23325,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
3145,
1007,
1007,
1063,
1049,
1012,
2275,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/arrow-spacing.js | getTokens | function getTokens(node) {
const arrow = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
return {
before: sourceCode.getTokenBefore(arrow),
arrow,
after: sourceCode.getTokenAfter(arrow)
};
} | javascript | function getTokens(node) {
const arrow = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken);
return {
before: sourceCode.getTokenBefore(arrow),
arrow,
after: sourceCode.getTokenAfter(arrow)
};
} | [
"function",
"getTokens",
"(",
"node",
")",
"{",
"const",
"arrow",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"node",
".",
"body",
",",
"astUtils",
".",
"isArrowToken",
")",
";",
"return",
"{",
"before",
":",
"sourceCode",
".",
"getTokenBefore",
"(",
"a... | Get tokens of arrow(`=>`) and before/after arrow.
@param {ASTNode} node The arrow function node.
@returns {Object} Tokens of arrow and before/after arrow. | [
"Get",
"tokens",
"of",
"arrow",
"(",
"=",
">",
")",
"and",
"before",
"/",
"after",
"arrow",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/arrow-spacing.js#L71-L79 | train | Get tokens from node | [
30522,
3853,
2131,
18715,
6132,
1006,
13045,
1007,
1063,
9530,
3367,
8612,
1027,
3120,
16044,
1012,
2131,
18715,
2368,
4783,
29278,
2063,
1006,
13045,
1012,
2303,
1010,
2004,
8525,
3775,
4877,
1012,
18061,
28597,
18715,
2368,
1007,
1025,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/qunit.js | function( obj, objType, stack ) {
stack = stack || [];
var res, parser, parserType,
inStack = inArray( obj, stack );
if ( inStack !== -1 ) {
return "recursion(" + ( inStack - stack.length ) + ")";
}
objType = objType || this.typeOf( obj );
parser = this.parsers[ objType ];
parserType = typeof parser;
if ( parserType === "function" ) {
stack.push( obj );
res = parser.call( this, obj, stack );
stack.pop();
return res;
}
return ( parserType === "string" ) ? parser : this.parsers.error;
} | javascript | function( obj, objType, stack ) {
stack = stack || [];
var res, parser, parserType,
inStack = inArray( obj, stack );
if ( inStack !== -1 ) {
return "recursion(" + ( inStack - stack.length ) + ")";
}
objType = objType || this.typeOf( obj );
parser = this.parsers[ objType ];
parserType = typeof parser;
if ( parserType === "function" ) {
stack.push( obj );
res = parser.call( this, obj, stack );
stack.pop();
return res;
}
return ( parserType === "string" ) ? parser : this.parsers.error;
} | [
"function",
"(",
"obj",
",",
"objType",
",",
"stack",
")",
"{",
"stack",
"=",
"stack",
"||",
"[",
"]",
";",
"var",
"res",
",",
"parser",
",",
"parserType",
",",
"inStack",
"=",
"inArray",
"(",
"obj",
",",
"stack",
")",
";",
"if",
"(",
"inStack",
... | objType is used mostly internally, you can fix a (custom) type in advance | [
"objType",
"is",
"used",
"mostly",
"internally",
"you",
"can",
"fix",
"a",
"(",
"custom",
")",
"type",
"in",
"advance"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/qunit.js#L1683-L1703 | train | Returns a string that can be used to describe the object | [
30522,
3853,
1006,
27885,
3501,
1010,
27885,
3501,
13874,
1010,
9991,
1007,
1063,
9991,
1027,
9991,
1064,
1064,
1031,
1033,
1025,
13075,
24501,
1010,
11968,
8043,
1010,
11968,
8043,
13874,
1010,
16021,
2696,
3600,
1027,
27118,
11335,
2100,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aws/aws-sdk-js | lib/config.js | update | function update(options, allowUnknownKeys) {
allowUnknownKeys = allowUnknownKeys || false;
options = this.extractCredentials(options);
AWS.util.each.call(this, options, function (key, value) {
if (allowUnknownKeys || Object.prototype.hasOwnProperty.call(this.keys, key) ||
AWS.Service.hasService(key)) {
this.set(key, value);
}
});
} | javascript | function update(options, allowUnknownKeys) {
allowUnknownKeys = allowUnknownKeys || false;
options = this.extractCredentials(options);
AWS.util.each.call(this, options, function (key, value) {
if (allowUnknownKeys || Object.prototype.hasOwnProperty.call(this.keys, key) ||
AWS.Service.hasService(key)) {
this.set(key, value);
}
});
} | [
"function",
"update",
"(",
"options",
",",
"allowUnknownKeys",
")",
"{",
"allowUnknownKeys",
"=",
"allowUnknownKeys",
"||",
"false",
";",
"options",
"=",
"this",
".",
"extractCredentials",
"(",
"options",
")",
";",
"AWS",
".",
"util",
".",
"each",
".",
"call... | @!group Loading and Setting Configuration Options
@overload update(options, allowUnknownKeys = false)
Updates the current configuration object with new options.
@example Update maxRetries property of a configuration object
config.update({maxRetries: 10});
@param [Object] options a map of option keys and values.
@param [Boolean] allowUnknownKeys whether unknown keys can be set on
the configuration object. Defaults to `false`.
@see constructor | [
"@!group",
"Loading",
"and",
"Setting",
"Configuration",
"Options",
"@overload",
"update",
"(",
"options",
"allowUnknownKeys",
"=",
"false",
")",
"Updates",
"the",
"current",
"configuration",
"object",
"with",
"new",
"options",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/config.js#L414-L423 | train | Updates the configuration of the resource | [
30522,
3853,
10651,
1006,
7047,
1010,
3499,
16814,
19779,
8950,
3240,
2015,
1007,
1063,
3499,
16814,
19779,
8950,
3240,
2015,
1027,
3499,
16814,
19779,
8950,
3240,
2015,
1064,
1064,
6270,
1025,
7047,
1027,
2023,
1012,
14817,
16748,
16454,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/report/ReportProvider.js | openReport | function openReport(oData) {
// Create a hidden anchor. Open window outside of the promise otherwise browsers blocks the window.open.
var content = '';
var a = jQuery('<a style="display: none;"/>');
a.on('click', function () {
var reportWindow = window.open('', '_blank');
jQuery(reportWindow.document).ready(function () {
// Sometimes document.write overwrites the document html and sometimes it appends to it so we need a wrapper div.
if (reportWindow.document.getElementById('sap-report-content')) {
reportWindow.document.getElementById('sap-report-content').innerHtml = content;
} else {
reportWindow.document.write('<div id="sap-report-content">' + content + '</div>');
}
reportWindow.document.title = 'Report';
});
});
jQuery('body').append(a);
this.getReportHtml(oData).then(function (html) {
content = html;
a[0].click();
a.remove();
});
} | javascript | function openReport(oData) {
// Create a hidden anchor. Open window outside of the promise otherwise browsers blocks the window.open.
var content = '';
var a = jQuery('<a style="display: none;"/>');
a.on('click', function () {
var reportWindow = window.open('', '_blank');
jQuery(reportWindow.document).ready(function () {
// Sometimes document.write overwrites the document html and sometimes it appends to it so we need a wrapper div.
if (reportWindow.document.getElementById('sap-report-content')) {
reportWindow.document.getElementById('sap-report-content').innerHtml = content;
} else {
reportWindow.document.write('<div id="sap-report-content">' + content + '</div>');
}
reportWindow.document.title = 'Report';
});
});
jQuery('body').append(a);
this.getReportHtml(oData).then(function (html) {
content = html;
a[0].click();
a.remove();
});
} | [
"function",
"openReport",
"(",
"oData",
")",
"{",
"// Create a hidden anchor. Open window outside of the promise otherwise browsers blocks the window.open.",
"var",
"content",
"=",
"''",
";",
"var",
"a",
"=",
"jQuery",
"(",
"'<a style=\"display: none;\"/>'",
")",
";",
"a",
... | Opens a report in a new window.
@param {Object} oData - the data required to create a report | [
"Opens",
"a",
"report",
"in",
"a",
"new",
"window",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/report/ReportProvider.js#L421-L444 | train | Opens the report window | [
30522,
3853,
2330,
2890,
6442,
1006,
1051,
2850,
2696,
1007,
1063,
1013,
1013,
3443,
1037,
5023,
8133,
1012,
2330,
3332,
2648,
1997,
1996,
4872,
4728,
16602,
2015,
5991,
1996,
3332,
1012,
2330,
1012,
13075,
4180,
1027,
1005,
1005,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/events/jquery/EventTriggerHook.js | suppressTriggeredEvent | function suppressTriggeredEvent(sEventType, oDomRef, aExcludedDomRefs) {
var mEventInfo = mTriggerEventInfo[sEventType];
var sId = uid();
if (!mEventInfo) {
mEventInfo = mTriggerEventInfo[sEventType] = {
domRefs: {},
originalTriggerHook: _applyTriggerHook(sEventType)
};
}
mEventInfo.domRefs[sId] = {
domRef: oDomRef,
excludedDomRefs: [].concat(aExcludedDomRefs)
};
return {
id: sId,
type: sEventType
};
} | javascript | function suppressTriggeredEvent(sEventType, oDomRef, aExcludedDomRefs) {
var mEventInfo = mTriggerEventInfo[sEventType];
var sId = uid();
if (!mEventInfo) {
mEventInfo = mTriggerEventInfo[sEventType] = {
domRefs: {},
originalTriggerHook: _applyTriggerHook(sEventType)
};
}
mEventInfo.domRefs[sId] = {
domRef: oDomRef,
excludedDomRefs: [].concat(aExcludedDomRefs)
};
return {
id: sId,
type: sEventType
};
} | [
"function",
"suppressTriggeredEvent",
"(",
"sEventType",
",",
"oDomRef",
",",
"aExcludedDomRefs",
")",
"{",
"var",
"mEventInfo",
"=",
"mTriggerEventInfo",
"[",
"sEventType",
"]",
";",
"var",
"sId",
"=",
"uid",
"(",
")",
";",
"if",
"(",
"!",
"mEventInfo",
")"... | Suppress jQuery.trigger events for a given DOM element
mTriggerEventInfo example:
mTriggerEventInfo: {
'EventType': {
domRefs: {
'DomRefId': {
domRef: 'DomRef',
excludedDomRefs: aDomRefs
}
},
hookApplied: 'boolean'
originalTriggerHook: 'fnHook'
}
}
@param {string} sEventType Event type to suppress jQuery.trigger for
@param {Element} oDomRef DOM element to suppress events from jQuery.trigger
@param {Element|Array} [aExcludedDomRefs] DomRefs excluded from suppress events from jQuery.trigger
@returns {Object} oHandler The suppression handler. Needed for releasing the suppression
@private | [
"Suppress",
"jQuery",
".",
"trigger",
"events",
"for",
"a",
"given",
"DOM",
"element"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/jquery/EventTriggerHook.js#L88-L108 | train | Suppresses a trigger event by adding a domRef to the domRefs map. | [
30522,
3853,
16081,
18886,
13327,
14728,
15338,
1006,
2698,
15353,
5051,
1010,
1051,
9527,
2890,
2546,
1010,
29347,
2595,
20464,
13936,
9527,
2890,
10343,
1007,
1063,
13075,
2033,
15338,
2378,
14876,
1027,
11047,
3089,
13327,
18697,
16778,
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... |
dequelabs/axe-core | lib/core/utils/qsa.js | matchesTag | function matchesTag(node, exp) {
return (
node.nodeType === 1 &&
(exp.tag === '*' || node.nodeName.toLowerCase() === exp.tag)
);
} | javascript | function matchesTag(node, exp) {
return (
node.nodeType === 1 &&
(exp.tag === '*' || node.nodeName.toLowerCase() === exp.tag)
);
} | [
"function",
"matchesTag",
"(",
"node",
",",
"exp",
")",
"{",
"return",
"(",
"node",
".",
"nodeType",
"===",
"1",
"&&",
"(",
"exp",
".",
"tag",
"===",
"'*'",
"||",
"node",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
"===",
"exp",
".",
"tag",
")",... | todo: implement an option to follow aria-owns | [
"todo",
":",
"implement",
"an",
"option",
"to",
"follow",
"aria",
"-",
"owns"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/qsa.js#L7-L12 | train | Returns true if node matches the tag | [
30522,
3853,
3503,
15900,
1006,
13045,
1010,
4654,
2361,
1007,
1063,
2709,
1006,
13045,
1012,
13045,
13874,
1027,
1027,
1027,
1015,
1004,
1004,
1006,
4654,
2361,
1012,
6415,
1027,
1027,
1027,
1005,
1008,
1005,
1064,
1064,
13045,
1012,
13045... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FindInFilesUI.js | searchAndReplaceResults | function searchAndReplaceResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: replace all
if (FindInFiles.searchModel.hasResults()) {
_finishReplaceBatch(FindInFiles.searchModel);
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("replace all failed: ", err);
StatusBar.hideBusyIndicator();
});
} | javascript | function searchAndReplaceResults(queryInfo, scope, filter, replaceText, candidateFilesPromise) {
return FindInFiles.doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise)
.done(function (zeroFilesToken) {
// Done searching all files: replace all
if (FindInFiles.searchModel.hasResults()) {
_finishReplaceBatch(FindInFiles.searchModel);
if (_findBar) {
_findBar.enable(true);
_findBar.focus();
}
}
StatusBar.hideBusyIndicator();
})
.fail(function (err) {
console.log("replace all failed: ", err);
StatusBar.hideBusyIndicator();
});
} | [
"function",
"searchAndReplaceResults",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",",
"candidateFilesPromise",
")",
"{",
"return",
"FindInFiles",
".",
"doSearchInScope",
"(",
"queryInfo",
",",
"scope",
",",
"filter",
",",
"replaceText",
",... | Does a search in the given scope with the given filter. Replace the result list once the search is complete.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo Query info object
@param {?Entry} scope Project file/subfolder to search within; else searches whole project.
@param {?string} filter A "compiled" filter as returned by FileFilters.compile(), or null for no filter
@param {?string} replaceText If this is a replacement, the text to replace matches with.
@param {?$.Promise} candidateFilesPromise If specified, a promise that should resolve with the same set of files that
getCandidateFiles(scope) would return.
@return {$.Promise} A promise that's resolved with the search results or rejected when the find competes. | [
"Does",
"a",
"search",
"in",
"the",
"given",
"scope",
"with",
"the",
"given",
"filter",
".",
"Replace",
"the",
"result",
"list",
"once",
"the",
"search",
"is",
"complete",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindInFilesUI.js#L127-L146 | train | Search and replace all results | [
30522,
3853,
3945,
5685,
2890,
24759,
10732,
6072,
11314,
2015,
1006,
23032,
2378,
14876,
30524,
1007,
1063,
2709,
2424,
2378,
8873,
4244,
1012,
13004,
2906,
17231,
26127,
1006,
23032,
2378,
14876,
1010,
9531,
1010,
11307,
1010,
5672,
18209,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/padding-line-between-statements.js | getActualLastToken | function getActualLastToken(sourceCode, node) {
const semiToken = sourceCode.getLastToken(node);
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const isSemicolonLessStyle = Boolean(
prevToken &&
nextToken &&
prevToken.range[0] >= node.range[0] &&
astUtils.isSemicolonToken(semiToken) &&
semiToken.loc.start.line !== prevToken.loc.end.line &&
semiToken.loc.end.line === nextToken.loc.start.line
);
return isSemicolonLessStyle ? prevToken : semiToken;
} | javascript | function getActualLastToken(sourceCode, node) {
const semiToken = sourceCode.getLastToken(node);
const prevToken = sourceCode.getTokenBefore(semiToken);
const nextToken = sourceCode.getTokenAfter(semiToken);
const isSemicolonLessStyle = Boolean(
prevToken &&
nextToken &&
prevToken.range[0] >= node.range[0] &&
astUtils.isSemicolonToken(semiToken) &&
semiToken.loc.start.line !== prevToken.loc.end.line &&
semiToken.loc.end.line === nextToken.loc.start.line
);
return isSemicolonLessStyle ? prevToken : semiToken;
} | [
"function",
"getActualLastToken",
"(",
"sourceCode",
",",
"node",
")",
"{",
"const",
"semiToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
";",
"const",
"prevToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"semiToken",
")",
";",
"const"... | Gets the actual last token.
If a semicolon is semicolon-less style's semicolon, this ignores it.
For example:
foo()
;[1, 2, 3].forEach(bar)
@param {SourceCode} sourceCode The source code to get tokens.
@param {ASTNode} node The node to get.
@returns {Token} The actual last token.
@private | [
"Gets",
"the",
"actual",
"last",
"token",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L196-L210 | train | Gets the actual last token of a given node. | [
30522,
3853,
2131,
18908,
8787,
8523,
9284,
7520,
1006,
3120,
16044,
1010,
13045,
1007,
1063,
9530,
3367,
4100,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
13045,
1007,
1025,
9530,
3367,
3653,
2615,
18715,
2368,
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... |
facebook/relay | packages/relay-runtime/store/DataChecker.js | check | function check(
source: RecordSource,
target: MutableRecordSource,
selector: NormalizationSelector,
handlers: $ReadOnlyArray<MissingFieldHandler>,
operationLoader: ?OperationLoader,
getDataID: GetDataID,
): boolean {
const {dataID, node, variables} = selector;
const checker = new DataChecker(
source,
target,
variables,
handlers,
operationLoader,
getDataID,
);
return checker.check(node, dataID);
} | javascript | function check(
source: RecordSource,
target: MutableRecordSource,
selector: NormalizationSelector,
handlers: $ReadOnlyArray<MissingFieldHandler>,
operationLoader: ?OperationLoader,
getDataID: GetDataID,
): boolean {
const {dataID, node, variables} = selector;
const checker = new DataChecker(
source,
target,
variables,
handlers,
operationLoader,
getDataID,
);
return checker.check(node, dataID);
} | [
"function",
"check",
"(",
"source",
":",
"RecordSource",
",",
"target",
":",
"MutableRecordSource",
",",
"selector",
":",
"NormalizationSelector",
",",
"handlers",
":",
"$ReadOnlyArray",
"<",
"MissingFieldHandler",
">",
",",
"operationLoader",
":",
"?",
"OperationLo... | Synchronously check whether the records required to fulfill the given
`selector` are present in `source`.
If a field is missing, it uses the provided handlers to attempt to substitute
data. The `target` will store all records that are modified because of a
successful substitution.
If all records are present, returns `true`, otherwise `false`. | [
"Synchronously",
"check",
"whether",
"the",
"records",
"required",
"to",
"fulfill",
"the",
"given",
"selector",
"are",
"present",
"in",
"source",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/store/DataChecker.js#L72-L90 | train | Checks if a given selector matches the dataID. | [
30522,
3853,
4638,
1006,
3120,
1024,
2636,
8162,
3401,
1010,
4539,
1024,
14163,
10880,
2890,
27108,
30524,
28213,
2015,
1024,
1002,
3191,
2239,
2135,
2906,
9447,
1026,
4394,
3790,
11774,
3917,
1028,
1010,
3169,
11066,
2121,
1024,
1029,
3169... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/timing.js | time | function time(key, fn) {
if (typeof data[key] === "undefined") {
data[key] = 0;
}
return function(...args) {
let t = process.hrtime();
fn(...args);
t = process.hrtime(t);
data[key] += t[0] * 1e3 + t[1] / 1e6;
};
} | javascript | function time(key, fn) {
if (typeof data[key] === "undefined") {
data[key] = 0;
}
return function(...args) {
let t = process.hrtime();
fn(...args);
t = process.hrtime(t);
data[key] += t[0] * 1e3 + t[1] / 1e6;
};
} | [
"function",
"time",
"(",
"key",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"data",
"[",
"key",
"]",
"===",
"\"undefined\"",
")",
"{",
"data",
"[",
"key",
"]",
"=",
"0",
";",
"}",
"return",
"function",
"(",
"...",
"args",
")",
"{",
"let",
"t",
"=... | Time the run
@param {*} key key from the data object
@param {Function} fn function to be called
@returns {Function} function to be executed
@private | [
"Time",
"the",
"run"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/timing.js#L114-L126 | train | get time function | [
30522,
3853,
2051,
1006,
3145,
1010,
1042,
2078,
1007,
1063,
2065,
1006,
2828,
11253,
2951,
1031,
3145,
1033,
1027,
1027,
1027,
1000,
6151,
28344,
1000,
1007,
1063,
2951,
1031,
3145,
1033,
1027,
1014,
1025,
1065,
2709,
3853,
1006,
1012,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ApiDetail.controller.js | function (aData) {
var oEntityData,
oMasterController,
sTopicId = this._sTopicid;
// Cache api-index data
this._aApiIndex = aData;
// Find symbol
function findSymbol (a) {
return a.some(function (o) {
var bFound = o.name === sTopicId;
if (!bFound && o.nodes) {
return findSymbol(o.nodes);
} else if (bFound) {
oEntityData = o;
return true;
}
return false;
});
}
findSymbol(aData);
if (oEntityData) {
// Cache entity data
this._oEntityData = oEntityData;
// If target symbol is deprecated - all deprecated records should be shown in the tree
if (oEntityData.deprecated) {
oMasterController = this.getOwnerComponent().getConfigUtil().getMasterView("apiId").getController();
oMasterController.selectDeprecatedSymbol(this._sTopicid);
}
// Load API.json only for selected lib
return APIInfo.getLibraryElementsJSONPromise(oEntityData.lib).then(function (aData) {
return Promise.resolve(aData); // We have found the symbol and loaded the corresponding api.json
});
}
// If we are here - the object does not exist so we reject the promise.
return Promise.reject(this.NOT_FOUND);
} | javascript | function (aData) {
var oEntityData,
oMasterController,
sTopicId = this._sTopicid;
// Cache api-index data
this._aApiIndex = aData;
// Find symbol
function findSymbol (a) {
return a.some(function (o) {
var bFound = o.name === sTopicId;
if (!bFound && o.nodes) {
return findSymbol(o.nodes);
} else if (bFound) {
oEntityData = o;
return true;
}
return false;
});
}
findSymbol(aData);
if (oEntityData) {
// Cache entity data
this._oEntityData = oEntityData;
// If target symbol is deprecated - all deprecated records should be shown in the tree
if (oEntityData.deprecated) {
oMasterController = this.getOwnerComponent().getConfigUtil().getMasterView("apiId").getController();
oMasterController.selectDeprecatedSymbol(this._sTopicid);
}
// Load API.json only for selected lib
return APIInfo.getLibraryElementsJSONPromise(oEntityData.lib).then(function (aData) {
return Promise.resolve(aData); // We have found the symbol and loaded the corresponding api.json
});
}
// If we are here - the object does not exist so we reject the promise.
return Promise.reject(this.NOT_FOUND);
} | [
"function",
"(",
"aData",
")",
"{",
"var",
"oEntityData",
",",
"oMasterController",
",",
"sTopicId",
"=",
"this",
".",
"_sTopicid",
";",
"// Cache api-index data",
"this",
".",
"_aApiIndex",
"=",
"aData",
";",
"// Find symbol",
"function",
"findSymbol",
"(",
"a"... | Process data from api-index file and if symbol is found load the corresponding api.json file for the
symbol library. If the symbol is not resolved this method returns a rejected promise which triggers
navigation to not found page.
@param {array} aData data from api-index file
@return {Promise} resolved or rejected promise
@private | [
"Process",
"data",
"from",
"api",
"-",
"index",
"file",
"and",
"if",
"symbol",
"is",
"found",
"load",
"the",
"corresponding",
"api",
".",
"json",
"file",
"for",
"the",
"symbol",
"library",
".",
"If",
"the",
"symbol",
"is",
"not",
"resolved",
"this",
"met... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ApiDetail.controller.js#L208-L249 | train | Load the API. json for the target symbol | [
30522,
3853,
1006,
15262,
2696,
1007,
1063,
13075,
1051,
4765,
3012,
2850,
2696,
1010,
18168,
24268,
8663,
13181,
10820,
1010,
2644,
28775,
2094,
1027,
2023,
1012,
1035,
2644,
28775,
2094,
1025,
1013,
1013,
17053,
17928,
1011,
5950,
2951,
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... | |
ecomfe/zrender | src/dom/HandlerProxy.js | function (event) {
event = normalizeEvent(this.dom, event);
// Mark touch, which is useful in distinguish touch and
// mouse event in upper applicatoin.
event.zrByTouch = true;
this.handler.processGesture(this, event, 'end');
domHandlers.mouseup.call(this, event);
// Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
// triggered in `touchstart`. This seems to be illogical, but by this mechanism,
// we can conveniently implement "hover style" in both PC and touch device just
// by listening to `mouseover` to add "hover style" and listening to `mouseout`
// to remove "hover style" on an element, without any additional code for
// compatibility. (`mouseout` will not be triggered in `touchend`, so "hover
// style" will remain for user view)
// click event should always be triggered no matter whether
// there is gestrue event. System click can not be prevented.
if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
domHandlers.click.call(this, event);
}
setTouchTimer(this);
} | javascript | function (event) {
event = normalizeEvent(this.dom, event);
// Mark touch, which is useful in distinguish touch and
// mouse event in upper applicatoin.
event.zrByTouch = true;
this.handler.processGesture(this, event, 'end');
domHandlers.mouseup.call(this, event);
// Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
// triggered in `touchstart`. This seems to be illogical, but by this mechanism,
// we can conveniently implement "hover style" in both PC and touch device just
// by listening to `mouseover` to add "hover style" and listening to `mouseout`
// to remove "hover style" on an element, without any additional code for
// compatibility. (`mouseout` will not be triggered in `touchend`, so "hover
// style" will remain for user view)
// click event should always be triggered no matter whether
// there is gestrue event. System click can not be prevented.
if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
domHandlers.click.call(this, event);
}
setTouchTimer(this);
} | [
"function",
"(",
"event",
")",
"{",
"event",
"=",
"normalizeEvent",
"(",
"this",
".",
"dom",
",",
"event",
")",
";",
"// Mark touch, which is useful in distinguish touch and",
"// mouse event in upper applicatoin.",
"event",
".",
"zrByTouch",
"=",
"true",
";",
"this",... | Touch结束响应函数
@inner
@param {Event} event | [
"Touch结束响应函数"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/dom/HandlerProxy.js#L154-L181 | train | The mouseup event handler | [
30522,
3853,
1006,
2724,
1007,
1063,
2724,
1027,
3671,
4697,
18697,
3372,
1006,
2023,
1012,
14383,
1010,
2724,
1007,
1025,
1013,
1013,
2928,
3543,
1010,
2029,
2003,
6179,
1999,
10782,
3543,
1998,
1013,
1013,
8000,
2724,
1999,
3356,
10439,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
google/closure-library | closure/goog/html/sanitizer/csspropertysanitizer.js | getSafeUri | function getSafeUri(uri, propName, uriRewriter) {
if (!uriRewriter) {
return null;
}
var safeUri = uriRewriter(uri, propName);
if (safeUri && SafeUrl.unwrap(safeUri) != SafeUrl.INNOCUOUS_STRING) {
return 'url("' +
SafeUrl.unwrap(safeUri).replace(NORM_URL_REGEXP, normalizeUrlChar) +
'")';
}
return null;
} | javascript | function getSafeUri(uri, propName, uriRewriter) {
if (!uriRewriter) {
return null;
}
var safeUri = uriRewriter(uri, propName);
if (safeUri && SafeUrl.unwrap(safeUri) != SafeUrl.INNOCUOUS_STRING) {
return 'url("' +
SafeUrl.unwrap(safeUri).replace(NORM_URL_REGEXP, normalizeUrlChar) +
'")';
}
return null;
} | [
"function",
"getSafeUri",
"(",
"uri",
",",
"propName",
",",
"uriRewriter",
")",
"{",
"if",
"(",
"!",
"uriRewriter",
")",
"{",
"return",
"null",
";",
"}",
"var",
"safeUri",
"=",
"uriRewriter",
"(",
"uri",
",",
"propName",
")",
";",
"if",
"(",
"safeUri",... | Constructs a safe URI from a given URI and prop using a given uriRewriter
function.
@param {string} uri URI to be sanitized.
@param {string} propName Property name which contained the URI.
@param {?function(string, string):?SafeUrl} uriRewriter A URI rewriter that
returns a {@link SafeUrl}.
@return {?string} Safe URI for use in CSS. | [
"Constructs",
"a",
"safe",
"URI",
"from",
"a",
"given",
"URI",
"and",
"prop",
"using",
"a",
"given",
"uriRewriter",
"function",
"."
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/sanitizer/csspropertysanitizer.js#L92-L103 | train | Get a safe URI from a URI and property name | [
30522,
3853,
4152,
10354,
11236,
2072,
1006,
24471,
2072,
1010,
17678,
18442,
1010,
24471,
7442,
15994,
1007,
1063,
2065,
1006,
999,
24471,
7442,
15994,
1007,
1063,
2709,
19701,
1025,
1065,
13075,
3647,
9496,
1027,
24471,
7442,
15994,
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... |
Microsoft/vscode | src/bootstrap-window.js | function (e) {
const key = extractKey(e);
if (key === TOGGLE_DEV_TOOLS_KB || key === TOGGLE_DEV_TOOLS_KB_ALT) {
ipc.send('vscode:toggleDevTools');
} else if (key === RELOAD_KB) {
ipc.send('vscode:reloadWindow');
}
} | javascript | function (e) {
const key = extractKey(e);
if (key === TOGGLE_DEV_TOOLS_KB || key === TOGGLE_DEV_TOOLS_KB_ALT) {
ipc.send('vscode:toggleDevTools');
} else if (key === RELOAD_KB) {
ipc.send('vscode:reloadWindow');
}
} | [
"function",
"(",
"e",
")",
"{",
"const",
"key",
"=",
"extractKey",
"(",
"e",
")",
";",
"if",
"(",
"key",
"===",
"TOGGLE_DEV_TOOLS_KB",
"||",
"key",
"===",
"TOGGLE_DEV_TOOLS_KB_ALT",
")",
"{",
"ipc",
".",
"send",
"(",
"'vscode:toggleDevTools'",
")",
";",
... | mac: Cmd-R, rest: Ctrl-R | [
"mac",
":",
"Cmd",
"-",
"R",
"rest",
":",
"Ctrl",
"-",
"R"
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/src/bootstrap-window.js#L184-L191 | train | Handle keydown events | [
30522,
3853,
1006,
1041,
1007,
1063,
9530,
3367,
3145,
1027,
14817,
14839,
1006,
1041,
1007,
1025,
2065,
1006,
3145,
1027,
1027,
1027,
2000,
24679,
1035,
16475,
1035,
5906,
1035,
21677,
1064,
1064,
3145,
1027,
1027,
1027,
2000,
24679,
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... | |
SheetJS/js-xlsx | xlsx.js | parse_RgceArea | function parse_RgceArea(blob, length, opts) {
var w = 2;
if(opts) {
if(opts.biff >= 2 && opts.biff <= 5) return parse_RgceArea_BIFF2(blob, length, opts);
else if(opts.biff == 12) w = 4;
}
var r=blob.read_shift(w), R=blob.read_shift(w);
var c=parse_ColRelU(blob, 2);
var C=parse_ColRelU(blob, 2);
return { s:{r:r, c:c[0], cRel:c[1], rRel:c[2]}, e:{r:R, c:C[0], cRel:C[1], rRel:C[2]} };
} | javascript | function parse_RgceArea(blob, length, opts) {
var w = 2;
if(opts) {
if(opts.biff >= 2 && opts.biff <= 5) return parse_RgceArea_BIFF2(blob, length, opts);
else if(opts.biff == 12) w = 4;
}
var r=blob.read_shift(w), R=blob.read_shift(w);
var c=parse_ColRelU(blob, 2);
var C=parse_ColRelU(blob, 2);
return { s:{r:r, c:c[0], cRel:c[1], rRel:c[2]}, e:{r:R, c:C[0], cRel:C[1], rRel:C[2]} };
} | [
"function",
"parse_RgceArea",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"w",
"=",
"2",
";",
"if",
"(",
"opts",
")",
"{",
"if",
"(",
"opts",
".",
"biff",
">=",
"2",
"&&",
"opts",
".",
"biff",
"<=",
"5",
")",
"return",
"parse_RgceAr... | /* [MS-XLS] 2.5.198.105 ; [MS-XLSB] 2.5.97.89 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"105",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"89"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10234-L10244 | train | ECMA - 262 12. 2. 2 | [
30522,
3853,
11968,
3366,
1035,
1054,
18195,
14644,
5243,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
1059,
1027,
1016,
1025,
2065,
1006,
23569,
2015,
1007,
1063,
2065,
1006,
23569,
2015,
1012,
12170,
4246,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | convertNode | function convertNode(node, children) {
switch (node.type) {
/**
* General
*
* Convert simple cases that only require a type and children, with no
* additional properties.
*/
case 'root':
case 'paragraph':
case 'quote':
case 'list-item':
case 'table':
case 'table-row':
case 'table-cell': {
return u(typeMap[node.type], children);
}
/**
* Shortcodes
*
* Shortcode nodes only exist in Slate's Raw AST if they were inserted
* via the plugin toolbar in memory, so they should always have
* shortcode data attached. The "shortcode" data property contains the
* name of the registered shortcode plugin, and the "shortcodeData" data
* property contains the data received from the shortcode plugin's
* `fromBlock` method when the shortcode node was created.
*
* Here we create a `shortcode` MDAST node that contains only the shortcode
* data.
*/
case 'shortcode': {
const { data } = node;
return u(typeMap[node.type], { data });
}
/**
* Headings
*
* Slate schemas don't usually infer basic type info from data, so each
* level of heading is a separately named type. The MDAST schema just
* has a single "heading" type with the depth stored in a "depth"
* property on the node. Here we derive the depth from the Slate node
* type - e.g., for "heading-two", we need a depth value of "2".
*/
case 'heading-one':
case 'heading-two':
case 'heading-three':
case 'heading-four':
case 'heading-five':
case 'heading-six': {
const depthMap = { one: 1, two: 2, three: 3, four: 4, five: 5, six: 6 };
const depthText = node.type.split('-')[1];
const depth = depthMap[depthText];
return u(typeMap[node.type], { depth }, children);
}
/**
* Code Blocks
*
* Code block nodes have a single text child, and may have a code language
* stored in the "lang" data property. Here we transfer both the node
* value and the "lang" data property to the new MDAST node.
*/
case 'code': {
const value = flatMap(node.nodes, child => {
return flatMap(child.leaves, 'text');
}).join('');
const { lang, ...data } = get(node, 'data', {});
return u(typeMap[node.type], { lang, data }, value);
}
/**
* Lists
*
* Our Slate schema has separate node types for ordered and unordered
* lists, but the MDAST spec uses a single type with a boolean "ordered"
* property to indicate whether the list is numbered. The MDAST spec also
* allows for a "start" property to indicate the first number used for an
* ordered list. Here we translate both values to our Slate schema.
*/
case 'numbered-list':
case 'bulleted-list': {
const ordered = node.type === 'numbered-list';
const props = { ordered, start: get(node.data, 'start') || 1 };
return u(typeMap[node.type], props, children);
}
/**
* Breaks
*
* Breaks don't have children. We parse them separately for clarity.
*/
case 'break':
case 'thematic-break': {
return u(typeMap[node.type]);
}
/**
* Links
*
* The url and title attributes of link nodes are stored in properties on
* the node for both Slate and Remark schemas.
*/
case 'link': {
const { url, title, ...data } = get(node, 'data', {});
return u(typeMap[node.type], { url, title, data }, children);
}
/**
* Images
*
* This transformation is almost identical to that of links, except for the
* lack of child nodes and addition of `alt` attribute data.
*/
case 'image': {
const { url, title, alt, ...data } = get(node, 'data', {});
return u(typeMap[node.type], { url, title, alt, data });
}
/**
* No default case is supplied because an unhandled case should never
* occur. In the event that it does, let the error throw (for now).
*/
}
} | javascript | function convertNode(node, children) {
switch (node.type) {
/**
* General
*
* Convert simple cases that only require a type and children, with no
* additional properties.
*/
case 'root':
case 'paragraph':
case 'quote':
case 'list-item':
case 'table':
case 'table-row':
case 'table-cell': {
return u(typeMap[node.type], children);
}
/**
* Shortcodes
*
* Shortcode nodes only exist in Slate's Raw AST if they were inserted
* via the plugin toolbar in memory, so they should always have
* shortcode data attached. The "shortcode" data property contains the
* name of the registered shortcode plugin, and the "shortcodeData" data
* property contains the data received from the shortcode plugin's
* `fromBlock` method when the shortcode node was created.
*
* Here we create a `shortcode` MDAST node that contains only the shortcode
* data.
*/
case 'shortcode': {
const { data } = node;
return u(typeMap[node.type], { data });
}
/**
* Headings
*
* Slate schemas don't usually infer basic type info from data, so each
* level of heading is a separately named type. The MDAST schema just
* has a single "heading" type with the depth stored in a "depth"
* property on the node. Here we derive the depth from the Slate node
* type - e.g., for "heading-two", we need a depth value of "2".
*/
case 'heading-one':
case 'heading-two':
case 'heading-three':
case 'heading-four':
case 'heading-five':
case 'heading-six': {
const depthMap = { one: 1, two: 2, three: 3, four: 4, five: 5, six: 6 };
const depthText = node.type.split('-')[1];
const depth = depthMap[depthText];
return u(typeMap[node.type], { depth }, children);
}
/**
* Code Blocks
*
* Code block nodes have a single text child, and may have a code language
* stored in the "lang" data property. Here we transfer both the node
* value and the "lang" data property to the new MDAST node.
*/
case 'code': {
const value = flatMap(node.nodes, child => {
return flatMap(child.leaves, 'text');
}).join('');
const { lang, ...data } = get(node, 'data', {});
return u(typeMap[node.type], { lang, data }, value);
}
/**
* Lists
*
* Our Slate schema has separate node types for ordered and unordered
* lists, but the MDAST spec uses a single type with a boolean "ordered"
* property to indicate whether the list is numbered. The MDAST spec also
* allows for a "start" property to indicate the first number used for an
* ordered list. Here we translate both values to our Slate schema.
*/
case 'numbered-list':
case 'bulleted-list': {
const ordered = node.type === 'numbered-list';
const props = { ordered, start: get(node.data, 'start') || 1 };
return u(typeMap[node.type], props, children);
}
/**
* Breaks
*
* Breaks don't have children. We parse them separately for clarity.
*/
case 'break':
case 'thematic-break': {
return u(typeMap[node.type]);
}
/**
* Links
*
* The url and title attributes of link nodes are stored in properties on
* the node for both Slate and Remark schemas.
*/
case 'link': {
const { url, title, ...data } = get(node, 'data', {});
return u(typeMap[node.type], { url, title, data }, children);
}
/**
* Images
*
* This transformation is almost identical to that of links, except for the
* lack of child nodes and addition of `alt` attribute data.
*/
case 'image': {
const { url, title, alt, ...data } = get(node, 'data', {});
return u(typeMap[node.type], { url, title, alt, data });
}
/**
* No default case is supplied because an unhandled case should never
* occur. In the event that it does, let the error throw (for now).
*/
}
} | [
"function",
"convertNode",
"(",
"node",
",",
"children",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"/**\n * General\n *\n * Convert simple cases that only require a type and children, with no\n * additional properties.\n */",
"case",
"'root'",
":... | Convert a single Slate Raw node to an MDAST node. Uses the unist-builder `u`
function to create MDAST nodes. | [
"Convert",
"a",
"single",
"Slate",
"Raw",
"node",
"to",
"an",
"MDAST",
"node",
".",
"Uses",
"the",
"unist",
"-",
"builder",
"u",
"function",
"to",
"create",
"MDAST",
"nodes",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L385-L510 | train | Convert a node to a MDAST node. | [
30522,
3853,
10463,
3630,
3207,
1006,
13045,
1010,
2336,
1007,
1063,
6942,
1006,
13045,
1012,
2828,
1007,
1063,
1013,
1008,
1008,
1008,
2236,
1008,
1008,
10463,
3722,
3572,
2008,
2069,
5478,
1037,
2828,
1998,
2336,
1010,
2007,
2053,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/ScopeManager.js | _postMessageByPass | function _postMessageByPass(msg) {
ternPromise.done(function (ternModule) {
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} | javascript | function _postMessageByPass(msg) {
ternPromise.done(function (ternModule) {
if (config.debug) {
console.debug("Sending message", msg);
}
_ternNodeDomain.exec("invokeTernCommand", msg);
});
} | [
"function",
"_postMessageByPass",
"(",
"msg",
")",
"{",
"ternPromise",
".",
"done",
"(",
"function",
"(",
"ternModule",
")",
"{",
"if",
"(",
"config",
".",
"debug",
")",
"{",
"console",
".",
"debug",
"(",
"\"Sending message\"",
",",
"msg",
")",
";",
"}",... | Send a message to the tern node domain - this is only for messages that
need to be sent before and while the addFilesPromise is being resolved. | [
"Send",
"a",
"message",
"to",
"the",
"tern",
"node",
"domain",
"-",
"this",
"is",
"only",
"for",
"messages",
"that",
"need",
"to",
"be",
"sent",
"before",
"and",
"while",
"the",
"addFilesPromise",
"is",
"being",
"resolved",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L870-L877 | train | post message by pass | [
30522,
3853,
1035,
2695,
7834,
3736,
3351,
3762,
15194,
1006,
5796,
2290,
1007,
1063,
28774,
16275,
21716,
5562,
1012,
2589,
1006,
3853,
1006,
28774,
2078,
5302,
8566,
2571,
1007,
1063,
2065,
1006,
9530,
8873,
2290,
1012,
2139,
8569,
2290,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/Axis.js | function (opt) {
opt = opt || {};
var tickModel = opt.tickModel || this.getTickModel();
var result = createAxisTicks(this, tickModel);
var ticks = result.ticks;
var ticksCoords = map(ticks, function (tickValue) {
return {
coord: this.dataToCoord(tickValue),
tickValue: tickValue
};
}, this);
var alignWithLabel = tickModel.get('alignWithLabel');
fixOnBandTicksCoords(
this, ticksCoords, result.tickCategoryInterval, alignWithLabel, opt.clamp
);
return ticksCoords;
} | javascript | function (opt) {
opt = opt || {};
var tickModel = opt.tickModel || this.getTickModel();
var result = createAxisTicks(this, tickModel);
var ticks = result.ticks;
var ticksCoords = map(ticks, function (tickValue) {
return {
coord: this.dataToCoord(tickValue),
tickValue: tickValue
};
}, this);
var alignWithLabel = tickModel.get('alignWithLabel');
fixOnBandTicksCoords(
this, ticksCoords, result.tickCategoryInterval, alignWithLabel, opt.clamp
);
return ticksCoords;
} | [
"function",
"(",
"opt",
")",
"{",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"var",
"tickModel",
"=",
"opt",
".",
"tickModel",
"||",
"this",
".",
"getTickModel",
"(",
")",
";",
"var",
"result",
"=",
"createAxisTicks",
"(",
"this",
",",
"tickModel",
")",... | Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
`axis.getTicksCoords` considers `onBand`, which is used by
`boundaryGap:true` of category axis and splitLine and splitArea.
@param {Object} [opt]
@param {number} [opt.tickModel=axis.model.getModel('axisTick')]
@param {boolean} [opt.clamp] If `true`, the first and the last
tick must be at the axis end points. Otherwise, clip ticks
that outside the axis extent.
@return {Array.<Object>} [{
coord: ...,
tickValue: ...
}, ...] | [
"Different",
"from",
"zrUtil",
".",
"map",
"(",
"axis",
".",
"getTicks",
"()",
"axis",
".",
"dataToCoord",
"axis",
")",
"axis",
".",
"getTicksCoords",
"considers",
"onBand",
"which",
"is",
"used",
"by",
"boundaryGap",
":",
"true",
"of",
"category",
"axis",
... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L185-L206 | train | Returns the coord of the ticks | [
30522,
3853,
1006,
23569,
1007,
1063,
23569,
1027,
23569,
1064,
1064,
1063,
1065,
1025,
13075,
16356,
5302,
9247,
1027,
23569,
1012,
16356,
5302,
9247,
1064,
1064,
2023,
1012,
2131,
26348,
5302,
9247,
1006,
1007,
1025,
13075,
2765,
1027,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/systems/shadow.js | function (enabled) {
var renderer = this.sceneEl.renderer;
this.shadowMapEnabled = this.data.enabled && enabled;
if (renderer) {
renderer.shadowMap.enabled = this.shadowMapEnabled;
}
} | javascript | function (enabled) {
var renderer = this.sceneEl.renderer;
this.shadowMapEnabled = this.data.enabled && enabled;
if (renderer) {
renderer.shadowMap.enabled = this.shadowMapEnabled;
}
} | [
"function",
"(",
"enabled",
")",
"{",
"var",
"renderer",
"=",
"this",
".",
"sceneEl",
".",
"renderer",
";",
"this",
".",
"shadowMapEnabled",
"=",
"this",
".",
"data",
".",
"enabled",
"&&",
"enabled",
";",
"if",
"(",
"renderer",
")",
"{",
"renderer",
".... | Enables/disables the renderer shadow map.
@param {boolean} enabled | [
"Enables",
"/",
"disables",
"the",
"renderer",
"shadow",
"map",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/shadow.js#L46-L52 | train | set shadow map enabled | [
30522,
3853,
1006,
9124,
1007,
1063,
13075,
17552,
2121,
1027,
2023,
1012,
3496,
2884,
1012,
17552,
2121,
1025,
2023,
1012,
5192,
2863,
11837,
3085,
2094,
1027,
2023,
1012,
2951,
1012,
9124,
1004,
1004,
9124,
1025,
2065,
1006,
17552,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AnnotationHelper.js | function (sPath, oDetails) {
var iIndexOfAt;
// Whether the given value is exactly <code>true</code>
function isTrue (vValue) {
return vValue === true;
}
if (!sPath || sPath[0] === "@") {
return false;
}
if (rCount.test(sPath)) {
return true;
}
iIndexOfAt = sPath.indexOf("@");
if (iIndexOfAt > -1) {
sPath = sPath.slice(0, iIndexOfAt);
}
if (sPath[sPath.length - 1] !== "/") {
sPath += "/";
}
sPath = "/" + oDetails.schemaChildName + "/" + sPath + "$isCollection";
return oDetails.$$valueAsPromise
? oDetails.context.getModel().fetchObject(sPath).then(isTrue).unwrap()
: oDetails.context.getObject(sPath) === true;
} | javascript | function (sPath, oDetails) {
var iIndexOfAt;
// Whether the given value is exactly <code>true</code>
function isTrue (vValue) {
return vValue === true;
}
if (!sPath || sPath[0] === "@") {
return false;
}
if (rCount.test(sPath)) {
return true;
}
iIndexOfAt = sPath.indexOf("@");
if (iIndexOfAt > -1) {
sPath = sPath.slice(0, iIndexOfAt);
}
if (sPath[sPath.length - 1] !== "/") {
sPath += "/";
}
sPath = "/" + oDetails.schemaChildName + "/" + sPath + "$isCollection";
return oDetails.$$valueAsPromise
? oDetails.context.getModel().fetchObject(sPath).then(isTrue).unwrap()
: oDetails.context.getObject(sPath) === true;
} | [
"function",
"(",
"sPath",
",",
"oDetails",
")",
"{",
"var",
"iIndexOfAt",
";",
"// Whether the given value is exactly <code>true</code>",
"function",
"isTrue",
"(",
"vValue",
")",
"{",
"return",
"vValue",
"===",
"true",
";",
"}",
"if",
"(",
"!",
"sPath",
"||",
... | A function that helps to interpret OData V4 annotations. It knows about the syntax
of the path value used by the following dynamic expressions:
<ul>
<li>"14.5.2 Expression edm:AnnotationPath"</li>
<li>"14.5.11 Expression edm:NavigationPropertyPath"</li>
<li>"14.5.12 Expression edm:Path"</li>
<li>"14.5.13 Expression edm:PropertyPath"</li>
</ul>
It returns the information whether the given path ends with "$count" or with a
multi-valued structural or navigation property. Term casts and annotations of
navigation properties are ignored.
Example:
<pre>
<template:if test="{facet>Target/$AnnotationPath@@sap.ui.model.odata.v4.AnnotationHelper.isMultiple}">
</pre>
@param {string} sPath
The path value from the meta model, for example
"ToSupplier/@com.sap.vocabularies.Communication.v1.Address" or
"@com.sap.vocabularies.UI.v1.FieldGroup#Dimensions"
@param {object} oDetails
The details object
@param {boolean} [oDetails.$$valueAsPromise]
Whether a <code>Promise</code> may be returned if the needed metadata is not yet
loaded (since 1.57.0)
@param {sap.ui.model.Context} oDetails.context
Points to the given path, that is
<code>oDetails.context.getProperty("") === sPath</code>
@param {string} oDetails.schemaChildName
The qualified name of the schema child where the computed annotation has been
found, for example "name.space.EntityType"
@returns {boolean|Promise}
<code>true</code> if the given path ends with "$count" or with a multi-valued
structural or navigation property, <code>false</code> otherwise. If
<code>oDetails.$$valueAsPromise</code> is <code>true</code> a <code>Promise</code>
may be returned resolving with the boolean value.
@public
@since 1.43.0 | [
"A",
"function",
"that",
"helps",
"to",
"interpret",
"OData",
"V4",
"annotations",
".",
"It",
"knows",
"about",
"the",
"syntax",
"of",
"the",
"path",
"value",
"used",
"by",
"the",
"following",
"dynamic",
"expressions",
":",
"<ul",
">",
"<li",
">",
"14",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js#L383-L409 | train | Determines whether the given path is a valid object. | [
30522,
3853,
1006,
14690,
2232,
1010,
24040,
22081,
1007,
1063,
13075,
2462,
13629,
2595,
11253,
4017,
1025,
1013,
1013,
3251,
1996,
2445,
3643,
2003,
3599,
1026,
3642,
1028,
2995,
1026,
1013,
3642,
1028,
3853,
21541,
6820,
2063,
1006,
1058... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mochajs/mocha | lib/reporters/base.js | colorLines | function colorLines(name, str) {
return str
.split('\n')
.map(function(str) {
return color(name, str);
})
.join('\n');
} | javascript | function colorLines(name, str) {
return str
.split('\n')
.map(function(str) {
return color(name, str);
})
.join('\n');
} | [
"function",
"colorLines",
"(",
"name",
",",
"str",
")",
"{",
"return",
"str",
".",
"split",
"(",
"'\\n'",
")",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"color",
"(",
"name",
",",
"str",
")",
";",
"}",
")",
".",
"join",
"(",
... | Colors lines for `str`, using the color `name`.
@private
@param {string} name
@param {string} str
@return {string} | [
"Colors",
"lines",
"for",
"str",
"using",
"the",
"color",
"name",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/base.js#L465-L472 | train | color lines | [
30522,
3853,
3609,
12735,
1006,
2171,
1010,
2358,
2099,
1007,
1063,
2709,
2358,
2099,
1012,
3975,
1006,
1005,
1032,
1050,
1005,
1007,
1012,
4949,
1006,
3853,
1006,
2358,
2099,
1007,
1063,
2709,
3609,
1006,
2171,
1010,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/downloads.js | downloadManager | function downloadManager() {
this._controller = null;
this.downloadState = downloadState;
this._dms = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
} | javascript | function downloadManager() {
this._controller = null;
this.downloadState = downloadState;
this._dms = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
} | [
"function",
"downloadManager",
"(",
")",
"{",
"this",
".",
"_controller",
"=",
"null",
";",
"this",
".",
"downloadState",
"=",
"downloadState",
";",
"this",
".",
"_dms",
"=",
"Cc",
"[",
"\"@mozilla.org/download-manager;1\"",
"]",
".",
"getService",
"(",
"Ci",
... | Constructor | [
"Constructor"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L71-L77 | train | A download manager. | [
30522,
3853,
8816,
24805,
4590,
1006,
1007,
1063,
2023,
1012,
1035,
11486,
1027,
19701,
1025,
2023,
1012,
22956,
12259,
1027,
22956,
12259,
1025,
2023,
1012,
1035,
1040,
5244,
1027,
10507,
1031,
1000,
1030,
9587,
5831,
4571,
1012,
8917,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oPathValue, sEdmType) {
var vValue = oPathValue.value;
if (sEdmType === "String") {
if (rI18n.test(vValue)) { // a simple binding to "@i18n" model
return {
ignoreTypeInPath : true,
result : "binding",
type : "Edm.String",
value : vValue.slice(1, -1) // cut off "{" and "}"
};
}
}
return {
result : "constant",
type : mType2Type[sEdmType],
value : vValue
};
} | javascript | function (oPathValue, sEdmType) {
var vValue = oPathValue.value;
if (sEdmType === "String") {
if (rI18n.test(vValue)) { // a simple binding to "@i18n" model
return {
ignoreTypeInPath : true,
result : "binding",
type : "Edm.String",
value : vValue.slice(1, -1) // cut off "{" and "}"
};
}
}
return {
result : "constant",
type : mType2Type[sEdmType],
value : vValue
};
} | [
"function",
"(",
"oPathValue",
",",
"sEdmType",
")",
"{",
"var",
"vValue",
"=",
"oPathValue",
".",
"value",
";",
"if",
"(",
"sEdmType",
"===",
"\"String\"",
")",
"{",
"if",
"(",
"rI18n",
".",
"test",
"(",
"vValue",
")",
")",
"{",
"// a simple binding to ... | Handling of "14.4 Constant Expressions", i.e.
<ul>
<li>"14.4.2 Expression edm:Bool",</li>
<li>"14.4.3 Expression edm:Date",</li>
<li>"14.4.4 Expression edm:DateTimeOffset",</li>
<li>"14.4.5 Expression edm:Decimal",</li>
<li>"14.4.8 Expression edm:Float",</li>
<li>"14.4.9 Expression edm:Guid",</li>
<li>"14.4.10 Expression edm:Int",</li>
<li>"14.4.11 Expression edm:String",</li>
<li>"14.4.12 Expression edm:TimeOfDay".</li>
</ul>
@param {object} oPathValue
path and value information pointing to the constant (see Expression object)
@param {string} sEdmType
the "edm:*" type of the constant, e.g. "Bool" or "Int" (incl. "Int32")
@returns {object}
the result object | [
"Handling",
"of",
"14",
".",
"4",
"Constant",
"Expressions",
"i",
".",
"e",
".",
"<ul",
">",
"<li",
">",
"14",
".",
"4",
".",
"2",
"Expression",
"edm",
":",
"Bool",
"<",
"/",
"li",
">",
"<li",
">",
"14",
".",
"4",
".",
"3",
"Expression",
"edm",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L307-L326 | train | returns a binding object for the given path value | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1010,
7367,
22117,
13874,
1007,
1063,
13075,
1058,
10175,
5657,
1027,
6728,
8988,
10175,
5657,
1012,
3643,
1025,
2065,
1006,
7367,
22117,
30524,
10175,
5657,
1007,
1007,
1063,
1013,
1013,
1037,
37... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dequelabs/axe-core | build/tasks/aria-supported.js | getSupportedElementsAsFootnote | function getSupportedElementsAsFootnote(elements) {
const notes = [];
const supportedElements = elements.map(element => {
if (typeof element === 'string') {
return `\`<${element}>\``;
}
/**
* if element is not a string it will be an object with structure:
{
nodeName: string,
properties: {
type: {string|string[]}
}
}
*/
return Object.keys(element.properties).map(prop => {
const value = element.properties[prop];
// the 'type' property can be a string or an array
if (typeof value === 'string') {
return `\`<${element.nodeName} ${prop}="${value}">\``;
}
// output format for an array of types:
// <input type="button" | "checkbox">
const values = value.map(v => `"${v}"`).join(' | ');
return `\`<${element.nodeName} ${prop}=${values}>\``;
});
});
notes.push('Supported on elements: ' + supportedElements.join(', '));
return notes;
} | javascript | function getSupportedElementsAsFootnote(elements) {
const notes = [];
const supportedElements = elements.map(element => {
if (typeof element === 'string') {
return `\`<${element}>\``;
}
/**
* if element is not a string it will be an object with structure:
{
nodeName: string,
properties: {
type: {string|string[]}
}
}
*/
return Object.keys(element.properties).map(prop => {
const value = element.properties[prop];
// the 'type' property can be a string or an array
if (typeof value === 'string') {
return `\`<${element.nodeName} ${prop}="${value}">\``;
}
// output format for an array of types:
// <input type="button" | "checkbox">
const values = value.map(v => `"${v}"`).join(' | ');
return `\`<${element.nodeName} ${prop}=${values}>\``;
});
});
notes.push('Supported on elements: ' + supportedElements.join(', '));
return notes;
} | [
"function",
"getSupportedElementsAsFootnote",
"(",
"elements",
")",
"{",
"const",
"notes",
"=",
"[",
"]",
";",
"const",
"supportedElements",
"=",
"elements",
".",
"map",
"(",
"element",
"=>",
"{",
"if",
"(",
"typeof",
"element",
"===",
"'string'",
")",
"{",
... | Parse a list of unsupported exception elements and add a footnote
detailing which HTML elements are supported.
@param {Array<String|Object>} elements List of supported elements
@returns {Array<String|Object>} notes | [
"Parse",
"a",
"list",
"of",
"unsupported",
"exception",
"elements",
"and",
"add",
"a",
"footnote",
"detailing",
"which",
"HTML",
"elements",
"are",
"supported",
"."
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/build/tasks/aria-supported.js#L159-L194 | train | Get the footnote for the given elements | [
30522,
3853,
4152,
6279,
6442,
14728,
16930,
11187,
3022,
13064,
22074,
1006,
3787,
1007,
1063,
9530,
3367,
3964,
1027,
1031,
1033,
1025,
9530,
3367,
3569,
12260,
8163,
1027,
3787,
1012,
4949,
1006,
5783,
1027,
1028,
1063,
2065,
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... |
adobe/brackets | src/view/MainViewManager.js | _forEachPaneOrPanes | function _forEachPaneOrPanes(paneId, callback) {
if (paneId === ALL_PANES) {
_.forEach(_panes, callback);
} else {
callback(_getPane(paneId));
}
} | javascript | function _forEachPaneOrPanes(paneId, callback) {
if (paneId === ALL_PANES) {
_.forEach(_panes, callback);
} else {
callback(_getPane(paneId));
}
} | [
"function",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"callback",
")",
"{",
"if",
"(",
"paneId",
"===",
"ALL_PANES",
")",
"{",
"_",
".",
"forEach",
"(",
"_panes",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"_getPane",
"(",
"paneId",
... | Iterates over the pane or ALL_PANES and calls the callback function for each.
@param {!string} paneId - id of the pane in which to adjust the scroll state, ALL_PANES or ACTIVE_PANE
@param {!function(!pane:Pane):boolean} callback - function to callback on to perform work.
The callback will receive a Pane and should return false to stop iterating.
@private | [
"Iterates",
"over",
"the",
"pane",
"or",
"ALL_PANES",
"and",
"calls",
"the",
"callback",
"function",
"for",
"each",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L486-L492 | train | For each pane or panes | [
30522,
3853,
1035,
18921,
6776,
9739,
8780,
14536,
7231,
2015,
1006,
6090,
7416,
2094,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
6090,
7416,
2094,
1027,
1027,
1027,
2035,
1035,
6090,
2229,
1007,
1063,
1035,
1012,
18921,
6776,
1006,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/ControlPersonalizationAPI.js | function(oControl) {
var oAppComponent = Utils.getAppComponentForControl(oControl);
var oFlexController = FlexControllerFactory.createForControl(oAppComponent);
var oRootControl = oAppComponent.getRootControl();
var oView = Utils.getViewForControl(oControl);
var oVariantModel = oAppComponent.getModel("$FlexVariants");
var mParams = {
rootControl : oRootControl,
view : oView,
variantModel : oVariantModel,
variantManagement : {},
flexController: oFlexController
};
var oVMControl;
var aForControlTypes;
jQuery.makeArray(mParams.rootControl.$().find(".sapUiFlVarMngmt")).map(function(oVariantManagementNode) {
oVMControl = sap.ui.getCore().byId(oVariantManagementNode.id);
if (oVMControl.getMetadata().getName() === "sap.ui.fl.variants.VariantManagement") {
aForControlTypes = oVMControl.getFor();
aForControlTypes.forEach(function(sControlType) {
mParams.variantManagement[sControlType] = mParams.variantModel.getLocalId(oVariantManagementNode.id, oAppComponent);
});
}
});
return mParams;
} | javascript | function(oControl) {
var oAppComponent = Utils.getAppComponentForControl(oControl);
var oFlexController = FlexControllerFactory.createForControl(oAppComponent);
var oRootControl = oAppComponent.getRootControl();
var oView = Utils.getViewForControl(oControl);
var oVariantModel = oAppComponent.getModel("$FlexVariants");
var mParams = {
rootControl : oRootControl,
view : oView,
variantModel : oVariantModel,
variantManagement : {},
flexController: oFlexController
};
var oVMControl;
var aForControlTypes;
jQuery.makeArray(mParams.rootControl.$().find(".sapUiFlVarMngmt")).map(function(oVariantManagementNode) {
oVMControl = sap.ui.getCore().byId(oVariantManagementNode.id);
if (oVMControl.getMetadata().getName() === "sap.ui.fl.variants.VariantManagement") {
aForControlTypes = oVMControl.getFor();
aForControlTypes.forEach(function(sControlType) {
mParams.variantManagement[sControlType] = mParams.variantModel.getLocalId(oVariantManagementNode.id, oAppComponent);
});
}
});
return mParams;
} | [
"function",
"(",
"oControl",
")",
"{",
"var",
"oAppComponent",
"=",
"Utils",
".",
"getAppComponentForControl",
"(",
"oControl",
")",
";",
"var",
"oFlexController",
"=",
"FlexControllerFactory",
".",
"createForControl",
"(",
"oAppComponent",
")",
";",
"var",
"oRoot... | Returns a map of parameters used in public functions.
@param {sap.ui.core.Element} oControl - The control for which a variant management control has to be evaluated
@returns {object} Returns a map with needed parameters
@private | [
"Returns",
"a",
"map",
"of",
"parameters",
"used",
"in",
"public",
"functions",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/ControlPersonalizationAPI.js#L66-L94 | train | Returns the parameters for the given control. | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1007,
1063,
13075,
1051,
29098,
9006,
29513,
3372,
1027,
21183,
12146,
1012,
2131,
29098,
9006,
29513,
3372,
29278,
8663,
13181,
2140,
1006,
1051,
8663,
13181,
2140,
1007,
1025,
13075,
1997,
2571,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
radare/radare2 | shlr/www/graph/js-graph-it.js | calculateOffsetLeft | function calculateOffsetLeft(obj)
{
var curleft = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
while (obj = obj.offsetParent)
curleft += obj.offsetLeft;
} else if (obj.x)
curleft += obj.x;
return curleft;
} | javascript | function calculateOffsetLeft(obj)
{
var curleft = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
while (obj = obj.offsetParent)
curleft += obj.offsetLeft;
} else if (obj.x)
curleft += obj.x;
return curleft;
} | [
"function",
"calculateOffsetLeft",
"(",
"obj",
")",
"{",
"var",
"curleft",
"=",
"0",
";",
"if",
"(",
"obj",
".",
"offsetParent",
")",
"{",
"curleft",
"=",
"obj",
".",
"offsetLeft",
"while",
"(",
"obj",
"=",
"obj",
".",
"offsetParent",
")",
"curleft",
"... | /*
This function calculates the absolute 'left' value for a html node | [
"/",
"*",
"This",
"function",
"calculates",
"the",
"absolute",
"left",
"value",
"for",
"a",
"html",
"node"
] | bf5e3028810a0ec7c267c6fe4bfad639b4819e35 | https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/js-graph-it.js#L1227-L1237 | train | Calculates the left offset of an object. | [
30522,
3853,
18422,
27475,
3388,
2571,
6199,
1006,
27885,
3501,
1007,
1063,
13075,
15390,
29218,
1027,
1014,
1025,
2065,
1006,
27885,
3501,
1012,
16396,
19362,
4765,
1007,
1063,
15390,
29218,
1027,
27885,
3501,
1012,
16396,
2571,
6199,
2096,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_BrtShrFmla | function parse_BrtShrFmla(data, length, opts) {
var end = data.l + length;
var rfx = parse_UncheckedRfX(data, 16);
var o = [rfx];
if(opts.cellFormula) {
var formula = parse_XLSBSharedParsedFormula(data, end - data.l, opts);
o[1] = formula;
data.l = end;
} else data.l = end;
return o;
} | javascript | function parse_BrtShrFmla(data, length, opts) {
var end = data.l + length;
var rfx = parse_UncheckedRfX(data, 16);
var o = [rfx];
if(opts.cellFormula) {
var formula = parse_XLSBSharedParsedFormula(data, end - data.l, opts);
o[1] = formula;
data.l = end;
} else data.l = end;
return o;
} | [
"function",
"parse_BrtShrFmla",
"(",
"data",
",",
"length",
",",
"opts",
")",
"{",
"var",
"end",
"=",
"data",
".",
"l",
"+",
"length",
";",
"var",
"rfx",
"=",
"parse_UncheckedRfX",
"(",
"data",
",",
"16",
")",
";",
"var",
"o",
"=",
"[",
"rfx",
"]",... | /* [MS-XLSB] 2.4.750 BrtShrFmla | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"750",
"BrtShrFmla"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L13676-L13686 | train | Parse Brt Shr Fmla | [
30522,
3853,
11968,
3366,
1035,
7987,
3215,
8093,
16715,
2721,
1006,
2951,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2203,
1027,
2951,
1012,
1048,
1009,
3091,
1025,
13075,
21792,
2595,
1027,
11968,
3366,
1035,
4895,
5403,
18141,
128... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/interfaces/interfaces.js | getJavaScriptCallbackParameterListSimple | function getJavaScriptCallbackParameterListSimple(parameters) {
var result = []
parameters.forEach(function(parameter){
if (!parameter.out) return
result.push("/*" + getIdlType(parameter.type) + "*/ "+ parameter.name)
})
return result.join(", ")
} | javascript | function getJavaScriptCallbackParameterListSimple(parameters) {
var result = []
parameters.forEach(function(parameter){
if (!parameter.out) return
result.push("/*" + getIdlType(parameter.type) + "*/ "+ parameter.name)
})
return result.join(", ")
} | [
"function",
"getJavaScriptCallbackParameterListSimple",
"(",
"parameters",
")",
"{",
"var",
"result",
"=",
"[",
"]",
"parameters",
".",
"forEach",
"(",
"function",
"(",
"parameter",
")",
"{",
"if",
"(",
"!",
"parameter",
".",
"out",
")",
"return",
"result",
... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/interfaces/interfaces.js#L332-L341 | train | getJavaScriptCallbackParameterListSimple - returns a string with the parameters | [
30522,
3853,
2131,
3900,
12044,
23235,
9289,
20850,
8684,
28689,
22828,
27103,
5714,
10814,
1006,
11709,
1007,
1063,
13075,
2765,
1027,
1031,
1033,
11709,
1012,
18921,
6776,
1006,
3853,
1006,
16381,
1007,
1063,
2065,
1006,
999,
16381,
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... |
catapult-project/catapult | common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js | doScrollCheck | function doScrollCheck() {
if ( jQuery.isReady ) {
return;
}
try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
document.documentElement.doScroll("left");
} catch(e) {
setTimeout( doScrollCheck, 1 );
return;
}
// and execute any waiting functions
jQuery.ready();
} | javascript | function doScrollCheck() {
if ( jQuery.isReady ) {
return;
}
try {
// If IE is used, use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
document.documentElement.doScroll("left");
} catch(e) {
setTimeout( doScrollCheck, 1 );
return;
}
// and execute any waiting functions
jQuery.ready();
} | [
"function",
"doScrollCheck",
"(",
")",
"{",
"if",
"(",
"jQuery",
".",
"isReady",
")",
"{",
"return",
";",
"}",
"try",
"{",
"// If IE is used, use the trick by Diego Perini",
"// http://javascript.nwbox.com/IEContentLoaded/",
"document",
".",
"documentElement",
".",
"doS... | The DOM ready check for Internet Explorer | [
"The",
"DOM",
"ready",
"check",
"for",
"Internet",
"Explorer"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js#L937-L953 | train | Checks if the page is scrolled to the left | [
30522,
3853,
9998,
26775,
14511,
5403,
3600,
1006,
1007,
1063,
2065,
1006,
1046,
4226,
2854,
1012,
2003,
16416,
5149,
1007,
1063,
2709,
1025,
1065,
3046,
1063,
1013,
1013,
2065,
29464,
2003,
2109,
1010,
2224,
1996,
7577,
2011,
5277,
2566,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js | function(oEvent) {
var iOldIndex = this._iDnDColIndex;
var iNewIndex = this._iNewColPos;
// Unbind the event handlers
var $Document = jQuery(document);
$Document.unbind("touchmove.sapUiColumnMove");
$Document.unbind("touchend.sapUiColumnMove");
$Document.unbind("mousemove.sapUiColumnMove");
$Document.unbind("mouseup.sapUiColumnMove");
this._bReorderScroll = false;
// Cleanup globals
this.$().removeClass("sapUiTableDragDrop");
delete this._iDnDColIndex;
delete this._iNewColPos;
jQuery(this._$ReorderGhost).remove();
delete this._$ReorderGhost;
jQuery(this._$ReorderIndicator).remove();
delete this._$ReorderIndicator;
this.$().find(".sapUiTableColReorderFade").removeClass("sapUiTableColReorderFade");
this._enableTextSelection();
// Perform Reordering
TableUtils.Column.moveColumnTo(this.getColumns()[iOldIndex], iNewIndex);
// Re-apply focus
if (this._mTimeouts.reApplyFocusTimerId) {
window.clearTimeout(this._mTimeouts.reApplyFocusTimerId);
}
var that = this;
this._mTimeouts.reApplyFocusTimerId = window.setTimeout(function() {
var iOldFocusedIndex = TableUtils.getFocusedItemInfo(that).cell;
TableUtils.focusItem(that, 0, oEvent);
TableUtils.focusItem(that, iOldFocusedIndex, oEvent);
}, 0);
} | javascript | function(oEvent) {
var iOldIndex = this._iDnDColIndex;
var iNewIndex = this._iNewColPos;
// Unbind the event handlers
var $Document = jQuery(document);
$Document.unbind("touchmove.sapUiColumnMove");
$Document.unbind("touchend.sapUiColumnMove");
$Document.unbind("mousemove.sapUiColumnMove");
$Document.unbind("mouseup.sapUiColumnMove");
this._bReorderScroll = false;
// Cleanup globals
this.$().removeClass("sapUiTableDragDrop");
delete this._iDnDColIndex;
delete this._iNewColPos;
jQuery(this._$ReorderGhost).remove();
delete this._$ReorderGhost;
jQuery(this._$ReorderIndicator).remove();
delete this._$ReorderIndicator;
this.$().find(".sapUiTableColReorderFade").removeClass("sapUiTableColReorderFade");
this._enableTextSelection();
// Perform Reordering
TableUtils.Column.moveColumnTo(this.getColumns()[iOldIndex], iNewIndex);
// Re-apply focus
if (this._mTimeouts.reApplyFocusTimerId) {
window.clearTimeout(this._mTimeouts.reApplyFocusTimerId);
}
var that = this;
this._mTimeouts.reApplyFocusTimerId = window.setTimeout(function() {
var iOldFocusedIndex = TableUtils.getFocusedItemInfo(that).cell;
TableUtils.focusItem(that, 0, oEvent);
TableUtils.focusItem(that, iOldFocusedIndex, oEvent);
}, 0);
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"iOldIndex",
"=",
"this",
".",
"_iDnDColIndex",
";",
"var",
"iNewIndex",
"=",
"this",
".",
"_iNewColPos",
";",
"// Unbind the event handlers",
"var",
"$Document",
"=",
"jQuery",
"(",
"document",
")",
";",
"$Document"... | /*
Ends the column reordering process via drag&drop. | [
"/",
"*",
"Ends",
"the",
"column",
"reordering",
"process",
"via",
"drag&drop",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js#L568-L607 | train | Moves the column to the new position | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
22834,
6392,
22254,
10288,
1027,
2023,
1012,
1035,
8909,
4859,
25778,
22254,
10288,
1025,
13075,
1999,
7974,
22254,
10288,
1027,
2023,
1012,
1035,
1999,
7974,
25778,
6873,
2015,
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... | |
eslint/eslint | lib/rules/no-confusing-arrow.js | checkArrowFunc | function checkArrowFunc(node) {
const body = node.body;
if (isConditional(body) && !(allowParens && astUtils.isParenthesised(sourceCode, body))) {
context.report({
node,
messageId: "confusing",
fix(fixer) {
// if `allowParens` is not set to true dont bother wrapping in parens
return allowParens && fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`);
}
});
}
} | javascript | function checkArrowFunc(node) {
const body = node.body;
if (isConditional(body) && !(allowParens && astUtils.isParenthesised(sourceCode, body))) {
context.report({
node,
messageId: "confusing",
fix(fixer) {
// if `allowParens` is not set to true dont bother wrapping in parens
return allowParens && fixer.replaceText(node.body, `(${sourceCode.getText(node.body)})`);
}
});
}
} | [
"function",
"checkArrowFunc",
"(",
"node",
")",
"{",
"const",
"body",
"=",
"node",
".",
"body",
";",
"if",
"(",
"isConditional",
"(",
"body",
")",
"&&",
"!",
"(",
"allowParens",
"&&",
"astUtils",
".",
"isParenthesised",
"(",
"sourceCode",
",",
"body",
")... | Reports if an arrow function contains an ambiguous conditional.
@param {ASTNode} node - A node to check and report.
@returns {void} | [
"Reports",
"if",
"an",
"arrow",
"function",
"contains",
"an",
"ambiguous",
"conditional",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-confusing-arrow.js#L65-L79 | train | Check if the arrow function is confusing | [
30522,
3853,
4638,
2906,
10524,
11263,
12273,
1006,
13045,
1007,
1063,
9530,
3367,
2303,
1027,
13045,
1012,
2303,
1025,
2065,
1006,
2003,
8663,
27064,
1006,
2303,
1007,
1004,
1004,
999,
1006,
3499,
19362,
6132,
1004,
1004,
2004,
8525,
3775,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/software-update.js | softwareUpdate_waitForCheckFinished | function softwareUpdate_waitForCheckFinished(timeout) {
timeout = timeout ? timeout : gTimeoutUpdateCheck;
this._controller.waitFor(function() {
return this.currentPage != WIZARD_PAGES.checking;
}, "Check for updates has been completed.", timeout, null, this);
} | javascript | function softwareUpdate_waitForCheckFinished(timeout) {
timeout = timeout ? timeout : gTimeoutUpdateCheck;
this._controller.waitFor(function() {
return this.currentPage != WIZARD_PAGES.checking;
}, "Check for updates has been completed.", timeout, null, this);
} | [
"function",
"softwareUpdate_waitForCheckFinished",
"(",
"timeout",
")",
"{",
"timeout",
"=",
"timeout",
"?",
"timeout",
":",
"gTimeoutUpdateCheck",
";",
"this",
".",
"_controller",
".",
"waitFor",
"(",
"function",
"(",
")",
"{",
"return",
"this",
".",
"currentPa... | Wait that check for updates has been finished
@param {number} timeout | [
"Wait",
"that",
"check",
"for",
"updates",
"has",
"been",
"finished"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/software-update.js#L446-L452 | train | Wait until the check has been completed | [
30522,
3853,
4007,
6279,
13701,
1035,
3524,
29278,
5403,
3600,
16294,
13295,
1006,
2051,
5833,
1007,
1063,
2051,
5833,
1027,
2051,
5833,
1029,
2051,
5833,
1024,
14181,
14428,
5833,
6279,
13701,
5403,
30524,
2783,
13704,
999,
1027,
10276,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableAccExtension.js | function(oInfo) {
if (!oInfo) {
return null;
}
if (oInfo._normalized) {
return oInfo;
}
oInfo.role = oInfo.role || "";
oInfo.type = oInfo.type || "";
oInfo.description = oInfo.description || "";
oInfo.enabled = (oInfo.enabled === true || oInfo.enabled === false) ? oInfo.enabled : null;
oInfo.editable = (oInfo.editable === true || oInfo.editable === false) ? oInfo.editable : null;
oInfo.children = oInfo.children || [];
oInfo._normalized = true;
return oInfo;
} | javascript | function(oInfo) {
if (!oInfo) {
return null;
}
if (oInfo._normalized) {
return oInfo;
}
oInfo.role = oInfo.role || "";
oInfo.type = oInfo.type || "";
oInfo.description = oInfo.description || "";
oInfo.enabled = (oInfo.enabled === true || oInfo.enabled === false) ? oInfo.enabled : null;
oInfo.editable = (oInfo.editable === true || oInfo.editable === false) ? oInfo.editable : null;
oInfo.children = oInfo.children || [];
oInfo._normalized = true;
return oInfo;
} | [
"function",
"(",
"oInfo",
")",
"{",
"if",
"(",
"!",
"oInfo",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"oInfo",
".",
"_normalized",
")",
"{",
"return",
"oInfo",
";",
"}",
"oInfo",
".",
"role",
"=",
"oInfo",
".",
"role",
"||",
"\"\"",
";",
... | /*
Normalizes the given acc info object and ensures that all the defaults are set. | [
"/",
"*",
"Normalizes",
"the",
"given",
"acc",
"info",
"object",
"and",
"ensures",
"that",
"all",
"the",
"defaults",
"are",
"set",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccExtension.js#L51-L69 | train | Converts an object with properties | [
30522,
3853,
1006,
1051,
2378,
14876,
1007,
1063,
2065,
1006,
999,
1051,
2378,
14876,
1007,
1063,
2709,
19701,
1025,
1065,
2065,
1006,
1051,
2378,
14876,
1012,
1035,
3671,
3550,
1007,
1063,
2709,
1051,
2378,
14876,
1025,
1065,
1051,
2378,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/search/FindReplace.js | _updateFindBarWithMatchInfo | function _updateFindBarWithMatchInfo(state, matchRange, searchBackwards) {
// Bail if there is no result set.
if (!state.foundAny) {
return;
}
if (findBar) {
if (state.matchIndex === -1) {
state.matchIndex = _.findIndex(state.resultSet, matchRange);
} else {
state.matchIndex = searchBackwards ? state.matchIndex - 1 : state.matchIndex + 1;
// Adjust matchIndex for modulo wraparound
state.matchIndex = (state.matchIndex + state.resultSet.length) % state.resultSet.length;
// Confirm that we find the right matchIndex. If not, then search
// matchRange in the entire resultSet.
if (!_.isEqual(state.resultSet[state.matchIndex], matchRange)) {
state.matchIndex = _.findIndex(state.resultSet, matchRange);
}
}
console.assert(state.matchIndex !== -1);
if (state.matchIndex !== -1) {
// Convert to 1-based by adding one before showing the index.
findBar.showFindCount(StringUtils.format(Strings.FIND_MATCH_INDEX,
state.matchIndex + 1, state.resultSet.length));
}
}
} | javascript | function _updateFindBarWithMatchInfo(state, matchRange, searchBackwards) {
// Bail if there is no result set.
if (!state.foundAny) {
return;
}
if (findBar) {
if (state.matchIndex === -1) {
state.matchIndex = _.findIndex(state.resultSet, matchRange);
} else {
state.matchIndex = searchBackwards ? state.matchIndex - 1 : state.matchIndex + 1;
// Adjust matchIndex for modulo wraparound
state.matchIndex = (state.matchIndex + state.resultSet.length) % state.resultSet.length;
// Confirm that we find the right matchIndex. If not, then search
// matchRange in the entire resultSet.
if (!_.isEqual(state.resultSet[state.matchIndex], matchRange)) {
state.matchIndex = _.findIndex(state.resultSet, matchRange);
}
}
console.assert(state.matchIndex !== -1);
if (state.matchIndex !== -1) {
// Convert to 1-based by adding one before showing the index.
findBar.showFindCount(StringUtils.format(Strings.FIND_MATCH_INDEX,
state.matchIndex + 1, state.resultSet.length));
}
}
} | [
"function",
"_updateFindBarWithMatchInfo",
"(",
"state",
",",
"matchRange",
",",
"searchBackwards",
")",
"{",
"// Bail if there is no result set.",
"if",
"(",
"!",
"state",
".",
"foundAny",
")",
"{",
"return",
";",
"}",
"if",
"(",
"findBar",
")",
"{",
"if",
"(... | @private
Show the current match index by finding matchRange in the resultSet stored
in the search state if this is the first call for a new search query. For
subsequent calls, just compare matchRange with the next match in the resultSet
based on the search direction and show the next match if they are the same.
If not, then find the match index by searching matchRange in the entire resultSet.
@param {!SearchState} state The search state that has the array of search result
@param {!{from: {line: number, ch: number}, to: {line: number, ch: number}}} matchRange - the range of current match
@param {!boolean} searchBackwards true if searching backwards | [
"@private",
"Show",
"the",
"current",
"match",
"index",
"by",
"finding",
"matchRange",
"in",
"the",
"resultSet",
"stored",
"in",
"the",
"search",
"state",
"if",
"this",
"is",
"the",
"first",
"call",
"for",
"a",
"new",
"search",
"query",
".",
"For",
"subseq... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindReplace.js#L137-L165 | train | Update find bar with match info | [
30522,
3853,
1035,
10651,
16294,
18939,
2906,
24415,
18900,
17231,
14876,
1006,
2110,
1010,
2674,
24388,
2063,
1010,
3945,
5963,
7652,
2015,
1007,
1063,
1013,
1013,
15358,
2065,
2045,
2003,
2053,
2765,
2275,
1012,
2065,
1006,
999,
2110,
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... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(node) {
assertRangeValid(this);
var parent = node.parentNode;
var nodeIndex = getNodeIndex(node);
if (!parent) {
throw new DOMException("NOT_FOUND_ERR");
}
var startComparison = this.comparePoint(parent, nodeIndex),
endComparison = this.comparePoint(parent, nodeIndex + 1);
if (startComparison < 0) { // Node starts before
return (endComparison > 0) ? n_b_a : n_b;
} else {
return (endComparison > 0) ? n_a : n_i;
}
} | javascript | function(node) {
assertRangeValid(this);
var parent = node.parentNode;
var nodeIndex = getNodeIndex(node);
if (!parent) {
throw new DOMException("NOT_FOUND_ERR");
}
var startComparison = this.comparePoint(parent, nodeIndex),
endComparison = this.comparePoint(parent, nodeIndex + 1);
if (startComparison < 0) { // Node starts before
return (endComparison > 0) ? n_b_a : n_b;
} else {
return (endComparison > 0) ? n_a : n_i;
}
} | [
"function",
"(",
"node",
")",
"{",
"assertRangeValid",
"(",
"this",
")",
";",
"var",
"parent",
"=",
"node",
".",
"parentNode",
";",
"var",
"nodeIndex",
"=",
"getNodeIndex",
"(",
"node",
")",
";",
"if",
"(",
"!",
"parent",
")",
"{",
"throw",
"new",
"D... | The methods below are all non-standard. The following batch were introduced by Mozilla but have since been removed from Mozilla. | [
"The",
"methods",
"below",
"are",
"all",
"non",
"-",
"standard",
".",
"The",
"following",
"batch",
"were",
"introduced",
"by",
"Mozilla",
"but",
"have",
"since",
"been",
"removed",
"from",
"Mozilla",
"."
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L1622-L1640 | train | Returns the index of the node in the tree | [
30522,
3853,
1006,
13045,
1007,
1063,
20865,
24388,
13331,
21273,
1006,
2023,
1007,
1025,
13075,
6687,
1027,
13045,
1012,
6687,
3630,
3207,
1025,
13075,
13045,
22254,
10288,
1027,
2131,
3630,
3207,
22254,
10288,
1006,
13045,
1007,
1025,
2065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | JavascriptXPathEngine | function JavascriptXPathEngine() {
// private
var engineDoc = document;
// public
// Override
this.isAvailable = function() { return true; };
// Override
this.selectNodes = function(xpath, contextNode, namespaceResolver) {
if (contextNode != this.doc) {
// Regarding use of the second argument to document.evaluate():
// http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/a59ce20639c74ba1/a9d9f53e88e5ebb5
xpath = '.' + xpath;
}
var nodes = [];
try {
// When using the new and faster javascript-xpath library, we'll
// use the TestRunner's document object, not the App-Under-Test's
// document. The new library only modifies the TestRunner document
// with the new functionality.
var xpathResult = engineDoc.evaluate(xpath, contextNode,
namespaceResolver, 0, null);
}
catch (e) {
var msg = extractExceptionMessage(e);
throw new SeleniumError("Invalid xpath [1]: " + msg);
}
finally {
if (xpathResult == null) {
// If the result is null, we should still throw an Error.
throw new SeleniumError("Invalid xpath [2]: " + xpath);
}
}
var node = xpathResult.iterateNext();
while (node) {
nodes.push(node);
node = xpathResult.iterateNext();
}
return nodes;
};
} | javascript | function JavascriptXPathEngine() {
// private
var engineDoc = document;
// public
// Override
this.isAvailable = function() { return true; };
// Override
this.selectNodes = function(xpath, contextNode, namespaceResolver) {
if (contextNode != this.doc) {
// Regarding use of the second argument to document.evaluate():
// http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/a59ce20639c74ba1/a9d9f53e88e5ebb5
xpath = '.' + xpath;
}
var nodes = [];
try {
// When using the new and faster javascript-xpath library, we'll
// use the TestRunner's document object, not the App-Under-Test's
// document. The new library only modifies the TestRunner document
// with the new functionality.
var xpathResult = engineDoc.evaluate(xpath, contextNode,
namespaceResolver, 0, null);
}
catch (e) {
var msg = extractExceptionMessage(e);
throw new SeleniumError("Invalid xpath [1]: " + msg);
}
finally {
if (xpathResult == null) {
// If the result is null, we should still throw an Error.
throw new SeleniumError("Invalid xpath [2]: " + xpath);
}
}
var node = xpathResult.iterateNext();
while (node) {
nodes.push(node);
node = xpathResult.iterateNext();
}
return nodes;
};
} | [
"function",
"JavascriptXPathEngine",
"(",
")",
"{",
"// private",
"var",
"engineDoc",
"=",
"document",
";",
"// public",
"// Override",
"this",
".",
"isAvailable",
"=",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
";",
"// Override",
"this",
".",
"... | Implements XPathEngine. | [
"Implements",
"XPathEngine",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L1237-L1283 | train | The JavascriptXPathEngine class | [
30522,
3853,
9262,
22483,
2595,
15069,
13159,
3170,
1006,
1007,
1063,
1013,
1013,
2797,
13075,
21235,
10085,
1027,
6254,
1025,
1013,
1013,
2270,
1013,
1013,
2058,
15637,
2023,
1012,
18061,
3567,
11733,
3468,
1027,
3853,
1006,
1007,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js | function (oInterface, vRawValue) {
if (arguments.length === 1) {
vRawValue = oInterface.getObject("");
}
var oResult = Basics.followPath(oInterface, vRawValue);
return oResult
? "{" + oResult.navigationProperties.join("/") + "}"
: "";
} | javascript | function (oInterface, vRawValue) {
if (arguments.length === 1) {
vRawValue = oInterface.getObject("");
}
var oResult = Basics.followPath(oInterface, vRawValue);
return oResult
? "{" + oResult.navigationProperties.join("/") + "}"
: "";
} | [
"function",
"(",
"oInterface",
",",
"vRawValue",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"vRawValue",
"=",
"oInterface",
".",
"getObject",
"(",
"\"\"",
")",
";",
"}",
"var",
"oResult",
"=",
"Basics",
".",
"followPath",
"(... | A formatter function to be used in a complex binding inside an XML template view
in order to interpret OData V4 annotations. It knows about the following dynamic
expressions:
<ul>
<li>"14.5.2 Expression edm:AnnotationPath"</li>
<li>"14.5.11 Expression edm:NavigationPropertyPath"</li>
<li>"14.5.12 Expression edm:Path"</li>
<li>"14.5.13 Expression edm:PropertyPath"</li>
</ul>
It returns a binding expression for a navigation path in an OData model, starting at
an entity.
Currently supports navigation properties. Term casts and annotations of
navigation properties terminate the navigation path.
Examples:
<pre>
<template:if test="{path: 'facet>Target', formatter: 'sap.ui.model.odata.AnnotationHelper.getNavigationPath'}">
<form:SimpleForm binding="{path: 'facet>Target', formatter: 'sap.ui.model.odata.AnnotationHelper.getNavigationPath'}" />
</template:if>
</pre>
@param {sap.ui.core.util.XMLPreprocessor.IContext|sap.ui.model.Context} oInterface
the callback interface related to the current formatter call
@param {any} [vRawValue]
the raw value from the meta model, e.g. <code>{AnnotationPath :
"ToSupplier/@com.sap.vocabularies.Communication.v1.Address"}</code> or <code>
{AnnotationPath : "@com.sap.vocabularies.UI.v1.FieldGroup#Dimensions"}</code>;
embedded within an entity set or entity type;
<ul>
<li>if this function is used as formatter the value
is provided by the framework</li>
<li>if this function is called directly, provide the parameter only if it is
already calculated</li>
<li>if the parameter is omitted, it is calculated automatically through
<code>oInterface.getObject("")</code></li>
</ul>
@returns {string}
the resulting string value to write into the processed XML, e.g. "{ToSupplier}"
or "{}" (in case no navigation is needed); returns "" in case the navigation path
cannot be determined (this is treated as falsy in <code>template:if</code>
statements!)
@public | [
"A",
"formatter",
"function",
"to",
"be",
"used",
"in",
"a",
"complex",
"binding",
"inside",
"an",
"XML",
"template",
"view",
"in",
"order",
"to",
"interpret",
"OData",
"V4",
"annotations",
".",
"It",
"knows",
"about",
"the",
"following",
"dynamic",
"express... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js#L330-L339 | train | Returns the index of the property in the given interface. | [
30522,
3853,
1006,
1051,
18447,
2121,
12172,
1010,
27830,
10376,
10175,
5657,
1007,
1063,
2065,
1006,
9918,
1012,
3091,
1027,
1027,
1027,
1015,
1007,
1063,
27830,
10376,
10175,
5657,
1027,
1051,
18447,
2121,
12172,
1012,
2131,
16429,
20614,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dcloudio/mui | examples/hello-mui/js/mui.lazyload.js | function(load) {
var value, loading, handles = [],
h;
return function(handle) {
if(!loading) {
loading = true;
load(function(v) {
value = v;
while(h = handles.shift()) {
try {
h && h.apply(null, [value]);
} catch(e) {
setTimeout(function() {
throw e;
}, 0)
}
}
})
}
if(value) {
handle && handle.apply(null, [value]);
return value;
}
handle && handles.push(handle);
return value;
}
} | javascript | function(load) {
var value, loading, handles = [],
h;
return function(handle) {
if(!loading) {
loading = true;
load(function(v) {
value = v;
while(h = handles.shift()) {
try {
h && h.apply(null, [value]);
} catch(e) {
setTimeout(function() {
throw e;
}, 0)
}
}
})
}
if(value) {
handle && handle.apply(null, [value]);
return value;
}
handle && handles.push(handle);
return value;
}
} | [
"function",
"(",
"load",
")",
"{",
"var",
"value",
",",
"loading",
",",
"handles",
"=",
"[",
"]",
",",
"h",
";",
"return",
"function",
"(",
"handle",
")",
"{",
"if",
"(",
"!",
"loading",
")",
"{",
"loading",
"=",
"true",
";",
"load",
"(",
"functi... | 根据加载函数实现加载器
@param {Function} load 加载函数
@returns {Function} 加载器 | [
"根据加载函数实现加载器"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.lazyload.js#L49-L75 | train | Load the value of a key | [
30522,
3853,
1006,
7170,
1007,
1063,
13075,
3643,
1010,
10578,
1010,
16024,
1027,
1031,
1033,
1010,
1044,
1025,
2709,
3853,
1006,
5047,
1007,
1063,
2065,
1006,
999,
10578,
1007,
1063,
10578,
1027,
2995,
1025,
7170,
1006,
3853,
1006,
1058,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | function( from, to, unit ) {
this.startTime = now();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
this.now = this.start;
this.pos = this.state = 0;
var self = this;
function t( gotoEnd ) {
return self.step(gotoEnd);
}
t.elem = this.elem;
if ( t() && jQuery.timers.push(t) && !timerId ) {
timerId = setInterval(jQuery.fx.tick, 13);
}
} | javascript | function( from, to, unit ) {
this.startTime = now();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
this.now = this.start;
this.pos = this.state = 0;
var self = this;
function t( gotoEnd ) {
return self.step(gotoEnd);
}
t.elem = this.elem;
if ( t() && jQuery.timers.push(t) && !timerId ) {
timerId = setInterval(jQuery.fx.tick, 13);
}
} | [
"function",
"(",
"from",
",",
"to",
",",
"unit",
")",
"{",
"this",
".",
"startTime",
"=",
"now",
"(",
")",
";",
"this",
".",
"start",
"=",
"from",
";",
"this",
".",
"end",
"=",
"to",
";",
"this",
".",
"unit",
"=",
"unit",
"||",
"this",
".",
"... | Start an animation from one number to another | [
"Start",
"an",
"animation",
"from",
"one",
"number",
"to",
"another"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L8192-L8210 | train | set the start and end values | [
30522,
3853,
1006,
2013,
1010,
2000,
1010,
3131,
1007,
1063,
2023,
1012,
2707,
7292,
1027,
2085,
1006,
1007,
1025,
2023,
1012,
2707,
1027,
2013,
1025,
2023,
1012,
2203,
1027,
2000,
1025,
2023,
1012,
3131,
1027,
3131,
1064,
1064,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.