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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TryGhost/Ghost | core/server/models/base/index.js | permittedOptions | function permittedOptions(methodName) {
const baseOptions = ['context', 'withRelated'];
const extraOptions = ['transacting', 'importing', 'forUpdate', 'migrating'];
switch (methodName) {
case 'toJSON':
return baseOptions.concat('shallow', 'columns', 'previous');
case 'destroy':
return baseOptions.concat(extraOptions, ['id', 'destroyBy', 'require']);
case 'edit':
return baseOptions.concat(extraOptions, ['id', 'require']);
case 'findOne':
return baseOptions.concat(extraOptions, ['columns', 'require']);
case 'findAll':
return baseOptions.concat(extraOptions, ['columns']);
case 'findPage':
return baseOptions.concat(extraOptions, ['filter', 'order', 'page', 'limit', 'columns']);
default:
return baseOptions.concat(extraOptions);
}
} | javascript | function permittedOptions(methodName) {
const baseOptions = ['context', 'withRelated'];
const extraOptions = ['transacting', 'importing', 'forUpdate', 'migrating'];
switch (methodName) {
case 'toJSON':
return baseOptions.concat('shallow', 'columns', 'previous');
case 'destroy':
return baseOptions.concat(extraOptions, ['id', 'destroyBy', 'require']);
case 'edit':
return baseOptions.concat(extraOptions, ['id', 'require']);
case 'findOne':
return baseOptions.concat(extraOptions, ['columns', 'require']);
case 'findAll':
return baseOptions.concat(extraOptions, ['columns']);
case 'findPage':
return baseOptions.concat(extraOptions, ['filter', 'order', 'page', 'limit', 'columns']);
default:
return baseOptions.concat(extraOptions);
}
} | [
"function",
"permittedOptions",
"(",
"methodName",
")",
"{",
"const",
"baseOptions",
"=",
"[",
"'context'",
",",
"'withRelated'",
"]",
";",
"const",
"extraOptions",
"=",
"[",
"'transacting'",
",",
"'importing'",
",",
"'forUpdate'",
",",
"'migrating'",
"]",
";",
... | Returns an array of keys permitted in every method's `options` hash.
Can be overridden and added to by a model's `permittedOptions` method.
importing: is used when import a JSON file or when migrating the database
@return {Object} Keys allowed in the `options` hash of every model's method. | [
"Returns",
"an",
"array",
"of",
"keys",
"permitted",
"in",
"every",
"method",
"s",
"options",
"hash",
".",
"Can",
"be",
"overridden",
"and",
"added",
"to",
"by",
"a",
"model",
"s",
"permittedOptions",
"method",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L677-L697 | train | permittedOptions - returns an array of options for a method | [
30522,
3853,
7936,
7361,
9285,
1006,
4118,
18442,
1007,
1063,
9530,
3367,
2918,
7361,
9285,
1027,
1031,
1005,
6123,
1005,
30524,
22578,
2239,
1005,
1024,
2709,
2918,
7361,
9285,
1012,
9530,
11266,
1006,
1005,
8467,
1005,
1010,
1005,
7753,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
websockets/ws | lib/extension.js | format | function format(extensions) {
return Object.keys(extensions)
.map((extension) => {
let configurations = extensions[extension];
if (!Array.isArray(configurations)) configurations = [configurations];
return configurations
.map((params) => {
return [extension]
.concat(
Object.keys(params).map((k) => {
let values = params[k];
if (!Array.isArray(values)) values = [values];
return values
.map((v) => (v === true ? k : `${k}=${v}`))
.join('; ');
})
)
.join('; ');
})
.join(', ');
})
.join(', ');
} | javascript | function format(extensions) {
return Object.keys(extensions)
.map((extension) => {
let configurations = extensions[extension];
if (!Array.isArray(configurations)) configurations = [configurations];
return configurations
.map((params) => {
return [extension]
.concat(
Object.keys(params).map((k) => {
let values = params[k];
if (!Array.isArray(values)) values = [values];
return values
.map((v) => (v === true ? k : `${k}=${v}`))
.join('; ');
})
)
.join('; ');
})
.join(', ');
})
.join(', ');
} | [
"function",
"format",
"(",
"extensions",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"extensions",
")",
".",
"map",
"(",
"(",
"extension",
")",
"=>",
"{",
"let",
"configurations",
"=",
"extensions",
"[",
"extension",
"]",
";",
"if",
"(",
"!",
"Arra... | Builds the `Sec-WebSocket-Extensions` header field value.
@param {Object} extensions The map of extensions and parameters to format
@return {String} A string representing the given object
@public | [
"Builds",
"the",
"Sec",
"-",
"WebSocket",
"-",
"Extensions",
"header",
"field",
"value",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/extension.js#L199-L221 | train | Format the extensions object | [
30522,
3853,
4289,
1006,
14305,
1007,
1063,
2709,
4874,
1012,
6309,
1006,
14305,
1007,
1012,
4949,
1006,
1006,
5331,
1007,
1027,
1028,
1063,
2292,
22354,
1027,
14305,
1031,
5331,
1033,
1025,
2065,
1006,
999,
9140,
1012,
18061,
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... |
angular/material | src/core/services/layout/layout.js | function(element) {
if (!config.enabled) return angular.noop;
// Re-add the cloak
element.addClass(className);
return function(scope, element) {
// Wait while layout injectors configure, then uncloak
// NOTE: $rAF does not delay enough... and this is a 1x-only event,
// $timeout is acceptable.
$timeout(function(){
element.removeClass(className);
}, 10, false);
};
} | javascript | function(element) {
if (!config.enabled) return angular.noop;
// Re-add the cloak
element.addClass(className);
return function(scope, element) {
// Wait while layout injectors configure, then uncloak
// NOTE: $rAF does not delay enough... and this is a 1x-only event,
// $timeout is acceptable.
$timeout(function(){
element.removeClass(className);
}, 10, false);
};
} | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"config",
".",
"enabled",
")",
"return",
"angular",
".",
"noop",
";",
"// Re-add the cloak",
"element",
".",
"addClass",
"(",
"className",
")",
";",
"return",
"function",
"(",
"scope",
",",
"element",
... | run after normal ng-cloak | [
"run",
"after",
"normal",
"ng",
"-",
"cloak"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/layout/layout.js#L220-L234 | train | Returns a function that will add the cloak
ether class to the element | [
30522,
3853,
1006,
5783,
1007,
1063,
2065,
1006,
999,
9530,
8873,
2290,
1012,
9124,
1007,
2709,
16108,
1012,
2053,
7361,
1025,
1013,
1013,
2128,
1011,
5587,
1996,
11965,
5783,
1012,
5587,
26266,
1006,
2465,
18442,
1007,
1025,
2709,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GoogleChrome/puppeteer | experimental/puppeteer-firefox/lib/Launcher.js | killFirefox | function killFirefox() {
helper.removeEventListeners(listeners);
if (firefoxProcess.pid && !firefoxProcess.killed && !firefoxClosed) {
// Force kill chrome.
try {
if (process.platform === 'win32')
childProcess.execSync(`taskkill /pid ${firefoxProcess.pid} /T /F`);
else
process.kill(-firefoxProcess.pid, 'SIGKILL');
} catch (e) {
// the process might have already stopped
}
}
// Attempt to remove temporary profile directory to avoid littering.
try {
removeFolder.sync(temporaryProfileDir);
} catch (e) { }
} | javascript | function killFirefox() {
helper.removeEventListeners(listeners);
if (firefoxProcess.pid && !firefoxProcess.killed && !firefoxClosed) {
// Force kill chrome.
try {
if (process.platform === 'win32')
childProcess.execSync(`taskkill /pid ${firefoxProcess.pid} /T /F`);
else
process.kill(-firefoxProcess.pid, 'SIGKILL');
} catch (e) {
// the process might have already stopped
}
}
// Attempt to remove temporary profile directory to avoid littering.
try {
removeFolder.sync(temporaryProfileDir);
} catch (e) { }
} | [
"function",
"killFirefox",
"(",
")",
"{",
"helper",
".",
"removeEventListeners",
"(",
"listeners",
")",
";",
"if",
"(",
"firefoxProcess",
".",
"pid",
"&&",
"!",
"firefoxProcess",
".",
"killed",
"&&",
"!",
"firefoxClosed",
")",
"{",
"// Force kill chrome.",
"tr... | This method has to be sync to be used as 'exit' event handler. | [
"This",
"method",
"has",
"to",
"be",
"sync",
"to",
"be",
"used",
"as",
"exit",
"event",
"handler",
"."
] | 13f73b5b3a279f18313630e0f58c3c17fb0cef66 | https://github.com/GoogleChrome/puppeteer/blob/13f73b5b3a279f18313630e0f58c3c17fb0cef66/experimental/puppeteer-firefox/lib/Launcher.js#L186-L203 | train | Kills the chrome process | [
30522,
3853,
3102,
10273,
14876,
2595,
1006,
1007,
1063,
2393,
2121,
1012,
6366,
18697,
3372,
9863,
24454,
2015,
1006,
13810,
1007,
1025,
2065,
1006,
2543,
14876,
2595,
21572,
9623,
2015,
1012,
14255,
2094,
1004,
1004,
999,
2543,
14876,
259... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/models/relations/authors.js | onCreating | function onCreating(model, attrs, options) {
if (!model.get('author_id')) {
if (model.get('authors')) {
model.set('author_id', model.get('authors')[0].id);
} else {
model.set('author_id', this.contextUser(options));
}
}
if (!model.get('authors')) {
model.set('authors', [{
id: model.get('author_id')
}]);
}
return this._handleOptions('onCreating')(model, attrs, options);
} | javascript | function onCreating(model, attrs, options) {
if (!model.get('author_id')) {
if (model.get('authors')) {
model.set('author_id', model.get('authors')[0].id);
} else {
model.set('author_id', this.contextUser(options));
}
}
if (!model.get('authors')) {
model.set('authors', [{
id: model.get('author_id')
}]);
}
return this._handleOptions('onCreating')(model, attrs, options);
} | [
"function",
"onCreating",
"(",
"model",
",",
"attrs",
",",
"options",
")",
"{",
"if",
"(",
"!",
"model",
".",
"get",
"(",
"'author_id'",
")",
")",
"{",
"if",
"(",
"model",
".",
"get",
"(",
"'authors'",
")",
")",
"{",
"model",
".",
"set",
"(",
"'a... | NOTE: sending `post.author = {}` was always ignored [unsupported] | [
"NOTE",
":",
"sending",
"post",
".",
"author",
"=",
"{}",
"was",
"always",
"ignored",
"[",
"unsupported",
"]"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/relations/authors.js#L82-L98 | train | onCreating - Callback for creating a new record | [
30522,
3853,
2006,
16748,
5844,
1006,
2944,
1010,
2012,
16344,
2015,
1010,
7047,
1007,
1063,
2065,
1006,
999,
2944,
1012,
2131,
1006,
1005,
3166,
1035,
8909,
1005,
1007,
1007,
1063,
2065,
1006,
2944,
1012,
2131,
1006,
1005,
6048,
1005,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/core/component.js | function (schemaAddon) {
var extendedSchema;
// Clone base schema.
extendedSchema = utils.extend({}, components[this.name].schema);
// Extend base schema with new schema chunk.
utils.extend(extendedSchema, schemaAddon);
this.schema = processSchema(extendedSchema);
this.el.emit('schemachanged', this.evtDetail);
} | javascript | function (schemaAddon) {
var extendedSchema;
// Clone base schema.
extendedSchema = utils.extend({}, components[this.name].schema);
// Extend base schema with new schema chunk.
utils.extend(extendedSchema, schemaAddon);
this.schema = processSchema(extendedSchema);
this.el.emit('schemachanged', this.evtDetail);
} | [
"function",
"(",
"schemaAddon",
")",
"{",
"var",
"extendedSchema",
";",
"// Clone base schema.",
"extendedSchema",
"=",
"utils",
".",
"extend",
"(",
"{",
"}",
",",
"components",
"[",
"this",
".",
"name",
"]",
".",
"schema",
")",
";",
"// Extend base schema wit... | Extend schema of component given a partial schema.
Some components might want to mutate their schema based on certain properties.
e.g., Material component changes its schema based on `shader` to account for different
uniforms
@param {object} schemaAddon - Schema chunk that extend base schema. | [
"Extend",
"schema",
"of",
"component",
"given",
"a",
"partial",
"schema",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/component.js#L454-L462 | train | Merge schema with schemaAddon | [
30522,
3853,
1006,
8040,
28433,
4215,
5280,
1007,
1063,
13075,
3668,
22842,
2863,
1025,
1013,
1013,
17598,
2918,
8040,
28433,
1012,
3668,
22842,
2863,
1027,
21183,
12146,
1012,
7949,
1006,
1063,
1065,
1010,
6177,
1031,
2023,
1012,
2171,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onLinkReauthVerifyPhoneNumber | function onLinkReauthVerifyPhoneNumber() {
var phoneNumber = $('#link-reauth-phone-number').val();
var provider = new firebase.auth.PhoneAuthProvider(auth);
// Clear existing reCAPTCHA as an existing reCAPTCHA could be targeted for a
// sign-in operation.
clearApplicationVerifier();
// Initialize a reCAPTCHA application verifier.
makeApplicationVerifier('link-reauth-verify-phone-number');
provider.verifyPhoneNumber(phoneNumber, applicationVerifier)
.then(function(verificationId) {
clearApplicationVerifier();
$('#link-reauth-phone-verification-id').val(verificationId);
alertSuccess('Phone verification sent!');
}, function(error) {
clearApplicationVerifier();
onAuthError(error);
});
} | javascript | function onLinkReauthVerifyPhoneNumber() {
var phoneNumber = $('#link-reauth-phone-number').val();
var provider = new firebase.auth.PhoneAuthProvider(auth);
// Clear existing reCAPTCHA as an existing reCAPTCHA could be targeted for a
// sign-in operation.
clearApplicationVerifier();
// Initialize a reCAPTCHA application verifier.
makeApplicationVerifier('link-reauth-verify-phone-number');
provider.verifyPhoneNumber(phoneNumber, applicationVerifier)
.then(function(verificationId) {
clearApplicationVerifier();
$('#link-reauth-phone-verification-id').val(verificationId);
alertSuccess('Phone verification sent!');
}, function(error) {
clearApplicationVerifier();
onAuthError(error);
});
} | [
"function",
"onLinkReauthVerifyPhoneNumber",
"(",
")",
"{",
"var",
"phoneNumber",
"=",
"$",
"(",
"'#link-reauth-phone-number'",
")",
".",
"val",
"(",
")",
";",
"var",
"provider",
"=",
"new",
"firebase",
".",
"auth",
".",
"PhoneAuthProvider",
"(",
"auth",
")",
... | Sends a phone number verification code for linking or reauth. | [
"Sends",
"a",
"phone",
"number",
"verification",
"code",
"for",
"linking",
"or",
"reauth",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L469-L486 | train | Verify a phone number | [
30522,
3853,
2006,
13767,
16416,
14317,
6299,
8757,
9864,
19172,
5677,
1006,
1007,
1063,
13075,
3042,
19172,
5677,
1027,
1002,
1006,
1005,
1001,
4957,
1011,
2128,
4887,
2705,
1011,
3042,
1011,
2193,
1005,
1007,
1012,
11748,
1006,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/NativeApp.js | closeLiveBrowser | function closeLiveBrowser(pid) {
var result = new $.Deferred();
if (isNaN(pid)) {
pid = 0;
}
brackets.app.closeLiveBrowser(function (err) {
if (!err) {
var i = liveBrowserOpenedPIDs.indexOf(pid);
if (i !== -1) {
liveBrowserOpenedPIDs.splice(i, 1);
}
result.resolve();
} else {
result.reject(_browserErrToFileError(err));
}
}, pid);
return result.promise();
} | javascript | function closeLiveBrowser(pid) {
var result = new $.Deferred();
if (isNaN(pid)) {
pid = 0;
}
brackets.app.closeLiveBrowser(function (err) {
if (!err) {
var i = liveBrowserOpenedPIDs.indexOf(pid);
if (i !== -1) {
liveBrowserOpenedPIDs.splice(i, 1);
}
result.resolve();
} else {
result.reject(_browserErrToFileError(err));
}
}, pid);
return result.promise();
} | [
"function",
"closeLiveBrowser",
"(",
"pid",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"if",
"(",
"isNaN",
"(",
"pid",
")",
")",
"{",
"pid",
"=",
"0",
";",
"}",
"brackets",
".",
"app",
".",
"closeLiveBrowser",
"(",
... | closeLiveBrowser
@return {$.Promise} | [
"closeLiveBrowser"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/NativeApp.js#L73-L92 | train | Close Live Browser | [
30522,
3853,
2485,
3669,
3726,
12618,
9333,
2121,
1006,
14255,
2094,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
2065,
1006,
3475,
2319,
1006,
14255,
2094,
1007,
1007,
1063,
14255,
2094,
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... |
facebook/relay | packages/relay-compiler/core/GraphQLDerivedFromMetadata.js | getReaderSourceDefinitionName | function getReaderSourceDefinitionName(node: GeneratedNode): string {
const [name, derivedFrom] =
node.kind === 'Request'
? [node.params.name, node.params.metadata?.derivedFrom]
: node.kind === 'SplitOperation'
? [node.name, node.metadata?.derivedFrom]
: [node.name, null];
return typeof derivedFrom === 'string' ? derivedFrom : name;
} | javascript | function getReaderSourceDefinitionName(node: GeneratedNode): string {
const [name, derivedFrom] =
node.kind === 'Request'
? [node.params.name, node.params.metadata?.derivedFrom]
: node.kind === 'SplitOperation'
? [node.name, node.metadata?.derivedFrom]
: [node.name, null];
return typeof derivedFrom === 'string' ? derivedFrom : name;
} | [
"function",
"getReaderSourceDefinitionName",
"(",
"node",
":",
"GeneratedNode",
")",
":",
"string",
"{",
"const",
"[",
"name",
",",
"derivedFrom",
"]",
"=",
"node",
".",
"kind",
"===",
"'Request'",
"?",
"[",
"node",
".",
"params",
".",
"name",
",",
"node",... | Helpers to retieve the name of the document from which the input derives:
this is either the name of the input itself (if it is not a derived node)
or the metadata.derivedFrom property for derived nodes.
Version for generated nodes | [
"Helpers",
"to",
"retieve",
"the",
"name",
"of",
"the",
"document",
"from",
"which",
"the",
"input",
"derives",
":",
"this",
"is",
"either",
"the",
"name",
"of",
"the",
"input",
"itself",
"(",
"if",
"it",
"is",
"not",
"a",
"derived",
"node",
")",
"or",... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/GraphQLDerivedFromMetadata.js#L23-L31 | train | Returns the name of the reader source definition | [
30522,
3853,
2131,
16416,
13375,
8162,
22119,
16294,
22753,
18442,
1006,
13045,
1024,
7013,
3630,
3207,
1007,
1024,
5164,
1063,
9530,
3367,
1031,
2171,
1010,
5173,
19699,
5358,
1033,
1027,
13045,
1012,
2785,
1027,
1027,
1027,
1005,
5227,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/JSUtils/ScopeManager.js | handleEditorChange | function handleEditorChange(session, document, previousDocument) {
if (addFilesPromise === null) {
doEditorChange(session, document, previousDocument);
} else {
addFilesPromise.done(function () {
doEditorChange(session, document, previousDocument);
});
}
} | javascript | function handleEditorChange(session, document, previousDocument) {
if (addFilesPromise === null) {
doEditorChange(session, document, previousDocument);
} else {
addFilesPromise.done(function () {
doEditorChange(session, document, previousDocument);
});
}
} | [
"function",
"handleEditorChange",
"(",
"session",
",",
"document",
",",
"previousDocument",
")",
"{",
"if",
"(",
"addFilesPromise",
"===",
"null",
")",
"{",
"doEditorChange",
"(",
"session",
",",
"document",
",",
"previousDocument",
")",
";",
"}",
"else",
"{",... | Called each time a new editor becomes active.
@param {Session} session - the active hinting session (TODO: currently unused by doEditorChange())
@param {!Document} document - the document of the editor that has changed
@param {?Document} previousDocument - the document of the editor is changing from | [
"Called",
"each",
"time",
"a",
"new",
"editor",
"becomes",
"active",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1319-L1327 | train | Handle editor change | [
30522,
3853,
5047,
2098,
15660,
22305,
2063,
1006,
5219,
1010,
6254,
1010,
3025,
3527,
24894,
4765,
1007,
1063,
2065,
1006,
5587,
8873,
4244,
21572,
28732,
1027,
1027,
1027,
19701,
1007,
1063,
18629,
23194,
2953,
22305,
2063,
1006,
5219,
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... |
apache/incubator-echarts | src/chart/boxplot/boxplotLayout.js | groupSeriesByAxis | function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
result[idx].seriesModels.push(seriesModel);
});
return result;
} | javascript | function groupSeriesByAxis(ecModel) {
var result = [];
var axisList = [];
ecModel.eachSeriesByType('boxplot', function (seriesModel) {
var baseAxis = seriesModel.getBaseAxis();
var idx = zrUtil.indexOf(axisList, baseAxis);
if (idx < 0) {
idx = axisList.length;
axisList[idx] = baseAxis;
result[idx] = {axis: baseAxis, seriesModels: []};
}
result[idx].seriesModels.push(seriesModel);
});
return result;
} | [
"function",
"groupSeriesByAxis",
"(",
"ecModel",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"axisList",
"=",
"[",
"]",
";",
"ecModel",
".",
"eachSeriesByType",
"(",
"'boxplot'",
",",
"function",
"(",
"seriesModel",
")",
"{",
"var",
"baseAxis",
... | Group series by axis. | [
"Group",
"series",
"by",
"axis",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/boxplot/boxplotLayout.js#L51-L69 | train | group series by axis | [
30522,
3853,
2967,
28077,
3762,
8528,
2483,
1006,
14925,
5302,
9247,
1007,
1063,
13075,
2765,
1027,
1031,
1033,
1025,
13075,
8123,
9863,
1027,
1031,
1033,
1025,
14925,
5302,
9247,
1012,
2169,
8043,
3111,
3762,
13874,
1006,
1005,
3482,
24759... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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) {
_addResult(node);
ASTWalker.simple(node, {
/*
class <className> () {
<methodName> () {
}
}
*/
MethodDefinition: function (methodNode) {
_addResult(methodNode, methodNode.key.start, node.id.name);
}
});
} | javascript | function (node) {
_addResult(node);
ASTWalker.simple(node, {
/*
class <className> () {
<methodName> () {
}
}
*/
MethodDefinition: function (methodNode) {
_addResult(methodNode, methodNode.key.start, node.id.name);
}
});
} | [
"function",
"(",
"node",
")",
"{",
"_addResult",
"(",
"node",
")",
";",
"ASTWalker",
".",
"simple",
"(",
"node",
",",
"{",
"/*\n class <className> () {\n <methodName> () {\n \n }... | /*
class <className> () {} | [
"/",
"*",
"class",
"<className",
">",
"()",
"{}"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSUtils.js#L105-L119 | train | Add a method definition to the result | [
30522,
3853,
1006,
13045,
1007,
1063,
1035,
5587,
6072,
11314,
1006,
13045,
1007,
1025,
2004,
2102,
26965,
1012,
3722,
1006,
13045,
1010,
1063,
1013,
1008,
2465,
1026,
2465,
18442,
1028,
1006,
1007,
1063,
1026,
4118,
18442,
1028,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | mxKeyHandler | function mxKeyHandler(graph, target)
{
if (graph != null)
{
this.graph = graph;
this.target = target || document.documentElement;
// Creates the arrays to map from keycodes to functions
this.normalKeys = [];
this.shiftKeys = [];
this.controlKeys = [];
this.controlShiftKeys = [];
this.keydownHandler = mxUtils.bind(this, function(evt)
{
this.keyDown(evt);
});
// Installs the keystroke listener in the target
mxEvent.addListener(this.target, 'keydown', this.keydownHandler);
// Automatically deallocates memory in IE
if (mxClient.IS_IE)
{
mxEvent.addListener(window, 'unload',
mxUtils.bind(this, function()
{
this.destroy();
})
);
}
}
} | javascript | function mxKeyHandler(graph, target)
{
if (graph != null)
{
this.graph = graph;
this.target = target || document.documentElement;
// Creates the arrays to map from keycodes to functions
this.normalKeys = [];
this.shiftKeys = [];
this.controlKeys = [];
this.controlShiftKeys = [];
this.keydownHandler = mxUtils.bind(this, function(evt)
{
this.keyDown(evt);
});
// Installs the keystroke listener in the target
mxEvent.addListener(this.target, 'keydown', this.keydownHandler);
// Automatically deallocates memory in IE
if (mxClient.IS_IE)
{
mxEvent.addListener(window, 'unload',
mxUtils.bind(this, function()
{
this.destroy();
})
);
}
}
} | [
"function",
"mxKeyHandler",
"(",
"graph",
",",
"target",
")",
"{",
"if",
"(",
"graph",
"!=",
"null",
")",
"{",
"this",
".",
"graph",
"=",
"graph",
";",
"this",
".",
"target",
"=",
"target",
"||",
"document",
".",
"documentElement",
";",
"// Creates the a... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxKeyHandler
Event handler that listens to keystroke events. This is not a singleton,
however, it is normally only required once if the target is the document
element (default).
This handler installs a key event listener in the topmost DOM node and
processes all events that originate from descandants of <mxGraph.container>
or from the topmost DOM node. The latter means that all unhandled keystrokes
are handled by this object regardless of the focused state of the <graph>.
Example:
The following example creates a key handler that listens to the delete key
(46) and deletes the selection cells if the graph is enabled.
(code)
var keyHandler = new mxKeyHandler(graph);
keyHandler.bindKey(46, function(evt)
{
if (graph.isEnabled())
{
graph.removeCells();
}
});
(end)
Keycodes:
See http://tinyurl.com/yp8jgl or http://tinyurl.com/229yqw for a list of
keycodes or install a key event listener into the document element and print
the key codes of the respective events to the console.
To support the Command key and the Control key on the Mac, the following
code can be used.
(code)
keyHandler.getFunction = function(evt)
{
if (evt != null)
{
return (mxEvent.isControlDown(evt) || (mxClient.IS_MAC && evt.metaKey)) ? this.controlKeys[evt.keyCode] : this.normalKeys[evt.keyCode];
}
return null;
};
(end)
Constructor: mxKeyHandler
Constructs an event handler that executes functions bound to specific
keystrokes.
Parameters:
graph - Reference to the associated <mxGraph>.
target - Optional reference to the event target. If null, the document
element is used as the event target, that is, the object where the key
event listener is installed. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxKeyHandler"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L80668-L80700 | train | This is the main entry point for the key handler | [
30522,
3853,
25630,
14839,
11774,
3917,
1006,
10629,
1010,
4539,
1007,
1063,
2065,
1006,
10629,
999,
1027,
19701,
1007,
1063,
2023,
1012,
10629,
1027,
10629,
1025,
2023,
1012,
4539,
1027,
4539,
1064,
1064,
6254,
1012,
6254,
12260,
3672,
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... |
angular/material | src/core/util/animation/animate.js | noTransitionFound | function noTransitionFound(styles) {
styles = styles || window.getComputedStyle(element[0]);
return styles.transitionDuration == '0s' || (!styles.transition && !styles.transitionProperty);
} | javascript | function noTransitionFound(styles) {
styles = styles || window.getComputedStyle(element[0]);
return styles.transitionDuration == '0s' || (!styles.transition && !styles.transitionProperty);
} | [
"function",
"noTransitionFound",
"(",
"styles",
")",
"{",
"styles",
"=",
"styles",
"||",
"window",
".",
"getComputedStyle",
"(",
"element",
"[",
"0",
"]",
")",
";",
"return",
"styles",
".",
"transitionDuration",
"==",
"'0s'",
"||",
"(",
"!",
"styles",
".",... | Checks whether or not there is a transition.
@param styles The cached styles to use for the calculation. If null, getComputedStyle()
will be used.
@returns {boolean} True if there is no transition/duration; false otherwise. | [
"Checks",
"whether",
"or",
"not",
"there",
"is",
"a",
"transition",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L94-L98 | train | Check if the element has no transition | [
30522,
3853,
2025,
5521,
28032,
3258,
14876,
8630,
1006,
6782,
1007,
1063,
6782,
30524,
1004,
1004,
999,
6782,
1012,
6653,
21572,
4842,
3723,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/widgets/InlineMenu.js | InlineMenu | function InlineMenu(editor, menuText) {
/**
* The list of items to display
*
* @type {Array.<{id: number, name: string>}
*/
this.items = [];
/**
* The selected position in the list; otherwise -1.
*
* @type {number}
*/
this.selectedIndex = -1;
/**
* Is the list currently open?
*
* @type {boolean}
*/
this.opened = false;
/**
* The editor context
*
* @type {Editor}
*/
this.editor = editor;
/**
* The menu selection callback function
*
* @type {Function}
*/
this.handleSelect = null;
/**
* The menu closure callback function
*
* @type {Function}
*/
this.handleClose = null;
/**
* The menu object
*
* @type {jQuery.Object}
*/
this.$menu =
$("<li class='dropdown inlinemenu-menu'></li>")
.append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
.hide())
.append("<ul class='dropdown-menu'>" +
"<li class='inlinemenu-header'>" +
"<a>" + menuText + "</a>" +
"</li>" +
"</ul>");
this._keydownHook = this._keydownHook.bind(this);
} | javascript | function InlineMenu(editor, menuText) {
/**
* The list of items to display
*
* @type {Array.<{id: number, name: string>}
*/
this.items = [];
/**
* The selected position in the list; otherwise -1.
*
* @type {number}
*/
this.selectedIndex = -1;
/**
* Is the list currently open?
*
* @type {boolean}
*/
this.opened = false;
/**
* The editor context
*
* @type {Editor}
*/
this.editor = editor;
/**
* The menu selection callback function
*
* @type {Function}
*/
this.handleSelect = null;
/**
* The menu closure callback function
*
* @type {Function}
*/
this.handleClose = null;
/**
* The menu object
*
* @type {jQuery.Object}
*/
this.$menu =
$("<li class='dropdown inlinemenu-menu'></li>")
.append($("<a href='#' class='dropdown-toggle' data-toggle='dropdown'></a>")
.hide())
.append("<ul class='dropdown-menu'>" +
"<li class='inlinemenu-header'>" +
"<a>" + menuText + "</a>" +
"</li>" +
"</ul>");
this._keydownHook = this._keydownHook.bind(this);
} | [
"function",
"InlineMenu",
"(",
"editor",
",",
"menuText",
")",
"{",
"/**\n * The list of items to display\n *\n * @type {Array.<{id: number, name: string>}\n */",
"this",
".",
"items",
"=",
"[",
"]",
";",
"/**\n * The selected position in the l... | Displays a popup list of items for a given editor context
@constructor
@param {Editor} editor
@param {string} menuText | [
"Displays",
"a",
"popup",
"list",
"of",
"items",
"for",
"a",
"given",
"editor",
"context"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/InlineMenu.js#L46-L108 | train | InlineMenu constructor. | [
30522,
3853,
23881,
3549,
2226,
1006,
3559,
1010,
12183,
18209,
1007,
1063,
1013,
1008,
1008,
1008,
1996,
2862,
1997,
5167,
2000,
4653,
1008,
1008,
1030,
2828,
1063,
9140,
1012,
1026,
1063,
8909,
1024,
2193,
1010,
2171,
1024,
5164,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | requestHints | function requestHints(session, document) {
var $deferredHints = $.Deferred(),
hintPromise,
sessionType = session.getType(),
fileInfo = getFileInfo(session),
offset = getOffset(session, fileInfo, null);
_maybeReset(session, document);
hintPromise = getTernHints(fileInfo, offset, sessionType.property);
$.when(hintPromise).done(
function (completions, fnType) {
if (completions.completions) {
session.setTernHints(completions.completions);
session.setGuesses(null);
} else {
session.setTernHints([]);
session.setGuesses(completions.properties);
}
$deferredHints.resolveWith(null);
}
).fail(function () {
$deferredHints.reject();
});
return $deferredHints.promise();
} | javascript | function requestHints(session, document) {
var $deferredHints = $.Deferred(),
hintPromise,
sessionType = session.getType(),
fileInfo = getFileInfo(session),
offset = getOffset(session, fileInfo, null);
_maybeReset(session, document);
hintPromise = getTernHints(fileInfo, offset, sessionType.property);
$.when(hintPromise).done(
function (completions, fnType) {
if (completions.completions) {
session.setTernHints(completions.completions);
session.setGuesses(null);
} else {
session.setTernHints([]);
session.setGuesses(completions.properties);
}
$deferredHints.resolveWith(null);
}
).fail(function () {
$deferredHints.reject();
});
return $deferredHints.promise();
} | [
"function",
"requestHints",
"(",
"session",
",",
"document",
")",
"{",
"var",
"$deferredHints",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"hintPromise",
",",
"sessionType",
"=",
"session",
".",
"getType",
"(",
")",
",",
"fileInfo",
"=",
"getFileInfo",
"(",... | Request hints from Tern.
Note that successive calls to getScope may return the same objects, so
clients that wish to modify those objects (e.g., by annotating them based
on some temporary context) should copy them first. See, e.g.,
Session.getHints().
@param {Session} session - the active hinting session
@param {Document} document - the document for which scope info is
desired
@return {jQuery.Promise} - The promise will not complete until the tern
hints have completed. | [
"Request",
"hints",
"from",
"Tern",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1461-L1489 | train | Request hints for a document | [
30522,
3853,
5227,
10606,
3215,
1006,
5219,
1010,
6254,
1007,
1063,
13075,
1002,
13366,
28849,
19114,
7666,
1027,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
9374,
21572,
28732,
1010,
5219,
13874,
1027,
5219,
1012,
2131,
13874,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/gesture/gesture.js | register | function register(element, handlerName, options) {
var handler = HANDLERS[handlerName.replace(/^\$md./, '')];
if (!handler) {
throw new Error('Failed to register element with handler ' + handlerName + '. ' +
'Available handlers: ' + Object.keys(HANDLERS).join(', '));
}
return handler.registerElement(element, options);
} | javascript | function register(element, handlerName, options) {
var handler = HANDLERS[handlerName.replace(/^\$md./, '')];
if (!handler) {
throw new Error('Failed to register element with handler ' + handlerName + '. ' +
'Available handlers: ' + Object.keys(HANDLERS).join(', '));
}
return handler.registerElement(element, options);
} | [
"function",
"register",
"(",
"element",
",",
"handlerName",
",",
"options",
")",
"{",
"var",
"handler",
"=",
"HANDLERS",
"[",
"handlerName",
".",
"replace",
"(",
"/",
"^\\$md.",
"/",
",",
"''",
")",
"]",
";",
"if",
"(",
"!",
"handler",
")",
"{",
"thr... | Register an element to listen for a handler.
This allows an element to override the default options for a handler.
Additionally, some handlers like drag and hold only dispatch events if
the domEvent happens inside an element that's registered to listen for these events.
@see GestureHandler for how overriding of default options works.
@example $mdGesture.register(myElement, 'drag', { minDistance: 20, horizontal: false }) | [
"Register",
"an",
"element",
"to",
"listen",
"for",
"a",
"handler",
".",
"This",
"allows",
"an",
"element",
"to",
"override",
"the",
"default",
"options",
"for",
"a",
"handler",
".",
"Additionally",
"some",
"handlers",
"like",
"drag",
"and",
"hold",
"only",
... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/gesture/gesture.js#L179-L186 | train | Register an element with a handler | [
30522,
3853,
4236,
1006,
5783,
1010,
28213,
18442,
1010,
7047,
1007,
1063,
13075,
28213,
1027,
28213,
2015,
1031,
28213,
18442,
1012,
5672,
1006,
1013,
1034,
1032,
1002,
9108,
1012,
1013,
1010,
1005,
1005,
1007,
1033,
1025,
2065,
1006,
999,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
sass/node-sass | lib/index.js | normalizeFunctionSignature | function normalizeFunctionSignature(signature, callback) {
if (!/^\*|@warn|@error|@debug|\w+\(.*\)$/.test(signature)) {
if (!/\w+/.test(signature)) {
throw new Error('Invalid function signature format "' + signature + '"');
}
return {
signature: signature + '(...)',
callback: function() {
var args = Array.prototype.slice.call(arguments),
list = args.shift(),
i;
for (i = list.getLength() - 1; i >= 0; i--) {
args.unshift(list.getValue(i));
}
return callback.apply(this, args);
}
};
}
return {
signature: signature,
callback: callback
};
} | javascript | function normalizeFunctionSignature(signature, callback) {
if (!/^\*|@warn|@error|@debug|\w+\(.*\)$/.test(signature)) {
if (!/\w+/.test(signature)) {
throw new Error('Invalid function signature format "' + signature + '"');
}
return {
signature: signature + '(...)',
callback: function() {
var args = Array.prototype.slice.call(arguments),
list = args.shift(),
i;
for (i = list.getLength() - 1; i >= 0; i--) {
args.unshift(list.getValue(i));
}
return callback.apply(this, args);
}
};
}
return {
signature: signature,
callback: callback
};
} | [
"function",
"normalizeFunctionSignature",
"(",
"signature",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"/",
"^\\*|@warn|@error|@debug|\\w+\\(.*\\)$",
"/",
".",
"test",
"(",
"signature",
")",
")",
"{",
"if",
"(",
"!",
"/",
"\\w+",
"/",
".",
"test",
"(",
"si... | Normalizes the signature of custom functions to make it possible to just supply the
function name and have the signature default to `fn(...)`. The callback is adjusted
to transform the input sass list into discrete arguments.
@param {String} signature
@param {Function} callback
@return {Object}
@api private | [
"Normalizes",
"the",
"signature",
"of",
"custom",
"functions",
"to",
"make",
"it",
"possible",
"to",
"just",
"supply",
"the",
"function",
"name",
"and",
"have",
"the",
"signature",
"default",
"to",
"fn",
"(",
"...",
")",
".",
"The",
"callback",
"is",
"adju... | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/index.js#L251-L277 | train | Normalize a function signature | [
30522,
3853,
3671,
4697,
11263,
27989,
5332,
16989,
11244,
1006,
8085,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
999,
1013,
1034,
1032,
1008,
1064,
1030,
11582,
1064,
1030,
7561,
1064,
1030,
2139,
8569,
2290,
1064,
1032,
1059,
1009,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/brackets.js | _onReady | function _onReady() {
PerfUtils.addMeasurement("window.document Ready");
// Let the user know Brackets doesn't run in a web browser yet
if (brackets.inBrowser) {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.ERROR_IN_BROWSER_TITLE,
Strings.ERROR_IN_BROWSER
);
}
// Use quiet scrollbars if we aren't on Lion. If we're on Lion, only
// use native scroll bars when the mouse is not plugged in or when
// using the "Always" scroll bar setting.
var osxMatch = /Mac OS X 10\D([\d+])\D/.exec(window.navigator.userAgent);
if (osxMatch && osxMatch[1] && Number(osxMatch[1]) >= 7) {
// test a scrolling div for scrollbars
var $testDiv = $("<div style='position:fixed;left:-50px;width:50px;height:50px;overflow:auto;'><div style='width:100px;height:100px;'/></div>").appendTo(window.document.body);
if ($testDiv.outerWidth() === $testDiv.get(0).clientWidth) {
$(".sidebar").removeClass("quiet-scrollbars");
}
$testDiv.remove();
}
// Load default languages and preferences
Async.waitForAll([LanguageManager.ready, PreferencesManager.ready]).always(function () {
// Load all extensions. This promise will complete even if one or more
// extensions fail to load.
var extensionPathOverride = params.get("extensions"); // used by unit tests
var extensionLoaderPromise = ExtensionLoader.init(extensionPathOverride ? extensionPathOverride.split(",") : null);
// Load the initial project after extensions have loaded
extensionLoaderPromise.always(function () {
// Signal that extensions are loaded
AppInit._dispatchReady(AppInit.EXTENSIONS_LOADED);
// Finish UI initialization
ViewCommandHandlers.restoreFontSize();
var initialProjectPath = ProjectManager.getInitialProjectPath();
ProjectManager.openProject(initialProjectPath).always(function () {
_initTest();
// If this is the first launch, and we have an index.html file in the project folder (which should be
// the samples folder on first launch), open it automatically. (We explicitly check for the
// samples folder in case this is the first time we're launching Brackets after upgrading from
// an old version that might not have set the "afterFirstLaunch" pref.)
var deferred = new $.Deferred();
if (!params.get("skipSampleProjectLoad") && !PreferencesManager.getViewState("afterFirstLaunch")) {
PreferencesManager.setViewState("afterFirstLaunch", "true");
if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) {
FileSystem.resolve(initialProjectPath + "index.html", function (err, file) {
if (!err) {
var promise = CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, { fullPath: file.fullPath });
promise.then(deferred.resolve, deferred.reject);
} else {
deferred.reject();
}
});
} else {
deferred.resolve();
}
} else {
deferred.resolve();
}
deferred.always(function () {
// Signal that Brackets is loaded
AppInit._dispatchReady(AppInit.APP_READY);
PerfUtils.addMeasurement("Application Startup");
if (PreferencesManager._isUserScopeCorrupt()) {
var userPrefFullPath = PreferencesManager.getUserPrefFile();
// user scope can get corrupt only if the file exists, is readable,
// but malformed. no need to check for its existance.
var info = MainViewManager.findInAllWorkingSets(userPrefFullPath);
var paneId;
if (info.length) {
paneId = info[0].paneId;
}
FileViewController.openFileAndAddToWorkingSet(userPrefFullPath, paneId)
.done(function () {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.ERROR_PREFS_CORRUPT_TITLE,
Strings.ERROR_PREFS_CORRUPT
).done(function () {
// give the focus back to the editor with the pref file
MainViewManager.focusActivePane();
});
});
}
});
// See if any startup files were passed to the application
if (brackets.app.getPendingFilesToOpen) {
brackets.app.getPendingFilesToOpen(function (err, paths) {
DragAndDrop.openDroppedFiles(paths);
});
}
});
});
});
// Check for updates
if (!brackets.inBrowser && !params.get("skipUpdateCheck")) {
AppInit.appReady(function () {
// launches periodic checks for updates cca every 24 hours
UpdateNotification.launchAutomaticUpdate();
});
}
} | javascript | function _onReady() {
PerfUtils.addMeasurement("window.document Ready");
// Let the user know Brackets doesn't run in a web browser yet
if (brackets.inBrowser) {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.ERROR_IN_BROWSER_TITLE,
Strings.ERROR_IN_BROWSER
);
}
// Use quiet scrollbars if we aren't on Lion. If we're on Lion, only
// use native scroll bars when the mouse is not plugged in or when
// using the "Always" scroll bar setting.
var osxMatch = /Mac OS X 10\D([\d+])\D/.exec(window.navigator.userAgent);
if (osxMatch && osxMatch[1] && Number(osxMatch[1]) >= 7) {
// test a scrolling div for scrollbars
var $testDiv = $("<div style='position:fixed;left:-50px;width:50px;height:50px;overflow:auto;'><div style='width:100px;height:100px;'/></div>").appendTo(window.document.body);
if ($testDiv.outerWidth() === $testDiv.get(0).clientWidth) {
$(".sidebar").removeClass("quiet-scrollbars");
}
$testDiv.remove();
}
// Load default languages and preferences
Async.waitForAll([LanguageManager.ready, PreferencesManager.ready]).always(function () {
// Load all extensions. This promise will complete even if one or more
// extensions fail to load.
var extensionPathOverride = params.get("extensions"); // used by unit tests
var extensionLoaderPromise = ExtensionLoader.init(extensionPathOverride ? extensionPathOverride.split(",") : null);
// Load the initial project after extensions have loaded
extensionLoaderPromise.always(function () {
// Signal that extensions are loaded
AppInit._dispatchReady(AppInit.EXTENSIONS_LOADED);
// Finish UI initialization
ViewCommandHandlers.restoreFontSize();
var initialProjectPath = ProjectManager.getInitialProjectPath();
ProjectManager.openProject(initialProjectPath).always(function () {
_initTest();
// If this is the first launch, and we have an index.html file in the project folder (which should be
// the samples folder on first launch), open it automatically. (We explicitly check for the
// samples folder in case this is the first time we're launching Brackets after upgrading from
// an old version that might not have set the "afterFirstLaunch" pref.)
var deferred = new $.Deferred();
if (!params.get("skipSampleProjectLoad") && !PreferencesManager.getViewState("afterFirstLaunch")) {
PreferencesManager.setViewState("afterFirstLaunch", "true");
if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) {
FileSystem.resolve(initialProjectPath + "index.html", function (err, file) {
if (!err) {
var promise = CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, { fullPath: file.fullPath });
promise.then(deferred.resolve, deferred.reject);
} else {
deferred.reject();
}
});
} else {
deferred.resolve();
}
} else {
deferred.resolve();
}
deferred.always(function () {
// Signal that Brackets is loaded
AppInit._dispatchReady(AppInit.APP_READY);
PerfUtils.addMeasurement("Application Startup");
if (PreferencesManager._isUserScopeCorrupt()) {
var userPrefFullPath = PreferencesManager.getUserPrefFile();
// user scope can get corrupt only if the file exists, is readable,
// but malformed. no need to check for its existance.
var info = MainViewManager.findInAllWorkingSets(userPrefFullPath);
var paneId;
if (info.length) {
paneId = info[0].paneId;
}
FileViewController.openFileAndAddToWorkingSet(userPrefFullPath, paneId)
.done(function () {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_ERROR,
Strings.ERROR_PREFS_CORRUPT_TITLE,
Strings.ERROR_PREFS_CORRUPT
).done(function () {
// give the focus back to the editor with the pref file
MainViewManager.focusActivePane();
});
});
}
});
// See if any startup files were passed to the application
if (brackets.app.getPendingFilesToOpen) {
brackets.app.getPendingFilesToOpen(function (err, paths) {
DragAndDrop.openDroppedFiles(paths);
});
}
});
});
});
// Check for updates
if (!brackets.inBrowser && !params.get("skipUpdateCheck")) {
AppInit.appReady(function () {
// launches periodic checks for updates cca every 24 hours
UpdateNotification.launchAutomaticUpdate();
});
}
} | [
"function",
"_onReady",
"(",
")",
"{",
"PerfUtils",
".",
"addMeasurement",
"(",
"\"window.document Ready\"",
")",
";",
"// Let the user know Brackets doesn't run in a web browser yet",
"if",
"(",
"brackets",
".",
"inBrowser",
")",
"{",
"Dialogs",
".",
"showModalDialog",
... | Setup Brackets | [
"Setup",
"Brackets"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/brackets.js#L248-L364 | train | Load all languages and preferences | [
30522,
3853,
1035,
2006,
16416,
5149,
1006,
1007,
1063,
2566,
11263,
3775,
4877,
1012,
5587,
4168,
3022,
5397,
3672,
1006,
1000,
3332,
1012,
6254,
3201,
1000,
1007,
1025,
1013,
1013,
2292,
1996,
5310,
2113,
19719,
2987,
1005,
1056,
2448,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/JSDOMParser.js | function () {
var c = this.nextChar();
if (c === undefined)
return null;
// Read any text as Text node
if (c !== "<") {
--this.currentChar;
var textNode = new Text();
var n = this.html.indexOf("<", this.currentChar);
if (n === -1) {
textNode.innerHTML = this.html.substring(this.currentChar, this.html.length);
this.currentChar = this.html.length;
} else {
textNode.innerHTML = this.html.substring(this.currentChar, n);
this.currentChar = n;
}
return textNode;
}
c = this.peekNext();
// Read Comment node. Normally, Comment nodes know their inner
// textContent, but we don't really care about Comment nodes (we throw
// them away in readChildren()). So just returning an empty Comment node
// here is sufficient.
if (c === "!" || c === "?") {
// We're still before the ! or ? that is starting this comment:
this.currentChar++;
return this.discardNextComment();
}
// If we're reading a closing tag, return null. This means we've reached
// the end of this set of child nodes.
if (c === "/") {
--this.currentChar;
return null;
}
// Otherwise, we're looking at an Element node
var result = this.makeElementNode(this.retPair);
if (!result)
return null;
var node = this.retPair[0];
var closed = this.retPair[1];
var localName = node.localName;
// If this isn't a void Element, read its child nodes
if (!closed) {
this.readChildren(node);
var closingTag = "</" + localName + ">";
if (!this.match(closingTag)) {
this.error("expected '" + closingTag + "' and got " + this.html.substr(this.currentChar, closingTag.length));
return null;
}
}
// Only use the first title, because SVG might have other
// title elements which we don't care about (medium.com
// does this, at least).
if (localName === "title" && !this.doc.title) {
this.doc.title = node.textContent.trim();
} else if (localName === "head") {
this.doc.head = node;
} else if (localName === "body") {
this.doc.body = node;
} else if (localName === "html") {
this.doc.documentElement = node;
}
return node;
} | javascript | function () {
var c = this.nextChar();
if (c === undefined)
return null;
// Read any text as Text node
if (c !== "<") {
--this.currentChar;
var textNode = new Text();
var n = this.html.indexOf("<", this.currentChar);
if (n === -1) {
textNode.innerHTML = this.html.substring(this.currentChar, this.html.length);
this.currentChar = this.html.length;
} else {
textNode.innerHTML = this.html.substring(this.currentChar, n);
this.currentChar = n;
}
return textNode;
}
c = this.peekNext();
// Read Comment node. Normally, Comment nodes know their inner
// textContent, but we don't really care about Comment nodes (we throw
// them away in readChildren()). So just returning an empty Comment node
// here is sufficient.
if (c === "!" || c === "?") {
// We're still before the ! or ? that is starting this comment:
this.currentChar++;
return this.discardNextComment();
}
// If we're reading a closing tag, return null. This means we've reached
// the end of this set of child nodes.
if (c === "/") {
--this.currentChar;
return null;
}
// Otherwise, we're looking at an Element node
var result = this.makeElementNode(this.retPair);
if (!result)
return null;
var node = this.retPair[0];
var closed = this.retPair[1];
var localName = node.localName;
// If this isn't a void Element, read its child nodes
if (!closed) {
this.readChildren(node);
var closingTag = "</" + localName + ">";
if (!this.match(closingTag)) {
this.error("expected '" + closingTag + "' and got " + this.html.substr(this.currentChar, closingTag.length));
return null;
}
}
// Only use the first title, because SVG might have other
// title elements which we don't care about (medium.com
// does this, at least).
if (localName === "title" && !this.doc.title) {
this.doc.title = node.textContent.trim();
} else if (localName === "head") {
this.doc.head = node;
} else if (localName === "body") {
this.doc.body = node;
} else if (localName === "html") {
this.doc.documentElement = node;
}
return node;
} | [
"function",
"(",
")",
"{",
"var",
"c",
"=",
"this",
".",
"nextChar",
"(",
")",
";",
"if",
"(",
"c",
"===",
"undefined",
")",
"return",
"null",
";",
"// Read any text as Text node",
"if",
"(",
"c",
"!==",
"\"<\"",
")",
"{",
"--",
"this",
".",
"current... | Reads the next child node from the input. If we're reading a closing
tag, or if we've reached the end of input, return null.
@returns the node | [
"Reads",
"the",
"next",
"child",
"node",
"from",
"the",
"input",
".",
"If",
"we",
"re",
"reading",
"a",
"closing",
"tag",
"or",
"if",
"we",
"ve",
"reached",
"the",
"end",
"of",
"input",
"return",
"null",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L1051-L1124 | train | Reads a node from the current character. | [
30522,
3853,
1006,
1007,
1063,
13075,
1039,
1027,
2023,
1012,
2279,
7507,
2099,
1006,
1007,
1025,
2065,
1006,
1039,
1027,
1027,
1027,
6151,
28344,
1007,
2709,
19701,
1025,
1013,
1013,
3191,
2151,
3793,
2004,
3793,
13045,
2065,
1006,
1039,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/datepicker/js/calendar.spec.js | findCellByLabel | function findCellByLabel(monthElement, day) {
var tds = monthElement.querySelectorAll('td');
var td;
for (var i = 0; i < tds.length; i++) {
td = tds[i];
if (td.textContent === day.toString()) {
return td;
}
}
} | javascript | function findCellByLabel(monthElement, day) {
var tds = monthElement.querySelectorAll('td');
var td;
for (var i = 0; i < tds.length; i++) {
td = tds[i];
if (td.textContent === day.toString()) {
return td;
}
}
} | [
"function",
"findCellByLabel",
"(",
"monthElement",
",",
"day",
")",
"{",
"var",
"tds",
"=",
"monthElement",
".",
"querySelectorAll",
"(",
"'td'",
")",
";",
"var",
"td",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tds",
".",
"length",
";",... | Finds a td given a label. | [
"Finds",
"a",
"td",
"given",
"a",
"label",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendar.spec.js#L44-L54 | train | Find a cell by label | [
30522,
3853,
2424,
29109,
14510,
20470,
2884,
1006,
3204,
12260,
3672,
1010,
2154,
1007,
1063,
13075,
14595,
2015,
1027,
3204,
12260,
3672,
1012,
23032,
11246,
22471,
6525,
3363,
1006,
1005,
14595,
1005,
1007,
1025,
13075,
14595,
1025,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | bower_components/jvectormap/lib/world-map.js | function(lat, lng) {
var point,
proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
width = this.width - this.baseTransX * 2 * this.baseScale,
height = this.height - this.baseTransY * 2 * this.baseScale,
inset,
bbox,
scaleFactor = this.scale / this.baseScale;
if (lng < (-180 + centralMeridian)) {
lng += 360;
}
point = jvm.Proj[proj.type](lat, lng, centralMeridian);
inset = this.getInsetForPoint(point.x, point.y);
if (inset) {
bbox = inset.bbox;
point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
return {
x: point.x + this.transX*this.scale + inset.left*this.scale,
y: point.y + this.transY*this.scale + inset.top*this.scale
};
} else {
return false;
}
} | javascript | function(lat, lng) {
var point,
proj = jvm.WorldMap.maps[this.params.map].projection,
centralMeridian = proj.centralMeridian,
width = this.width - this.baseTransX * 2 * this.baseScale,
height = this.height - this.baseTransY * 2 * this.baseScale,
inset,
bbox,
scaleFactor = this.scale / this.baseScale;
if (lng < (-180 + centralMeridian)) {
lng += 360;
}
point = jvm.Proj[proj.type](lat, lng, centralMeridian);
inset = this.getInsetForPoint(point.x, point.y);
if (inset) {
bbox = inset.bbox;
point.x = (point.x - bbox[0].x) / (bbox[1].x - bbox[0].x) * inset.width * this.scale;
point.y = (point.y - bbox[0].y) / (bbox[1].y - bbox[0].y) * inset.height * this.scale;
return {
x: point.x + this.transX*this.scale + inset.left*this.scale,
y: point.y + this.transY*this.scale + inset.top*this.scale
};
} else {
return false;
}
} | [
"function",
"(",
"lat",
",",
"lng",
")",
"{",
"var",
"point",
",",
"proj",
"=",
"jvm",
".",
"WorldMap",
".",
"maps",
"[",
"this",
".",
"params",
".",
"map",
"]",
".",
"projection",
",",
"centralMeridian",
"=",
"proj",
".",
"centralMeridian",
",",
"wi... | Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
@param {Number} lat Latitide of point in degrees.
@param {Number} lng Longitude of point in degrees. | [
"Converts",
"coordinates",
"expressed",
"as",
"latitude",
"and",
"longitude",
"to",
"the",
"coordinates",
"in",
"pixels",
"on",
"the",
"map",
"."
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jvectormap/lib/world-map.js#L819-L849 | train | Returns the inset of the given point | [
30522,
3853,
1006,
2474,
2102,
1010,
1048,
3070,
1007,
1063,
13075,
2391,
1010,
4013,
3501,
1027,
1046,
2615,
2213,
1012,
2088,
2863,
2361,
1012,
7341,
1031,
2023,
1012,
11498,
5244,
1012,
4949,
1033,
1012,
13996,
1010,
2430,
5017,
29342,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/crossroads.js | Crossroads | function Crossroads() {
this.bypassed = new signals.Signal();
this.routed = new signals.Signal();
this._routes = [];
this._prevRoutes = [];
this._piped = [];
this.resetState();
} | javascript | function Crossroads() {
this.bypassed = new signals.Signal();
this.routed = new signals.Signal();
this._routes = [];
this._prevRoutes = [];
this._piped = [];
this.resetState();
} | [
"function",
"Crossroads",
"(",
")",
"{",
"this",
".",
"bypassed",
"=",
"new",
"signals",
".",
"Signal",
"(",
")",
";",
"this",
".",
"routed",
"=",
"new",
"signals",
".",
"Signal",
"(",
")",
";",
"this",
".",
"_routes",
"=",
"[",
"]",
";",
"this",
... | Crossroads -------- ====================
@constructor | [
"Crossroads",
"--------",
"===================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/crossroads.js#L110-L117 | train | Crossroads constructor. | [
30522,
3853,
16760,
1006,
1007,
1063,
2023,
1012,
27539,
1027,
2047,
7755,
1012,
4742,
1006,
1007,
1025,
2023,
1012,
19578,
1027,
2047,
7755,
1012,
4742,
1006,
1007,
1025,
2023,
1012,
1035,
5847,
1027,
1031,
1033,
1025,
2023,
1012,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | polygonIntersectLine | function polygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding) {
var intersections = [];
var intersection;
var transformedPoints = new Array(basePoints.length);
var doTransform = true;
if (width == null) {
doTransform = false;
}
var points;
if (doTransform) {
for (var i = 0; i < transformedPoints.length / 2; i++) {
transformedPoints[i * 2] = basePoints[i * 2] * width + centerX;
transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY;
}
if (padding > 0) {
var expandedLineSet = expandPolygon(transformedPoints, -padding);
points = joinLines(expandedLineSet);
} else {
points = transformedPoints;
}
} else {
points = basePoints;
}
var currentX, currentY, nextX, nextY;
for (var _i2 = 0; _i2 < points.length / 2; _i2++) {
currentX = points[_i2 * 2];
currentY = points[_i2 * 2 + 1];
if (_i2 < points.length / 2 - 1) {
nextX = points[(_i2 + 1) * 2];
nextY = points[(_i2 + 1) * 2 + 1];
} else {
nextX = points[0];
nextY = points[1];
}
intersection = finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY);
if (intersection.length !== 0) {
intersections.push(intersection[0], intersection[1]);
}
}
return intersections;
} | javascript | function polygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding) {
var intersections = [];
var intersection;
var transformedPoints = new Array(basePoints.length);
var doTransform = true;
if (width == null) {
doTransform = false;
}
var points;
if (doTransform) {
for (var i = 0; i < transformedPoints.length / 2; i++) {
transformedPoints[i * 2] = basePoints[i * 2] * width + centerX;
transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY;
}
if (padding > 0) {
var expandedLineSet = expandPolygon(transformedPoints, -padding);
points = joinLines(expandedLineSet);
} else {
points = transformedPoints;
}
} else {
points = basePoints;
}
var currentX, currentY, nextX, nextY;
for (var _i2 = 0; _i2 < points.length / 2; _i2++) {
currentX = points[_i2 * 2];
currentY = points[_i2 * 2 + 1];
if (_i2 < points.length / 2 - 1) {
nextX = points[(_i2 + 1) * 2];
nextY = points[(_i2 + 1) * 2 + 1];
} else {
nextX = points[0];
nextY = points[1];
}
intersection = finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY);
if (intersection.length !== 0) {
intersections.push(intersection[0], intersection[1]);
}
}
return intersections;
} | [
"function",
"polygonIntersectLine",
"(",
"x",
",",
"y",
",",
"basePoints",
",",
"centerX",
",",
"centerY",
",",
"width",
",",
"height",
",",
"padding",
")",
"{",
"var",
"intersections",
"=",
"[",
"]",
";",
"var",
"intersection",
";",
"var",
"transformedPoi... | math.polygonIntersectLine( x, y, basePoints, centerX, centerY, width, height, padding ) intersect a node polygon (pts transformed) math.polygonIntersectLine( x, y, basePoints, centerX, centerY ) intersect the points (no transform) | [
"math",
".",
"polygonIntersectLine",
"(",
"x",
"y",
"basePoints",
"centerX",
"centerY",
"width",
"height",
"padding",
")",
"intersect",
"a",
"node",
"polygon",
"(",
"pts",
"transformed",
")",
"math",
".",
"polygonIntersectLine",
"(",
"x",
"y",
"basePoints",
"c... | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L3060-L3110 | train | Intersects a line with a polygon | [
30522,
3853,
26572,
7446,
18447,
2545,
22471,
4179,
1006,
1060,
1010,
1061,
1010,
2918,
26521,
1010,
2415,
2595,
1010,
2415,
2100,
1010,
9381,
1010,
4578,
1010,
11687,
4667,
1007,
1063,
13075,
26540,
1027,
1031,
1033,
1025,
13075,
6840,
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/XMLTemplateProcessor.js | syncStrategy | function syncStrategy(node, oAggregation, mAggregations) {
var childNode,
vChild,
aChildren = [];
for (childNode = node.firstChild; childNode; childNode = childNode.nextSibling) {
vChild = fnCallback(node, oAggregation, mAggregations, childNode);
if (vChild) {
aChildren.push(unwrapSyncPromise(vChild));
}
}
return SyncPromise.resolve(aChildren);
} | javascript | function syncStrategy(node, oAggregation, mAggregations) {
var childNode,
vChild,
aChildren = [];
for (childNode = node.firstChild; childNode; childNode = childNode.nextSibling) {
vChild = fnCallback(node, oAggregation, mAggregations, childNode);
if (vChild) {
aChildren.push(unwrapSyncPromise(vChild));
}
}
return SyncPromise.resolve(aChildren);
} | [
"function",
"syncStrategy",
"(",
"node",
",",
"oAggregation",
",",
"mAggregations",
")",
"{",
"var",
"childNode",
",",
"vChild",
",",
"aChildren",
"=",
"[",
"]",
";",
"for",
"(",
"childNode",
"=",
"node",
".",
"firstChild",
";",
"childNode",
";",
"childNod... | sync strategy ensures processing order by just being sync | [
"sync",
"strategy",
"ensures",
"processing",
"order",
"by",
"just",
"being",
"sync"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js#L101-L113 | train | Sync strategy for the node | [
30522,
3853,
26351,
20528,
2618,
6292,
1006,
13045,
1010,
1051,
8490,
17603,
12540,
1010,
23848,
17603,
12540,
2015,
1007,
1063,
13075,
2775,
3630,
3207,
1010,
18315,
19466,
2094,
1010,
9353,
19466,
16200,
2078,
1027,
1031,
1033,
1025,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/ViewSettingsDialog.js | function(sOperator) {
this.sOperator = sOperator || StringFilterOperator.StartsWith;
switch (this.sOperator) {
case StringFilterOperator.Equals:
this.fnOperator = fnEquals;
break;
case StringFilterOperator.Contains:
this.fnOperator = fnContains;
break;
case StringFilterOperator.StartsWith:
this.fnOperator = fnStartsWith;
break;
case StringFilterOperator.AnyWordStartsWith:
this.fnOperator = fnAnyWordStartsWith;
break;
default:
//warning when operator has been given but it doesn't match a value from sap.m.StringFilterOperator enum
Log.warning("Unknown string compare operator. Use values from sap.m.StringFilterOperator. Default operator should be used.");
this.fnOperator = fnContains;
break;
}
} | javascript | function(sOperator) {
this.sOperator = sOperator || StringFilterOperator.StartsWith;
switch (this.sOperator) {
case StringFilterOperator.Equals:
this.fnOperator = fnEquals;
break;
case StringFilterOperator.Contains:
this.fnOperator = fnContains;
break;
case StringFilterOperator.StartsWith:
this.fnOperator = fnStartsWith;
break;
case StringFilterOperator.AnyWordStartsWith:
this.fnOperator = fnAnyWordStartsWith;
break;
default:
//warning when operator has been given but it doesn't match a value from sap.m.StringFilterOperator enum
Log.warning("Unknown string compare operator. Use values from sap.m.StringFilterOperator. Default operator should be used.");
this.fnOperator = fnContains;
break;
}
} | [
"function",
"(",
"sOperator",
")",
"{",
"this",
".",
"sOperator",
"=",
"sOperator",
"||",
"StringFilterOperator",
".",
"StartsWith",
";",
"switch",
"(",
"this",
".",
"sOperator",
")",
"{",
"case",
"StringFilterOperator",
".",
"Equals",
":",
"this",
".",
"fnO... | String filter helper class.
@param {string} sOperator sap.m.StringFilterOperator value. Default is sap.m.StringFilterOperator.StartsWith.
@constructor
@private | [
"String",
"filter",
"helper",
"class",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/ViewSettingsDialog.js#L3228-L3250 | train | Sets the operator to use. | [
30522,
3853,
1006,
2061,
4842,
8844,
1007,
1063,
2023,
1012,
2061,
4842,
8844,
1027,
2061,
4842,
8844,
1064,
1064,
5164,
8873,
21928,
25918,
8844,
1012,
4627,
24415,
1025,
6942,
1006,
2023,
1012,
2061,
4842,
8844,
1007,
1063,
2553,
5164,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
juliangarnier/anime | src/index.js | getTotalLength | function getTotalLength(el) {
if (el.getTotalLength) return el.getTotalLength();
switch(el.tagName.toLowerCase()) {
case 'circle': return getCircleLength(el);
case 'rect': return getRectLength(el);
case 'line': return getLineLength(el);
case 'polyline': return getPolylineLength(el);
case 'polygon': return getPolygonLength(el);
}
} | javascript | function getTotalLength(el) {
if (el.getTotalLength) return el.getTotalLength();
switch(el.tagName.toLowerCase()) {
case 'circle': return getCircleLength(el);
case 'rect': return getRectLength(el);
case 'line': return getLineLength(el);
case 'polyline': return getPolylineLength(el);
case 'polygon': return getPolygonLength(el);
}
} | [
"function",
"getTotalLength",
"(",
"el",
")",
"{",
"if",
"(",
"el",
".",
"getTotalLength",
")",
"return",
"el",
".",
"getTotalLength",
"(",
")",
";",
"switch",
"(",
"el",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"'circle'",
":",
... | Path animation | [
"Path",
"animation"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/src/index.js#L550-L559 | train | Get total length of an element | [
30522,
3853,
2131,
3406,
9080,
7770,
13512,
2232,
1006,
3449,
1007,
1063,
2065,
1006,
3449,
1012,
2131,
3406,
9080,
7770,
13512,
2232,
1007,
2709,
3449,
1012,
2131,
3406,
9080,
7770,
13512,
2232,
1006,
1007,
1025,
6942,
1006,
3449,
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... |
heyui/heyui | src/plugins/popper/index.js | setStyles | function setStyles(element, styles) {
Object.keys(styles).forEach(function (prop) {
var unit = '';
// add unit if the value is numeric and is one of the following
if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
unit = 'px';
}
element.style[prop] = styles[prop] + unit;
});
} | javascript | function setStyles(element, styles) {
Object.keys(styles).forEach(function (prop) {
var unit = '';
// add unit if the value is numeric and is one of the following
if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
unit = 'px';
}
element.style[prop] = styles[prop] + unit;
});
} | [
"function",
"setStyles",
"(",
"element",
",",
"styles",
")",
"{",
"Object",
".",
"keys",
"(",
"styles",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"var",
"unit",
"=",
"''",
";",
"// add unit if the value is numeric and is one of the following",... | Set the style to the given popper
@method
@memberof Popper.Utils
@argument {Element} element - Element to apply the style to
@argument {Object} styles
Object with a list of properties and values which will be applied to the element | [
"Set",
"the",
"style",
"to",
"the",
"given",
"popper"
] | d5405d27d994151b676eb91c12b389316d7f6679 | https://github.com/heyui/heyui/blob/d5405d27d994151b676eb91c12b389316d7f6679/src/plugins/popper/index.js#L1173-L1182 | train | set styles on an element | [
30522,
3853,
4520,
27983,
2015,
1006,
5783,
1010,
6782,
1007,
1063,
4874,
1012,
6309,
1006,
6782,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
17678,
1007,
1063,
13075,
3131,
1027,
1005,
1005,
1025,
1013,
1013,
5587,
3131,
2065,
1996,
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... |
PrismJS/prism | scripts/utopia.js | function(target, type, properties) {
if(_.type(target) === 'string' || _.type(target) === 'array') {
var elements = _.type(target) === 'string'? $$(target) : target;
elements.forEach(function(element) {
_.event.fire(element, type, properties);
});
}
else if (document.createEvent) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent(type, true, true );
evt.custom = true;
if(properties) {
_.attach(evt, properties);
}
target.dispatchEvent(evt);
}
} | javascript | function(target, type, properties) {
if(_.type(target) === 'string' || _.type(target) === 'array') {
var elements = _.type(target) === 'string'? $$(target) : target;
elements.forEach(function(element) {
_.event.fire(element, type, properties);
});
}
else if (document.createEvent) {
var evt = document.createEvent("HTMLEvents");
evt.initEvent(type, true, true );
evt.custom = true;
if(properties) {
_.attach(evt, properties);
}
target.dispatchEvent(evt);
}
} | [
"function",
"(",
"target",
",",
"type",
",",
"properties",
")",
"{",
"if",
"(",
"_",
".",
"type",
"(",
"target",
")",
"===",
"'string'",
"||",
"_",
".",
"type",
"(",
"target",
")",
"===",
"'array'",
")",
"{",
"var",
"elements",
"=",
"_",
".",
"ty... | Fire a custom event | [
"Fire",
"a",
"custom",
"event"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L341-L361 | train | Fire an event on an element or array of elements | [
30522,
3853,
1006,
4539,
1010,
2828,
1010,
5144,
1007,
1063,
2065,
1006,
1035,
1012,
2828,
1006,
4539,
1007,
1027,
1027,
1027,
1005,
5164,
1005,
1064,
1064,
1035,
1012,
2828,
1006,
4539,
1007,
1027,
30524,
1027,
1005,
5164,
1005,
1029,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | commaify | function commaify(s) {
var w = 3;
if(s.length <= w) return s;
var j = (s.length % w), o = s.substr(0,j);
for(; j!=s.length; j+=w) o+=(o.length > 0 ? "," : "") + s.substr(j,w);
return o;
} | javascript | function commaify(s) {
var w = 3;
if(s.length <= w) return s;
var j = (s.length % w), o = s.substr(0,j);
for(; j!=s.length; j+=w) o+=(o.length > 0 ? "," : "") + s.substr(j,w);
return o;
} | [
"function",
"commaify",
"(",
"s",
")",
"{",
"var",
"w",
"=",
"3",
";",
"if",
"(",
"s",
".",
"length",
"<=",
"w",
")",
"return",
"s",
";",
"var",
"j",
"=",
"(",
"s",
".",
"length",
"%",
"w",
")",
",",
"o",
"=",
"s",
".",
"substr",
"(",
"0"... | /*jshint +W086 | [
"/",
"*",
"jshint",
"+",
"W086"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L430-L436 | train | commaify a string | [
30522,
3853,
4012,
2863,
8757,
1006,
1055,
1007,
1063,
13075,
1059,
1027,
1017,
1025,
2065,
1006,
1055,
1012,
3091,
1026,
1027,
1059,
1007,
2709,
1055,
1025,
13075,
1046,
1027,
1006,
1055,
1012,
3091,
1003,
1059,
1007,
1010,
1051,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | packages/vue-server-renderer/build.js | normalizeStyleData | function normalizeStyleData (data) {
var style = normalizeStyleBinding(data.style);
// static style is pre-processed into an object during compilation
// and is always a fresh object, so it's safe to merge into it
return data.staticStyle
? extend(data.staticStyle, style)
: style
} | javascript | function normalizeStyleData (data) {
var style = normalizeStyleBinding(data.style);
// static style is pre-processed into an object during compilation
// and is always a fresh object, so it's safe to merge into it
return data.staticStyle
? extend(data.staticStyle, style)
: style
} | [
"function",
"normalizeStyleData",
"(",
"data",
")",
"{",
"var",
"style",
"=",
"normalizeStyleBinding",
"(",
"data",
".",
"style",
")",
";",
"// static style is pre-processed into an object during compilation",
"// and is always a fresh object, so it's safe to merge into it",
"ret... | merge static and dynamic style data on the same vnode | [
"merge",
"static",
"and",
"dynamic",
"style",
"data",
"on",
"the",
"same",
"vnode"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/vue-server-renderer/build.js#L1495-L1502 | train | normalize style data | [
30522,
3853,
3671,
10057,
27983,
2850,
2696,
1006,
2951,
1007,
1063,
13075,
2806,
1027,
3671,
10057,
27983,
8428,
4667,
1006,
2951,
1012,
2806,
1007,
1025,
1013,
1013,
10763,
2806,
2003,
3653,
1011,
13995,
2046,
2019,
4874,
2076,
6268,
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... |
SAP/openui5 | src/sap.m/src/sap/m/FormattedText.js | openExternalLink | function openExternalLink (oEvent) {
var newWindow = window.open();
newWindow.opener = null;
newWindow.location = oEvent.currentTarget.href;
oEvent.preventDefault();
} | javascript | function openExternalLink (oEvent) {
var newWindow = window.open();
newWindow.opener = null;
newWindow.location = oEvent.currentTarget.href;
oEvent.preventDefault();
} | [
"function",
"openExternalLink",
"(",
"oEvent",
")",
"{",
"var",
"newWindow",
"=",
"window",
".",
"open",
"(",
")",
";",
"newWindow",
".",
"opener",
"=",
"null",
";",
"newWindow",
".",
"location",
"=",
"oEvent",
".",
"currentTarget",
".",
"href",
";",
"oE... | prohibit a new window from accessing window.opener.location | [
"prohibit",
"a",
"new",
"window",
"from",
"accessing",
"window",
".",
"opener",
".",
"location"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/FormattedText.js#L282-L287 | train | Open external link | [
30522,
3853,
2330,
10288,
16451,
8095,
19839,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
2047,
11101,
5004,
1027,
3332,
1012,
2330,
1006,
1007,
1025,
2047,
11101,
5004,
1012,
16181,
1027,
19701,
1025,
2047,
11101,
5004,
1012,
3295,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/axisTickLabelBuilder.js | makeLabelsByCustomizedCategoryInterval | function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
var ordinalScale = axis.scale;
var labelFormatter = makeLabelFormatter(axis);
var result = [];
zrUtil.each(ordinalScale.getTicks(), function (tickValue) {
var rawLabel = ordinalScale.getLabel(tickValue);
if (categoryInterval(tickValue, rawLabel)) {
result.push(onlyTick
? tickValue
: {
formattedLabel: labelFormatter(tickValue),
rawLabel: rawLabel,
tickValue: tickValue
}
);
}
});
return result;
} | javascript | function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
var ordinalScale = axis.scale;
var labelFormatter = makeLabelFormatter(axis);
var result = [];
zrUtil.each(ordinalScale.getTicks(), function (tickValue) {
var rawLabel = ordinalScale.getLabel(tickValue);
if (categoryInterval(tickValue, rawLabel)) {
result.push(onlyTick
? tickValue
: {
formattedLabel: labelFormatter(tickValue),
rawLabel: rawLabel,
tickValue: tickValue
}
);
}
});
return result;
} | [
"function",
"makeLabelsByCustomizedCategoryInterval",
"(",
"axis",
",",
"categoryInterval",
",",
"onlyTick",
")",
"{",
"var",
"ordinalScale",
"=",
"axis",
".",
"scale",
";",
"var",
"labelFormatter",
"=",
"makeLabelFormatter",
"(",
"axis",
")",
";",
"var",
"result"... | When interval is function, the result `false` means ignore the tick. It is time consuming for large category data. | [
"When",
"interval",
"is",
"function",
"the",
"result",
"false",
"means",
"ignore",
"the",
"tick",
".",
"It",
"is",
"time",
"consuming",
"for",
"large",
"category",
"data",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/axisTickLabelBuilder.js#L345-L365 | train | Creates an array of labels that are defined by a customized category interval | [
30522,
3853,
2191,
20470,
9050,
3762,
7874,
20389,
3550,
16280,
20255,
25811,
3334,
10175,
1006,
8123,
1010,
4696,
18447,
2121,
10175,
1010,
2069,
26348,
1007,
1063,
13075,
2030,
18979,
4877,
9289,
2063,
1027,
8123,
1012,
4094,
1025,
13075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/helper/writeFile.js | writeFile | function writeFile(output, filePath, content) {
var rootFolder = output.getRoot();
filePath = path.join(rootFolder, filePath);
return fs.ensureFile(filePath)
.then(function() {
return fs.writeFile(filePath, content);
})
.thenResolve(output);
} | javascript | function writeFile(output, filePath, content) {
var rootFolder = output.getRoot();
filePath = path.join(rootFolder, filePath);
return fs.ensureFile(filePath)
.then(function() {
return fs.writeFile(filePath, content);
})
.thenResolve(output);
} | [
"function",
"writeFile",
"(",
"output",
",",
"filePath",
",",
"content",
")",
"{",
"var",
"rootFolder",
"=",
"output",
".",
"getRoot",
"(",
")",
";",
"filePath",
"=",
"path",
".",
"join",
"(",
"rootFolder",
",",
"filePath",
")",
";",
"return",
"fs",
".... | Write a file to the output folder
@param {Output} output
@param {String} filePath
@param {Buffer|String} content
@return {Promise} | [
"Write",
"a",
"file",
"to",
"the",
"output",
"folder"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/helper/writeFile.js#L12-L21 | train | Write a file to the specified output folder | [
30522,
3853,
4339,
8873,
2571,
1006,
6434,
1010,
5371,
15069,
1010,
4180,
1007,
1063,
13075,
7117,
10371,
2121,
1027,
6434,
1012,
2131,
3217,
4140,
1006,
1007,
1025,
5371,
15069,
1027,
4130,
1012,
3693,
1006,
7117,
10371,
2121,
1010,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/util/animation/animate.js | function(raw) {
var css = { };
var lookups = 'left top right bottom width height x y min-width min-height max-width max-height';
angular.forEach(raw, function(value,key) {
if (angular.isUndefined(value)) return;
if (lookups.indexOf(key) >= 0) {
css[key] = value + 'px';
} else {
switch (key) {
case 'transition':
convertToVendor(key, $mdConstant.CSS.TRANSITION, value);
break;
case 'transform':
convertToVendor(key, $mdConstant.CSS.TRANSFORM, value);
break;
case 'transformOrigin':
convertToVendor(key, $mdConstant.CSS.TRANSFORM_ORIGIN, value);
break;
case 'font-size':
css['font-size'] = value; // font sizes aren't always in px
break;
}
}
});
return css;
function convertToVendor(key, vendor, value) {
angular.forEach(vendor.split(' '), function (key) {
css[key] = value;
});
}
} | javascript | function(raw) {
var css = { };
var lookups = 'left top right bottom width height x y min-width min-height max-width max-height';
angular.forEach(raw, function(value,key) {
if (angular.isUndefined(value)) return;
if (lookups.indexOf(key) >= 0) {
css[key] = value + 'px';
} else {
switch (key) {
case 'transition':
convertToVendor(key, $mdConstant.CSS.TRANSITION, value);
break;
case 'transform':
convertToVendor(key, $mdConstant.CSS.TRANSFORM, value);
break;
case 'transformOrigin':
convertToVendor(key, $mdConstant.CSS.TRANSFORM_ORIGIN, value);
break;
case 'font-size':
css['font-size'] = value; // font sizes aren't always in px
break;
}
}
});
return css;
function convertToVendor(key, vendor, value) {
angular.forEach(vendor.split(' '), function (key) {
css[key] = value;
});
}
} | [
"function",
"(",
"raw",
")",
"{",
"var",
"css",
"=",
"{",
"}",
";",
"var",
"lookups",
"=",
"'left top right bottom width height x y min-width min-height max-width max-height'",
";",
"angular",
".",
"forEach",
"(",
"raw",
",",
"function",
"(",
"value",
",",
"key",
... | Enhance raw values to represent valid css stylings... | [
"Enhance",
"raw",
"values",
"to",
"represent",
"valid",
"css",
"stylings",
"..."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/animation/animate.js#L164-L198 | train | Converts a raw CSS object to a CSS object | [
30522,
3853,
1006,
6315,
1007,
1063,
13075,
20116,
2015,
1027,
1063,
1065,
1025,
13075,
2298,
22264,
1027,
1005,
2187,
2327,
2157,
3953,
9381,
4578,
1060,
1061,
8117,
1011,
9381,
8117,
1011,
4578,
4098,
1011,
9381,
4098,
1011,
4578,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/ExtensionLoader.js | init | function init(paths) {
var params = new UrlParams();
if (_init) {
// Only init once. Return a resolved promise.
return new $.Deferred().resolve().promise();
}
if (!paths) {
params.parse();
if (params.get("reloadWithoutUserExts") === "true") {
paths = ["default"];
} else {
paths = [
getDefaultExtensionPath(),
"dev",
getUserExtensionPath()
];
}
}
// Load extensions before restoring the project
// Get a Directory for the user extension directory and create it if it doesn't exist.
// Note that this is an async call and there are no success or failure functions passed
// in. If the directory *doesn't* exist, it will be created. Extension loading may happen
// before the directory is finished being created, but that is okay, since the extension
// loading will work correctly without this directory.
// If the directory *does* exist, nothing else needs to be done. It will be scanned normally
// during extension loading.
var extensionPath = getUserExtensionPath();
FileSystem.getDirectoryForPath(extensionPath).create();
// Create the extensions/disabled directory, too.
var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled");
FileSystem.getDirectoryForPath(disabledExtensionPath).create();
var promise = Async.doSequentially(paths, function (item) {
var extensionPath = item;
// If the item has "/" in it, assume it is a full path. Otherwise, load
// from our source path + "/extensions/".
if (item.indexOf("/") === -1) {
extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item;
}
return loadAllExtensionsInNativeDirectory(extensionPath);
}, false);
promise.always(function () {
_init = true;
});
return promise;
} | javascript | function init(paths) {
var params = new UrlParams();
if (_init) {
// Only init once. Return a resolved promise.
return new $.Deferred().resolve().promise();
}
if (!paths) {
params.parse();
if (params.get("reloadWithoutUserExts") === "true") {
paths = ["default"];
} else {
paths = [
getDefaultExtensionPath(),
"dev",
getUserExtensionPath()
];
}
}
// Load extensions before restoring the project
// Get a Directory for the user extension directory and create it if it doesn't exist.
// Note that this is an async call and there are no success or failure functions passed
// in. If the directory *doesn't* exist, it will be created. Extension loading may happen
// before the directory is finished being created, but that is okay, since the extension
// loading will work correctly without this directory.
// If the directory *does* exist, nothing else needs to be done. It will be scanned normally
// during extension loading.
var extensionPath = getUserExtensionPath();
FileSystem.getDirectoryForPath(extensionPath).create();
// Create the extensions/disabled directory, too.
var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled");
FileSystem.getDirectoryForPath(disabledExtensionPath).create();
var promise = Async.doSequentially(paths, function (item) {
var extensionPath = item;
// If the item has "/" in it, assume it is a full path. Otherwise, load
// from our source path + "/extensions/".
if (item.indexOf("/") === -1) {
extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item;
}
return loadAllExtensionsInNativeDirectory(extensionPath);
}, false);
promise.always(function () {
_init = true;
});
return promise;
} | [
"function",
"init",
"(",
"paths",
")",
"{",
"var",
"params",
"=",
"new",
"UrlParams",
"(",
")",
";",
"if",
"(",
"_init",
")",
"{",
"// Only init once. Return a resolved promise.",
"return",
"new",
"$",
".",
"Deferred",
"(",
")",
".",
"resolve",
"(",
")",
... | Load extensions.
@param {?Array.<string>} A list containing references to extension source
location. A source location may be either (a) a folder name inside
src/extensions or (b) an absolute path.
@return {!$.Promise} A promise object that is resolved when all extensions complete loading. | [
"Load",
"extensions",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionLoader.js#L401-L456 | train | Initializes the extension directory | [
30522,
3853,
1999,
4183,
1006,
10425,
1007,
1063,
13075,
11498,
5244,
1027,
2047,
24471,
14277,
5400,
5244,
1006,
1007,
1025,
2065,
1006,
1035,
1999,
4183,
1007,
1063,
1013,
1013,
2069,
1999,
4183,
2320,
1012,
2709,
1037,
10395,
4872,
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... |
blueimp/jQuery-File-Upload | js/jquery.fileupload-ui.js | function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var $this = $(this),
that = $this.data('blueimp-fileupload') ||
$this.data('fileupload'),
options = that.options;
data.context = that._renderUpload(data.files)
.data('data', data)
.addClass('processing');
options.filesContainer[
options.prependFiles ? 'prepend' : 'append'
](data.context);
that._forceReflow(data.context);
that._transition(data.context);
data.process(function () {
return $this.fileupload('process', data);
}).always(function () {
data.context.each(function (index) {
$(this).find('.size').text(
that._formatFileSize(data.files[index].size)
);
}).removeClass('processing');
that._renderPreviews(data);
}).done(function () {
data.context.find('.start').prop('disabled', false);
if ((that._trigger('added', e, data) !== false) &&
(options.autoUpload || data.autoUpload) &&
data.autoUpload !== false) {
data.submit();
}
}).fail(function () {
if (data.files.error) {
data.context.each(function (index) {
var error = data.files[index].error;
if (error) {
$(this).find('.error').text(error);
}
});
}
});
} | javascript | function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var $this = $(this),
that = $this.data('blueimp-fileupload') ||
$this.data('fileupload'),
options = that.options;
data.context = that._renderUpload(data.files)
.data('data', data)
.addClass('processing');
options.filesContainer[
options.prependFiles ? 'prepend' : 'append'
](data.context);
that._forceReflow(data.context);
that._transition(data.context);
data.process(function () {
return $this.fileupload('process', data);
}).always(function () {
data.context.each(function (index) {
$(this).find('.size').text(
that._formatFileSize(data.files[index].size)
);
}).removeClass('processing');
that._renderPreviews(data);
}).done(function () {
data.context.find('.start').prop('disabled', false);
if ((that._trigger('added', e, data) !== false) &&
(options.autoUpload || data.autoUpload) &&
data.autoUpload !== false) {
data.submit();
}
}).fail(function () {
if (data.files.error) {
data.context.each(function (index) {
var error = data.files[index].error;
if (error) {
$(this).find('.error').text(error);
}
});
}
});
} | [
"function",
"(",
"e",
",",
"data",
")",
"{",
"if",
"(",
"e",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
",",
"that",
"=",
"$this",
".",
"data",
"(",
"'blueimp-fileupload'"... | The add callback is invoked as soon as files are added to the fileupload widget (via file input selection, drag & drop or add API call). See the basic file upload widget for more information: | [
"The",
"add",
"callback",
"is",
"invoked",
"as",
"soon",
"as",
"files",
"are",
"added",
"to",
"the",
"fileupload",
"widget",
"(",
"via",
"file",
"input",
"selection",
"drag",
"&",
"drop",
"or",
"add",
"API",
"call",
")",
".",
"See",
"the",
"basic",
"fi... | 4586771d65482dc9678c7e48d245a1501bf96ff5 | https://github.com/blueimp/jQuery-File-Upload/blob/4586771d65482dc9678c7e48d245a1501bf96ff5/js/jquery.fileupload-ui.js#L99-L141 | train | File upload event handler | [
30522,
3853,
1006,
1041,
1010,
2951,
1007,
1063,
2065,
1006,
1041,
1012,
2003,
3207,
7011,
11314,
28139,
15338,
2098,
1006,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
13075,
1002,
2023,
1027,
1002,
1006,
2023,
1007,
1010,
2008,
1027,
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... | |
jgraph/mxgraph | javascript/mxClient.js | function(evt)
{
return (evt.pointerType != null) ? (evt.pointerType == 'touch' || evt.pointerType ===
evt.MSPOINTER_TYPE_TOUCH) : ((evt.mozInputSource != null) ?
evt.mozInputSource == 5 : evt.type.indexOf('touch') == 0);
} | javascript | function(evt)
{
return (evt.pointerType != null) ? (evt.pointerType == 'touch' || evt.pointerType ===
evt.MSPOINTER_TYPE_TOUCH) : ((evt.mozInputSource != null) ?
evt.mozInputSource == 5 : evt.type.indexOf('touch') == 0);
} | [
"function",
"(",
"evt",
")",
"{",
"return",
"(",
"evt",
".",
"pointerType",
"!=",
"null",
")",
"?",
"(",
"evt",
".",
"pointerType",
"==",
"'touch'",
"||",
"evt",
".",
"pointerType",
"===",
"evt",
".",
"MSPOINTER_TYPE_TOUCH",
")",
":",
"(",
"(",
"evt",
... | Function: isTouchEvent
Returns true if the event was generated using a touch device (not a pen or mouse). | [
"Function",
":",
"isTouchEvent"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L9823-L9828 | train | Check if the event is a touch event | [
30522,
3853,
1006,
23408,
2102,
1007,
1063,
2709,
1006,
23408,
2102,
1012,
20884,
13874,
999,
1027,
19701,
1007,
1029,
1006,
23408,
2102,
1012,
20884,
13874,
1027,
1027,
1005,
3543,
1005,
1064,
1064,
23408,
2102,
1012,
20884,
13874,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/dialog/dialog.js | focusOnOpen | function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButton() || dialogElement;
target.focus();
}
/**
* If no element with class dialog-close, try to find the last
* button child in md-actions and assume it is a close button.
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButton() {
return element[0].querySelector('.dialog-close, md-dialog-actions button:last-child');
}
} | javascript | function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButton() || dialogElement;
target.focus();
}
/**
* If no element with class dialog-close, try to find the last
* button child in md-actions and assume it is a close button.
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButton() {
return element[0].querySelector('.dialog-close, md-dialog-actions button:last-child');
}
} | [
"function",
"focusOnOpen",
"(",
")",
"{",
"if",
"(",
"options",
".",
"focusOnOpen",
")",
"{",
"var",
"target",
"=",
"$mdUtil",
".",
"findFocusTarget",
"(",
"element",
")",
"||",
"findCloseButton",
"(",
")",
"||",
"dialogElement",
";",
"target",
".",
"focus... | For alerts, focus on content... otherwise focus on
the close button (or equivalent) | [
"For",
"alerts",
"focus",
"on",
"content",
"...",
"otherwise",
"focus",
"on",
"the",
"close",
"button",
"(",
"or",
"equivalent",
")"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L785-L800 | train | Focus on open | [
30522,
3853,
3579,
17175,
11837,
1006,
1007,
1063,
2065,
1006,
7047,
1012,
3579,
17175,
11837,
1007,
1063,
13075,
4539,
1027,
1002,
9108,
21823,
2140,
1012,
2424,
14876,
7874,
7559,
18150,
1006,
5783,
1007,
1064,
1064,
2424,
20464,
9232,
85... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | expandRangeToSurround | function expandRangeToSurround(range) {
if (range.canSurroundContents()) return;
var common = range.commonAncestorContainer,
start_depth = getDepth(common, range.startContainer),
end_depth = getDepth(common, range.endContainer);
while(!range.canSurroundContents()) {
// In the following branches, we cannot just decrement the depth variables because the setStartBefore/setEndAfter may move the start or end of the range more than one level relative to ``common``. So we need to recompute the depth.
if (start_depth > end_depth) {
range.setStartBefore(range.startContainer);
start_depth = getDepth(common, range.startContainer);
}
else {
range.setEndAfter(range.endContainer);
end_depth = getDepth(common, range.endContainer);
}
}
} | javascript | function expandRangeToSurround(range) {
if (range.canSurroundContents()) return;
var common = range.commonAncestorContainer,
start_depth = getDepth(common, range.startContainer),
end_depth = getDepth(common, range.endContainer);
while(!range.canSurroundContents()) {
// In the following branches, we cannot just decrement the depth variables because the setStartBefore/setEndAfter may move the start or end of the range more than one level relative to ``common``. So we need to recompute the depth.
if (start_depth > end_depth) {
range.setStartBefore(range.startContainer);
start_depth = getDepth(common, range.startContainer);
}
else {
range.setEndAfter(range.endContainer);
end_depth = getDepth(common, range.endContainer);
}
}
} | [
"function",
"expandRangeToSurround",
"(",
"range",
")",
"{",
"if",
"(",
"range",
".",
"canSurroundContents",
"(",
")",
")",
"return",
";",
"var",
"common",
"=",
"range",
".",
"commonAncestorContainer",
",",
"start_depth",
"=",
"getDepth",
"(",
"common",
",",
... | Should fix the obtained ranges that cannot surrond contents normally to apply changes upon Being considerate to firefox that sets range start start out of span and end inside on doubleclick initiated selection | [
"Should",
"fix",
"the",
"obtained",
"ranges",
"that",
"cannot",
"surrond",
"contents",
"normally",
"to",
"apply",
"changes",
"upon",
"Being",
"considerate",
"to",
"firefox",
"that",
"sets",
"range",
"start",
"start",
"out",
"of",
"span",
"and",
"end",
"inside"... | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L8732-L8750 | train | Expand a range to surround the contents of the range. | [
30522,
3853,
7818,
24388,
18903,
26210,
22494,
4859,
1006,
2846,
1007,
1063,
2065,
1006,
2846,
1012,
18484,
3126,
22494,
4859,
8663,
6528,
3215,
1006,
1007,
1007,
2709,
1025,
13075,
2691,
1027,
2846,
1012,
2691,
26755,
4263,
8663,
18249,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
pixijs/pixi.js | packages/text/src/TextStyle.js | areArraysEqual | function areArraysEqual(array1, array2)
{
if (!Array.isArray(array1) || !Array.isArray(array2))
{
return false;
}
if (array1.length !== array2.length)
{
return false;
}
for (let i = 0; i < array1.length; ++i)
{
if (array1[i] !== array2[i])
{
return false;
}
}
return true;
} | javascript | function areArraysEqual(array1, array2)
{
if (!Array.isArray(array1) || !Array.isArray(array2))
{
return false;
}
if (array1.length !== array2.length)
{
return false;
}
for (let i = 0; i < array1.length; ++i)
{
if (array1[i] !== array2[i])
{
return false;
}
}
return true;
} | [
"function",
"areArraysEqual",
"(",
"array1",
",",
"array2",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"array1",
")",
"||",
"!",
"Array",
".",
"isArray",
"(",
"array2",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array1",
"... | Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.
This version can also convert array of colors
@private
@param {Array} array1 First array to compare
@param {Array} array2 Second array to compare
@return {boolean} Do the arrays contain the same values in the same order | [
"Utility",
"function",
"to",
"convert",
"hexadecimal",
"colors",
"to",
"strings",
"and",
"simply",
"return",
"the",
"color",
"if",
"it",
"s",
"a",
"string",
".",
"This",
"version",
"can",
"also",
"convert",
"array",
"of",
"colors"
] | 99ae03b7565ae7ca5a6de633b0a277f7128fa4d0 | https://github.com/pixijs/pixi.js/blob/99ae03b7565ae7ca5a6de633b0a277f7128fa4d0/packages/text/src/TextStyle.js#L776-L797 | train | Check if two arrays are equal | [
30522,
3853,
2181,
11335,
23274,
26426,
1006,
9140,
2487,
1010,
9140,
2475,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
9140,
2487,
1007,
1064,
1064,
999,
9140,
1012,
18061,
11335,
2100,
1006,
9140,
2475,
1007,
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... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | findSetIndex | function findSetIndex(ele) {
for (var i = 0; i < forest.length; i++) {
var eles = forest[i];
if (eles.has(ele)) {
return i;
}
}
} | javascript | function findSetIndex(ele) {
for (var i = 0; i < forest.length; i++) {
var eles = forest[i];
if (eles.has(ele)) {
return i;
}
}
} | [
"function",
"findSetIndex",
"(",
"ele",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"forest",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"eles",
"=",
"forest",
"[",
"i",
"]",
";",
"if",
"(",
"eles",
".",
"has",
"(",
"ele",... | assumes byGroup() creates new collections that can be safely mutated | [
"assumes",
"byGroup",
"()",
"creates",
"new",
"collections",
"that",
"can",
"be",
"safely",
"mutated"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L1506-L1514 | train | Find the index of an element in the set | [
30522,
3853,
4858,
20624,
13629,
2595,
1006,
3449,
2063,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
3224,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
13075,
3449,
2229,
1027,
3224,
1031,
1045,
1033,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensibility/ExtensionManager.js | markForRemoval | function markForRemoval(id, mark) {
if (mark) {
_idsToRemove[id] = true;
} else {
delete _idsToRemove[id];
}
exports.trigger("statusChange", id);
} | javascript | function markForRemoval(id, mark) {
if (mark) {
_idsToRemove[id] = true;
} else {
delete _idsToRemove[id];
}
exports.trigger("statusChange", id);
} | [
"function",
"markForRemoval",
"(",
"id",
",",
"mark",
")",
"{",
"if",
"(",
"mark",
")",
"{",
"_idsToRemove",
"[",
"id",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"delete",
"_idsToRemove",
"[",
"id",
"]",
";",
"}",
"exports",
".",
"trigger",
"(",
"\"... | Marks an extension for later removal, or unmarks an extension previously marked.
@param {string} id The id of the extension to mark for removal.
@param {boolean} mark Whether to mark or unmark it. | [
"Marks",
"an",
"extension",
"for",
"later",
"removal",
"or",
"unmarks",
"an",
"extension",
"previously",
"marked",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L511-L518 | train | Mark a phrase for removal | [
30522,
3853,
2928,
29278,
28578,
7103,
2140,
1006,
8909,
1010,
2928,
1007,
1063,
2065,
1006,
2928,
1007,
1063,
1035,
8909,
23809,
6633,
21818,
1031,
8909,
1033,
1027,
2995,
1025,
1065,
2842,
1063,
3972,
12870,
1035,
8909,
23809,
6633,
21818... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/linter.js | resolveParserOptions | function resolveParserOptions(parserName, providedOptions, enabledEnvironments) {
const parserOptionsFromEnv = enabledEnvironments
.filter(env => env.parserOptions)
.reduce((parserOptions, env) => ConfigOps.merge(parserOptions, env.parserOptions), {});
const mergedParserOptions = ConfigOps.merge(parserOptionsFromEnv, providedOptions || {});
const isModule = mergedParserOptions.sourceType === "module";
if (isModule) {
// can't have global return inside of modules
mergedParserOptions.ecmaFeatures = Object.assign({}, mergedParserOptions.ecmaFeatures, { globalReturn: false });
}
mergedParserOptions.ecmaVersion = normalizeEcmaVersion(mergedParserOptions.ecmaVersion, isModule);
return mergedParserOptions;
} | javascript | function resolveParserOptions(parserName, providedOptions, enabledEnvironments) {
const parserOptionsFromEnv = enabledEnvironments
.filter(env => env.parserOptions)
.reduce((parserOptions, env) => ConfigOps.merge(parserOptions, env.parserOptions), {});
const mergedParserOptions = ConfigOps.merge(parserOptionsFromEnv, providedOptions || {});
const isModule = mergedParserOptions.sourceType === "module";
if (isModule) {
// can't have global return inside of modules
mergedParserOptions.ecmaFeatures = Object.assign({}, mergedParserOptions.ecmaFeatures, { globalReturn: false });
}
mergedParserOptions.ecmaVersion = normalizeEcmaVersion(mergedParserOptions.ecmaVersion, isModule);
return mergedParserOptions;
} | [
"function",
"resolveParserOptions",
"(",
"parserName",
",",
"providedOptions",
",",
"enabledEnvironments",
")",
"{",
"const",
"parserOptionsFromEnv",
"=",
"enabledEnvironments",
".",
"filter",
"(",
"env",
"=>",
"env",
".",
"parserOptions",
")",
".",
"reduce",
"(",
... | Combines the provided parserOptions with the options from environments
@param {string} parserName The parser name which uses this options.
@param {Object} providedOptions The provided 'parserOptions' key in a config
@param {Environment[]} enabledEnvironments The environments enabled in configuration and with inline comments
@returns {Object} Resulting parser options after merge | [
"Combines",
"the",
"provided",
"parserOptions",
"with",
"the",
"options",
"from",
"environments"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/linter.js#L357-L375 | train | Resolves the parser options from the environment | [
30522,
3853,
10663,
19362,
8043,
7361,
9285,
1006,
11968,
8043,
18442,
1010,
3024,
7361,
9285,
1010,
9124,
2368,
21663,
2239,
8163,
1007,
1063,
9530,
3367,
11968,
8043,
7361,
9285,
19699,
8462,
2078,
2615,
1027,
9124,
2368,
21663,
2239,
816... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _edit | function _edit(paneId, doc, optionsIn) {
var options = optionsIn || {};
var pane = _getPane(paneId);
// If file is untitled or otherwise not within project tree, add it to
// working set right now (don't wait for it to become dirty)
if (doc.isUntitled() || !ProjectManager.isWithinProject(doc.file.fullPath)) {
addToWorkingSet(paneId, doc.file);
}
// open document will show the editor if there is one already
EditorManager.openDocument(doc, pane, options);
_makeFileMostRecent(paneId, doc.file);
if (!options.noPaneActivate) {
setActivePaneId(paneId);
}
} | javascript | function _edit(paneId, doc, optionsIn) {
var options = optionsIn || {};
var pane = _getPane(paneId);
// If file is untitled or otherwise not within project tree, add it to
// working set right now (don't wait for it to become dirty)
if (doc.isUntitled() || !ProjectManager.isWithinProject(doc.file.fullPath)) {
addToWorkingSet(paneId, doc.file);
}
// open document will show the editor if there is one already
EditorManager.openDocument(doc, pane, options);
_makeFileMostRecent(paneId, doc.file);
if (!options.noPaneActivate) {
setActivePaneId(paneId);
}
} | [
"function",
"_edit",
"(",
"paneId",
",",
"doc",
",",
"optionsIn",
")",
"{",
"var",
"options",
"=",
"optionsIn",
"||",
"{",
"}",
";",
"var",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"// If file is untitled or otherwise not within project tree, add it to",
... | Edits a document in the specified pane.
This function is only used by:
- Unit Tests (which construct Mock Document objects),
- by File > New because there is yet to be an established File object
- by Find In Files which needs to open documents synchronously in some cases
Do not use this API it is for internal use only
@param {!string} paneId - id of the pane in which to open the document
@param {!Document} doc - document to edit
@param {{noPaneActivate:boolean=}=} optionsIn - options
@private | [
"Edits",
"a",
"document",
"in",
"the",
"specified",
"pane",
".",
"This",
"function",
"is",
"only",
"used",
"by",
":",
"-",
"Unit",
"Tests",
"(",
"which",
"construct",
"Mock",
"Document",
"objects",
")",
"-",
"by",
"File",
">",
"New",
"because",
"there",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L1198-L1216 | train | Edit a document | [
30522,
3853,
1035,
10086,
1006,
6090,
7416,
2094,
1010,
9986,
1010,
7047,
2378,
1007,
1063,
13075,
7047,
1027,
7047,
2378,
1064,
1064,
1063,
1065,
1025,
13075,
6090,
2063,
1027,
1035,
2131,
9739,
2063,
1006,
6090,
7416,
2094,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js | normalizeText | function normalizeText(text, start, end, removeTrailingSemiColons) {
var trimmedText;
// Remove leading spaces
trimmedText = _.trimLeft(text);
if (trimmedText.length < text.length) {
start += (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing spaces
trimmedText = _.trimRight(text);
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing semicolons
if (removeTrailingSemiColons) {
trimmedText = _.trimRight(text, ';');
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
}
return {
text: trimmedText,
start: start,
end: end
};
} | javascript | function normalizeText(text, start, end, removeTrailingSemiColons) {
var trimmedText;
// Remove leading spaces
trimmedText = _.trimLeft(text);
if (trimmedText.length < text.length) {
start += (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing spaces
trimmedText = _.trimRight(text);
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
text = trimmedText;
// Remove trailing semicolons
if (removeTrailingSemiColons) {
trimmedText = _.trimRight(text, ';');
if (trimmedText.length < text.length) {
end -= (text.length - trimmedText.length);
}
}
return {
text: trimmedText,
start: start,
end: end
};
} | [
"function",
"normalizeText",
"(",
"text",
",",
"start",
",",
"end",
",",
"removeTrailingSemiColons",
")",
"{",
"var",
"trimmedText",
";",
"// Remove leading spaces",
"trimmedText",
"=",
"_",
".",
"trimLeft",
"(",
"text",
")",
";",
"if",
"(",
"trimmedText",
"."... | Normalize text by removing leading and trailing whitespace characters
and moves the start and end offset to reflect the new offset
@param {!string} text - selected text
@param {!number} start - the start offset of the text
@param {!number} end - the end offset of the text
@param {!boolean} removeTrailingSemiColons - removes trailing semicolons also if true
@return {!{text: string, start: number, end: number}} | [
"Normalize",
"text",
"by",
"removing",
"leading",
"and",
"trailing",
"whitespace",
"characters",
"and",
"moves",
"the",
"start",
"and",
"end",
"offset",
"to",
"reflect",
"the",
"new",
"offset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptRefactoring/RefactoringUtils.js#L240-L275 | train | Normalize text to be a string | [
30522,
3853,
3671,
4697,
18209,
1006,
3793,
1010,
2707,
1010,
2203,
1010,
6366,
6494,
16281,
3366,
7712,
12898,
3619,
1007,
1063,
13075,
21920,
18209,
1025,
1013,
1013,
6366,
2877,
7258,
21920,
18209,
1027,
1035,
1012,
12241,
2571,
6199,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | handleReload | function handleReload(loadWithoutExtensions) {
var href = window.location.href,
params = new UrlParams();
// Make sure the Reload Without User Extensions parameter is removed
params.parse();
if (loadWithoutExtensions) {
if (!params.get("reloadWithoutUserExts")) {
params.put("reloadWithoutUserExts", true);
}
} else {
if (params.get("reloadWithoutUserExts")) {
params.remove("reloadWithoutUserExts");
}
}
if (href.indexOf("?") !== -1) {
href = href.substring(0, href.indexOf("?"));
}
if (!params.isEmpty()) {
href += "?" + params.toString();
}
// Give Mac native menus extra time to update shortcut highlighting.
// Prevents the menu highlighting from getting messed up after reload.
window.setTimeout(function () {
browserReload(href);
}, 100);
} | javascript | function handleReload(loadWithoutExtensions) {
var href = window.location.href,
params = new UrlParams();
// Make sure the Reload Without User Extensions parameter is removed
params.parse();
if (loadWithoutExtensions) {
if (!params.get("reloadWithoutUserExts")) {
params.put("reloadWithoutUserExts", true);
}
} else {
if (params.get("reloadWithoutUserExts")) {
params.remove("reloadWithoutUserExts");
}
}
if (href.indexOf("?") !== -1) {
href = href.substring(0, href.indexOf("?"));
}
if (!params.isEmpty()) {
href += "?" + params.toString();
}
// Give Mac native menus extra time to update shortcut highlighting.
// Prevents the menu highlighting from getting messed up after reload.
window.setTimeout(function () {
browserReload(href);
}, 100);
} | [
"function",
"handleReload",
"(",
"loadWithoutExtensions",
")",
"{",
"var",
"href",
"=",
"window",
".",
"location",
".",
"href",
",",
"params",
"=",
"new",
"UrlParams",
"(",
")",
";",
"// Make sure the Reload Without User Extensions parameter is removed",
"params",
"."... | Restarts brackets Handler
@param {boolean=} loadWithoutExtensions - true to restart without extensions,
otherwise extensions are loadeed as it is durning a typical boot | [
"Restarts",
"brackets",
"Handler"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L1720-L1750 | train | Handle reload | [
30522,
3853,
28213,
18349,
4215,
1006,
7170,
24415,
5833,
10288,
29048,
2015,
1007,
1063,
13075,
17850,
12879,
1027,
3332,
1012,
3295,
1012,
17850,
12879,
1010,
11498,
5244,
1027,
2047,
24471,
14277,
5400,
5244,
1006,
1007,
1025,
1013,
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/JSUtils/ScopeManager.js | filterText | function filterText(text) {
var newText = text;
if (text.length > preferences.getMaxFileSize()) {
newText = "";
}
return newText;
} | javascript | function filterText(text) {
var newText = text;
if (text.length > preferences.getMaxFileSize()) {
newText = "";
}
return newText;
} | [
"function",
"filterText",
"(",
"text",
")",
"{",
"var",
"newText",
"=",
"text",
";",
"if",
"(",
"text",
".",
"length",
">",
"preferences",
".",
"getMaxFileSize",
"(",
")",
")",
"{",
"newText",
"=",
"\"\"",
";",
"}",
"return",
"newText",
";",
"}"
] | check to see if the text we are sending to Tern is too long.
@param {string} the text to check
@return {string} the text, or the empty text if the original was too long | [
"check",
"to",
"see",
"if",
"the",
"text",
"we",
"are",
"sending",
"to",
"Tern",
"is",
"too",
"long",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L360-L366 | train | Filter text to only contain the file size | [
30522,
3853,
11307,
18209,
1006,
3793,
1007,
1063,
13075,
25597,
10288,
2102,
1027,
3793,
1025,
2065,
1006,
3793,
1012,
3091,
1028,
18394,
1012,
2131,
17848,
8873,
4244,
4697,
1006,
1007,
1007,
1063,
30524,
1000,
1025,
1065,
2709,
25597,
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.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js | function (oEvent) {
var sSource = oEvent.getSource();
var sContentBindingPath = sSource.getBindingContextPath().substring(1);
var sContentModelData = this.getView().getModel("content").getData();
var sContent = sContentModelData[sContentBindingPath];
var sContentName = sContent.name;
var sContentFileType = sContentModelData[sContentBindingPath].fileType;
var oRouter = UIComponent.getRouterFor(this);
this.sNamespace = (this.sNamespace ? this.sNamespace : '/');
if (sContentFileType) {
// show details to a file
var mRouteParameters = {
"layer": this.sLayer,
"namespace": encodeURIComponent(this.sNamespace),
"fileName": sContentName,
"fileType": sContentFileType
};
oRouter.navTo("ContentDetails", mRouteParameters);
} else {
// navigation to a namespace
this.sNamespace += sContentName + '/';
oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(this.sNamespace)});
}
} | javascript | function (oEvent) {
var sSource = oEvent.getSource();
var sContentBindingPath = sSource.getBindingContextPath().substring(1);
var sContentModelData = this.getView().getModel("content").getData();
var sContent = sContentModelData[sContentBindingPath];
var sContentName = sContent.name;
var sContentFileType = sContentModelData[sContentBindingPath].fileType;
var oRouter = UIComponent.getRouterFor(this);
this.sNamespace = (this.sNamespace ? this.sNamespace : '/');
if (sContentFileType) {
// show details to a file
var mRouteParameters = {
"layer": this.sLayer,
"namespace": encodeURIComponent(this.sNamespace),
"fileName": sContentName,
"fileType": sContentFileType
};
oRouter.navTo("ContentDetails", mRouteParameters);
} else {
// navigation to a namespace
this.sNamespace += sContentName + '/';
oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(this.sNamespace)});
}
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"sSource",
"=",
"oEvent",
".",
"getSource",
"(",
")",
";",
"var",
"sContentBindingPath",
"=",
"sSource",
".",
"getBindingContextPath",
"(",
")",
".",
"substring",
"(",
"1",
")",
";",
"var",
"sContentModelData",
"... | Handles the selection of a layer entry in the master page;
Gathers the selected namespace and the current layer, then navigates to the target.
@param {Object} oEvent - press event of master components list
@public | [
"Handles",
"the",
"selection",
"of",
"a",
"layer",
"entry",
"in",
"the",
"master",
"page",
";",
"Gathers",
"the",
"selected",
"namespace",
"and",
"the",
"current",
"layer",
"then",
"navigates",
"to",
"the",
"target",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js#L121-L146 | train | The default event handler for the content navigation | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
7020,
8162,
3401,
1027,
1051,
18697,
3372,
1012,
4152,
8162,
3401,
1006,
1007,
1025,
13075,
8040,
28040,
3372,
8428,
4667,
15069,
1027,
7020,
8162,
3401,
1012,
2131,
8428,
4667,
8663,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mui-org/material-ui | packages/material-ui/src/Popover/Popover.js | getScrollParent | function getScrollParent(parent, child) {
let element = child;
let scrollTop = 0;
while (element && element !== parent) {
element = element.parentNode;
scrollTop += element.scrollTop;
}
return scrollTop;
} | javascript | function getScrollParent(parent, child) {
let element = child;
let scrollTop = 0;
while (element && element !== parent) {
element = element.parentNode;
scrollTop += element.scrollTop;
}
return scrollTop;
} | [
"function",
"getScrollParent",
"(",
"parent",
",",
"child",
")",
"{",
"let",
"element",
"=",
"child",
";",
"let",
"scrollTop",
"=",
"0",
";",
"while",
"(",
"element",
"&&",
"element",
"!==",
"parent",
")",
"{",
"element",
"=",
"element",
".",
"parentNode... | Sum the scrollTop between two elements. | [
"Sum",
"the",
"scrollTop",
"between",
"two",
"elements",
"."
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui/src/Popover/Popover.js#L53-L62 | train | Get the scrollTop of the parent element of child | [
30522,
3853,
4152,
26775,
14511,
19362,
4765,
1006,
6687,
1010,
2775,
1007,
1063,
2292,
5783,
1027,
2775,
1025,
2292,
17186,
14399,
1027,
1014,
1025,
2096,
1006,
5783,
1004,
1004,
5783,
999,
1027,
1027,
6687,
1007,
1063,
5783,
1027,
5783,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CSSCodeHints/main.js | formatHints | function formatHints(hints, query) {
var hasColorSwatch = hints.some(function (token) {
return token.color;
});
StringMatch.basicMatchSort(hints);
return hints.map(function (token) {
var $hintObj = $("<span>").addClass("brackets-css-hints");
// highlight the matched portion of each hint
if (token.stringRanges) {
token.stringRanges.forEach(function (item) {
if (item.matched) {
$hintObj.append($("<span>")
.text(item.text)
.addClass("matched-hint"));
} else {
$hintObj.append(item.text);
}
});
} else {
$hintObj.text(token.value);
}
if (hasColorSwatch) {
$hintObj = ColorUtils.formatColorHint($hintObj, token.color);
}
return $hintObj;
});
} | javascript | function formatHints(hints, query) {
var hasColorSwatch = hints.some(function (token) {
return token.color;
});
StringMatch.basicMatchSort(hints);
return hints.map(function (token) {
var $hintObj = $("<span>").addClass("brackets-css-hints");
// highlight the matched portion of each hint
if (token.stringRanges) {
token.stringRanges.forEach(function (item) {
if (item.matched) {
$hintObj.append($("<span>")
.text(item.text)
.addClass("matched-hint"));
} else {
$hintObj.append(item.text);
}
});
} else {
$hintObj.text(token.value);
}
if (hasColorSwatch) {
$hintObj = ColorUtils.formatColorHint($hintObj, token.color);
}
return $hintObj;
});
} | [
"function",
"formatHints",
"(",
"hints",
",",
"query",
")",
"{",
"var",
"hasColorSwatch",
"=",
"hints",
".",
"some",
"(",
"function",
"(",
"token",
")",
"{",
"return",
"token",
".",
"color",
";",
"}",
")",
";",
"StringMatch",
".",
"basicMatchSort",
"(",
... | Returns a sorted and formatted list of hints with the query substring
highlighted.
@param {Array.<Object>} hints - the list of hints to format
@param {string} query - querystring used for highlighting matched
portions of each hint
@return {Array.jQuery} sorted Array of jQuery DOM elements to insert | [
"Returns",
"a",
"sorted",
"and",
"formatted",
"list",
"of",
"hints",
"with",
"the",
"query",
"substring",
"highlighted",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CSSCodeHints/main.js#L193-L223 | train | Format hints for the given query | [
30522,
3853,
4289,
10606,
3215,
1006,
20385,
1010,
23032,
1007,
1063,
13075,
2038,
18717,
26760,
4017,
2818,
1027,
20385,
1012,
2070,
1006,
3853,
1006,
19204,
1007,
1063,
2709,
19204,
1012,
3609,
1025,
1065,
1007,
1025,
5164,
18900,
2818,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/node/FindInFilesDomain.js | fileCrawler | function fileCrawler() {
if (!files || (files && files.length === 0)) {
setTimeout(fileCrawler, 1000);
return;
}
var contents = "";
if (currentCrawlIndex < files.length) {
contents = getFileContentsForFile(files[currentCrawlIndex]);
if (contents) {
cacheSize += contents.length;
}
currentCrawlIndex++;
}
if (currentCrawlIndex < files.length) {
crawlComplete = false;
setImmediate(fileCrawler);
} else {
crawlComplete = true;
if (!crawlEventSent) {
crawlEventSent = true;
_domainManager.emitEvent("FindInFiles", "crawlComplete", [files.length, cacheSize]);
}
setTimeout(fileCrawler, 1000);
}
} | javascript | function fileCrawler() {
if (!files || (files && files.length === 0)) {
setTimeout(fileCrawler, 1000);
return;
}
var contents = "";
if (currentCrawlIndex < files.length) {
contents = getFileContentsForFile(files[currentCrawlIndex]);
if (contents) {
cacheSize += contents.length;
}
currentCrawlIndex++;
}
if (currentCrawlIndex < files.length) {
crawlComplete = false;
setImmediate(fileCrawler);
} else {
crawlComplete = true;
if (!crawlEventSent) {
crawlEventSent = true;
_domainManager.emitEvent("FindInFiles", "crawlComplete", [files.length, cacheSize]);
}
setTimeout(fileCrawler, 1000);
}
} | [
"function",
"fileCrawler",
"(",
")",
"{",
"if",
"(",
"!",
"files",
"||",
"(",
"files",
"&&",
"files",
".",
"length",
"===",
"0",
")",
")",
"{",
"setTimeout",
"(",
"fileCrawler",
",",
"1000",
")",
";",
"return",
";",
"}",
"var",
"contents",
"=",
"\"... | Crawls through the files in the project ans stores them in cache. Since that could take a while
we do it in batches so that node wont be blocked. | [
"Crawls",
"through",
"the",
"files",
"in",
"the",
"project",
"ans",
"stores",
"them",
"in",
"cache",
".",
"Since",
"that",
"could",
"take",
"a",
"while",
"we",
"do",
"it",
"in",
"batches",
"so",
"that",
"node",
"wont",
"be",
"blocked",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L343-L367 | train | Crawls the files | [
30522,
3853,
5371,
26775,
10376,
3917,
1006,
1007,
1063,
2065,
1006,
999,
6764,
1064,
1064,
1006,
6764,
1004,
1004,
6764,
1012,
3091,
1027,
1027,
1027,
1014,
1007,
1007,
1063,
2275,
7292,
5833,
1006,
5371,
26775,
10376,
3917,
1010,
6694,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 parent = self._parent;
// Setup the default parameters.
self._muted = parent._muted;
self._loop = parent._loop;
self._volume = parent._volume;
self._rate = parent._rate;
self._seek = 0;
self._paused = true;
self._ended = true;
self._sprite = '__default';
// Generate a unique ID for this sound.
self._id = ++Howler._counter;
// Add itself to the parent's pool.
parent._sounds.push(self);
// Create the new node.
self.create();
return self;
} | javascript | function() {
var self = this;
var parent = self._parent;
// Setup the default parameters.
self._muted = parent._muted;
self._loop = parent._loop;
self._volume = parent._volume;
self._rate = parent._rate;
self._seek = 0;
self._paused = true;
self._ended = true;
self._sprite = '__default';
// Generate a unique ID for this sound.
self._id = ++Howler._counter;
// Add itself to the parent's pool.
parent._sounds.push(self);
// Create the new node.
self.create();
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"parent",
"=",
"self",
".",
"_parent",
";",
"// Setup the default parameters.",
"self",
".",
"_muted",
"=",
"parent",
".",
"_muted",
";",
"self",
".",
"_loop",
"=",
"parent",
".",
"_loop"... | Initialize a new Sound object.
@return {Sound} | [
"Initialize",
"a",
"new",
"Sound",
"object",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L2164-L2188 | train | Create a new sound node | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
6687,
1027,
2969,
1012,
1035,
6687,
1025,
1013,
1013,
16437,
1996,
12398,
11709,
1012,
2969,
1012,
1035,
22124,
1027,
6687,
1012,
1035,
22124,
1025,
2969,
1012,
1035,
7077... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
elastic/elasticsearch-js | api/api/ml.find_file_structure.js | buildMlFindFileStructure | function buildMlFindFileStructure (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html) request
*
* @param {int} lines_to_sample - How many lines of the file should be included in the analysis
* @param {time} timeout - Timeout after which the analysis will be aborted
* @param {string} charset - Optional parameter to specify the character set of the file
* @param {enum} format - Optional parameter to specify the high level file format
* @param {boolean} has_header_row - Optional parameter to specify whether a delimited file includes the column names in its first row
* @param {list} column_names - Optional parameter containing a comma separated list of the column names for a delimited file
* @param {string} delimiter - Optional parameter to specify the delimiter character for a delimited file - must be a single character
* @param {string} quote - Optional parameter to specify the quote character for a delimited file - must be a single character
* @param {boolean} should_trim_fields - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them
* @param {string} grok_pattern - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file
* @param {string} timestamp_field - Optional parameter to specify the timestamp field in the file
* @param {string} timestamp_format - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format
* @param {boolean} explain - Whether to include a commentary on how the structure was derived
* @param {object} body - The contents of the file to be analyzed
*/
const acceptedQuerystring = [
'lines_to_sample',
'timeout',
'charset',
'format',
'has_header_row',
'column_names',
'delimiter',
'quote',
'should_trim_fields',
'grok_pattern',
'timestamp_field',
'timestamp_format',
'explain'
]
const snakeCase = {
linesToSample: 'lines_to_sample',
hasHeaderRow: 'has_header_row',
columnNames: 'column_names',
shouldTrimFields: 'should_trim_fields',
grokPattern: 'grok_pattern',
timestampField: 'timestamp_field',
timestampFormat: 'timestamp_format'
}
return function mlFindFileStructure (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ml' + '/' + 'find_file_structure'
// build request object
const request = {
method,
path,
bulkBody: body,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildMlFindFileStructure (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html) request
*
* @param {int} lines_to_sample - How many lines of the file should be included in the analysis
* @param {time} timeout - Timeout after which the analysis will be aborted
* @param {string} charset - Optional parameter to specify the character set of the file
* @param {enum} format - Optional parameter to specify the high level file format
* @param {boolean} has_header_row - Optional parameter to specify whether a delimited file includes the column names in its first row
* @param {list} column_names - Optional parameter containing a comma separated list of the column names for a delimited file
* @param {string} delimiter - Optional parameter to specify the delimiter character for a delimited file - must be a single character
* @param {string} quote - Optional parameter to specify the quote character for a delimited file - must be a single character
* @param {boolean} should_trim_fields - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them
* @param {string} grok_pattern - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file
* @param {string} timestamp_field - Optional parameter to specify the timestamp field in the file
* @param {string} timestamp_format - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format
* @param {boolean} explain - Whether to include a commentary on how the structure was derived
* @param {object} body - The contents of the file to be analyzed
*/
const acceptedQuerystring = [
'lines_to_sample',
'timeout',
'charset',
'format',
'has_header_row',
'column_names',
'delimiter',
'quote',
'should_trim_fields',
'grok_pattern',
'timestamp_field',
'timestamp_format',
'explain'
]
const snakeCase = {
linesToSample: 'lines_to_sample',
hasHeaderRow: 'has_header_row',
columnNames: 'column_names',
shouldTrimFields: 'should_trim_fields',
grokPattern: 'grok_pattern',
timestampField: 'timestamp_field',
timestampFormat: 'timestamp_format'
}
return function mlFindFileStructure (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
path = '/' + '_ml' + '/' + 'find_file_structure'
// build request object
const request = {
method,
path,
bulkBody: body,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildMlFindFileStructure",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [ml.find_file_structure](http://... | /* eslint camelcase: 0 /* eslint no-unused-vars: 0 | [
"/",
"*",
"eslint",
"camelcase",
":",
"0",
"/",
"*",
"eslint",
"no",
"-",
"unused",
"-",
"vars",
":",
"0"
] | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/api/ml.find_file_structure.js#L25-L126 | train | Build an ML find file structure | [
30522,
3853,
3857,
19968,
16294,
20952,
9463,
3367,
6820,
14890,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
2279,
1011,
2240,
2053,
1011,
15171,
1011,
13075,
2015,
9530,
3367,
1063,
9338,
2063,
155... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js | reject | function reject(oError, vRequest) {
if (Array.isArray(vRequest)) {
vRequest.forEach(reject.bind(null, oError));
} else {
vRequest.$reject(oError);
}
} | javascript | function reject(oError, vRequest) {
if (Array.isArray(vRequest)) {
vRequest.forEach(reject.bind(null, oError));
} else {
vRequest.$reject(oError);
}
} | [
"function",
"reject",
"(",
"oError",
",",
"vRequest",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"vRequest",
")",
")",
"{",
"vRequest",
".",
"forEach",
"(",
"reject",
".",
"bind",
"(",
"null",
",",
"oError",
")",
")",
";",
"}",
"else",
"{",... | /*
(Recursively) rejects the request(s) with the given error
@param {Error} oError
@param {object|object[]} vRequest | [
"/",
"*",
"(",
"Recursively",
")",
"rejects",
"the",
"request",
"(",
"s",
")",
"with",
"the",
"given",
"error"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js#L1385-L1391 | train | rejects all the errors in the request | [
30522,
3853,
15454,
1006,
1051,
2121,
29165,
1010,
27830,
2063,
15500,
1007,
1063,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
27830,
2063,
15500,
1007,
1007,
1063,
27830,
2063,
15500,
1012,
18921,
6776,
1006,
15454,
1012,
14187,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/blanket.js | parseFunctionSourceElements | function parseFunctionSourceElements() {
var sourceElement, sourceElements = [], token, directive, firstRestricted,
oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken;
startToken = lookahead;
expect('{');
while (index < length) {
if (lookahead.type !== Token.StringLiteral) {
break;
}
token = lookahead;
sourceElement = parseSourceElement();
sourceElements.push(sourceElement);
if (sourceElement.expression.type !== Syntax.Literal) {
// this is not directive
break;
}
directive = source.slice(token.start + 1, token.end - 1);
if (directive === 'use strict') {
strict = true;
if (firstRestricted) {
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
}
} else {
if (!firstRestricted && token.octal) {
firstRestricted = token;
}
}
}
oldLabelSet = state.labelSet;
oldInIteration = state.inIteration;
oldInSwitch = state.inSwitch;
oldInFunctionBody = state.inFunctionBody;
state.labelSet = {};
state.inIteration = false;
state.inSwitch = false;
state.inFunctionBody = true;
while (index < length) {
if (match('}')) {
break;
}
sourceElement = parseSourceElement();
if (typeof sourceElement === 'undefined') {
break;
}
sourceElements.push(sourceElement);
}
expect('}');
state.labelSet = oldLabelSet;
state.inIteration = oldInIteration;
state.inSwitch = oldInSwitch;
state.inFunctionBody = oldInFunctionBody;
return delegate.markEnd(delegate.createBlockStatement(sourceElements), startToken);
} | javascript | function parseFunctionSourceElements() {
var sourceElement, sourceElements = [], token, directive, firstRestricted,
oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, startToken;
startToken = lookahead;
expect('{');
while (index < length) {
if (lookahead.type !== Token.StringLiteral) {
break;
}
token = lookahead;
sourceElement = parseSourceElement();
sourceElements.push(sourceElement);
if (sourceElement.expression.type !== Syntax.Literal) {
// this is not directive
break;
}
directive = source.slice(token.start + 1, token.end - 1);
if (directive === 'use strict') {
strict = true;
if (firstRestricted) {
throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
}
} else {
if (!firstRestricted && token.octal) {
firstRestricted = token;
}
}
}
oldLabelSet = state.labelSet;
oldInIteration = state.inIteration;
oldInSwitch = state.inSwitch;
oldInFunctionBody = state.inFunctionBody;
state.labelSet = {};
state.inIteration = false;
state.inSwitch = false;
state.inFunctionBody = true;
while (index < length) {
if (match('}')) {
break;
}
sourceElement = parseSourceElement();
if (typeof sourceElement === 'undefined') {
break;
}
sourceElements.push(sourceElement);
}
expect('}');
state.labelSet = oldLabelSet;
state.inIteration = oldInIteration;
state.inSwitch = oldInSwitch;
state.inFunctionBody = oldInFunctionBody;
return delegate.markEnd(delegate.createBlockStatement(sourceElements), startToken);
} | [
"function",
"parseFunctionSourceElements",
"(",
")",
"{",
"var",
"sourceElement",
",",
"sourceElements",
"=",
"[",
"]",
",",
"token",
",",
"directive",
",",
"firstRestricted",
",",
"oldLabelSet",
",",
"oldInIteration",
",",
"oldInSwitch",
",",
"oldInFunctionBody",
... | 13 Function Definition | [
"13",
"Function",
"Definition"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L3276-L3337 | train | ECMA - 262 12. 2 Function Definition | [
30522,
3853,
11968,
20106,
4609,
22014,
8162,
3401,
12260,
8163,
1006,
1007,
1063,
13075,
3120,
12260,
3672,
1010,
3120,
12260,
8163,
1027,
1031,
1033,
1010,
19204,
1010,
16449,
1010,
2034,
28533,
20623,
1010,
2214,
20470,
9050,
3388,
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/extensions/default/CommandLineTool/main.js | addCommand | function addCommand() {
var menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU),
INSTALL_COMMAND_SCRIPT = "file.installCommandScript";
CommandManager.register(Strings.CMD_LAUNCH_SCRIPT_MAC, INSTALL_COMMAND_SCRIPT, handleInstallCommand);
menu.addMenuDivider();
menu.addMenuItem(INSTALL_COMMAND_SCRIPT);
} | javascript | function addCommand() {
var menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU),
INSTALL_COMMAND_SCRIPT = "file.installCommandScript";
CommandManager.register(Strings.CMD_LAUNCH_SCRIPT_MAC, INSTALL_COMMAND_SCRIPT, handleInstallCommand);
menu.addMenuDivider();
menu.addMenuItem(INSTALL_COMMAND_SCRIPT);
} | [
"function",
"addCommand",
"(",
")",
"{",
"var",
"menu",
"=",
"Menus",
".",
"getMenu",
"(",
"Menus",
".",
"AppMenuBar",
".",
"FILE_MENU",
")",
",",
"INSTALL_COMMAND_SCRIPT",
"=",
"\"file.installCommandScript\"",
";",
"CommandManager",
".",
"register",
"(",
"Strin... | Register the command and add the menu to file menu. | [
"Register",
"the",
"command",
"and",
"add",
"the",
"menu",
"to",
"file",
"menu",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CommandLineTool/main.js#L97-L105 | train | Adds a command to the command menu | [
30522,
3853,
5587,
9006,
2386,
2094,
1006,
1007,
1063,
13075,
12183,
1027,
12183,
2015,
1012,
2131,
3549,
2226,
1006,
12183,
2015,
1012,
10439,
3549,
19761,
2099,
1012,
5371,
1035,
12183,
1007,
1010,
16500,
1035,
3094,
1035,
5896,
1027,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
KaTeX/KaTeX | contrib/mhchem/mhchem.js | function (tokens, stateMachine) {
// Recreate the argument string from KaTeX's array of tokens.
var str = "";
var expectedLoc = tokens[tokens.length - 1].loc.start
for (var i = tokens.length - 1; i >= 0; i--) {
if(tokens[i].loc.start > expectedLoc) {
// context.consumeArgs has eaten a space.
str += " ";
expectedLoc = tokens[i].loc.start;
}
str += tokens[i].text;
expectedLoc += tokens[i].text.length;
}
var tex = texify.go(mhchemParser.go(str, stateMachine));
return tex;
} | javascript | function (tokens, stateMachine) {
// Recreate the argument string from KaTeX's array of tokens.
var str = "";
var expectedLoc = tokens[tokens.length - 1].loc.start
for (var i = tokens.length - 1; i >= 0; i--) {
if(tokens[i].loc.start > expectedLoc) {
// context.consumeArgs has eaten a space.
str += " ";
expectedLoc = tokens[i].loc.start;
}
str += tokens[i].text;
expectedLoc += tokens[i].text.length;
}
var tex = texify.go(mhchemParser.go(str, stateMachine));
return tex;
} | [
"function",
"(",
"tokens",
",",
"stateMachine",
")",
"{",
"// Recreate the argument string from KaTeX's array of tokens.",
"var",
"str",
"=",
"\"\"",
";",
"var",
"expectedLoc",
"=",
"tokens",
"[",
"tokens",
".",
"length",
"-",
"1",
"]",
".",
"loc",
".",
"start",... | This is the main function for handing the \ce and \pu commands. It takes the argument to \ce or \pu and returns the corresponding TeX string. | [
"This",
"is",
"the",
"main",
"function",
"for",
"handing",
"the",
"\\",
"ce",
"and",
"\\",
"pu",
"commands",
".",
"It",
"takes",
"the",
"argument",
"to",
"\\",
"ce",
"or",
"\\",
"pu",
"and",
"returns",
"the",
"corresponding",
"TeX",
"string",
"."
] | 17bfb247b88070267f3e5c7b21fe4a360fdf49d9 | https://github.com/KaTeX/KaTeX/blob/17bfb247b88070267f3e5c7b21fe4a360fdf49d9/contrib/mhchem/mhchem.js#L77-L92 | train | Parse a KaTeX string | [
30522,
3853,
1006,
19204,
2015,
1010,
2110,
22911,
14014,
1007,
1063,
1013,
1013,
28667,
29313,
1996,
6685,
5164,
2013,
5736,
2595,
1005,
1055,
9140,
1997,
19204,
2015,
1012,
13075,
2358,
2099,
1027,
1000,
1000,
1025,
13075,
3517,
4135,
227... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
liriliri/eruda | src/lib/stringify.js | sortObjName | function sortObjName(a, b) {
let lenA = a.length
let lenB = b.length
let len = lenA > lenB ? lenB : lenA
for (let i = 0; i < len; i++) {
let codeA = a.charCodeAt(i)
let codeB = b.charCodeAt(i)
let cmpResult = cmpCode(codeA, codeB)
if (cmpResult !== 0) return cmpResult
}
if (lenA > lenB) return 1
if (lenA < lenB) return -1
return 0
} | javascript | function sortObjName(a, b) {
let lenA = a.length
let lenB = b.length
let len = lenA > lenB ? lenB : lenA
for (let i = 0; i < len; i++) {
let codeA = a.charCodeAt(i)
let codeB = b.charCodeAt(i)
let cmpResult = cmpCode(codeA, codeB)
if (cmpResult !== 0) return cmpResult
}
if (lenA > lenB) return 1
if (lenA < lenB) return -1
return 0
} | [
"function",
"sortObjName",
"(",
"a",
",",
"b",
")",
"{",
"let",
"lenA",
"=",
"a",
".",
"length",
"let",
"lenB",
"=",
"b",
".",
"length",
"let",
"len",
"=",
"lenA",
">",
"lenB",
"?",
"lenB",
":",
"lenA",
"for",
"(",
"let",
"i",
"=",
"0",
";",
... | $, upperCase, lowerCase, _ | [
"$",
"upperCase",
"lowerCase",
"_"
] | 93e1c2e6fbe57853135435297b9bb166fc4b2620 | https://github.com/liriliri/eruda/blob/93e1c2e6fbe57853135435297b9bb166fc4b2620/src/lib/stringify.js#L202-L219 | train | Sort object name by code | [
30522,
3853,
4066,
16429,
22895,
14074,
1006,
1037,
1010,
1038,
1007,
1063,
2292,
14229,
1027,
1037,
1012,
3091,
2292,
18798,
2497,
1027,
1038,
1012,
3091,
2292,
18798,
1027,
14229,
1028,
18798,
2497,
1029,
18798,
2497,
1024,
14229,
2005,
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/mxClient.js | function(evt)
{
return (evt.pointerType != null) ? (evt.pointerType == 'pen' || evt.pointerType ===
evt.MSPOINTER_TYPE_PEN) : ((evt.mozInputSource != null) ?
evt.mozInputSource == 2 : evt.type.indexOf('pen') == 0);
} | javascript | function(evt)
{
return (evt.pointerType != null) ? (evt.pointerType == 'pen' || evt.pointerType ===
evt.MSPOINTER_TYPE_PEN) : ((evt.mozInputSource != null) ?
evt.mozInputSource == 2 : evt.type.indexOf('pen') == 0);
} | [
"function",
"(",
"evt",
")",
"{",
"return",
"(",
"evt",
".",
"pointerType",
"!=",
"null",
")",
"?",
"(",
"evt",
".",
"pointerType",
"==",
"'pen'",
"||",
"evt",
".",
"pointerType",
"===",
"evt",
".",
"MSPOINTER_TYPE_PEN",
")",
":",
"(",
"(",
"evt",
".... | Function: isPenEvent
Returns true if the event was generated using a pen (not a touch device or mouse). | [
"Function",
":",
"isPenEvent"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L9835-L9840 | train | Returns true if the event is a pointer event | [
30522,
3853,
1006,
23408,
2102,
1007,
1063,
2709,
1006,
23408,
2102,
1012,
20884,
13874,
999,
1027,
19701,
1007,
1029,
1006,
23408,
2102,
1012,
20884,
13874,
1027,
1027,
1005,
7279,
1005,
1064,
1064,
23408,
2102,
1012,
20884,
13874,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/core/util/util.js | throttle | function throttle(func, delay) {
var recent;
return function throttled() {
var context = this;
var args = arguments;
var now = $mdUtil.now();
if (!recent || (now - recent > delay)) {
func.apply(context, args);
recent = now;
}
};
} | javascript | function throttle(func, delay) {
var recent;
return function throttled() {
var context = this;
var args = arguments;
var now = $mdUtil.now();
if (!recent || (now - recent > delay)) {
func.apply(context, args);
recent = now;
}
};
} | [
"function",
"throttle",
"(",
"func",
",",
"delay",
")",
"{",
"var",
"recent",
";",
"return",
"function",
"throttled",
"(",
")",
"{",
"var",
"context",
"=",
"this",
";",
"var",
"args",
"=",
"arguments",
";",
"var",
"now",
"=",
"$mdUtil",
".",
"now",
"... | Returns a function that can only be triggered every `delay` milliseconds. In other words, the function will not be called unless it has been more than `delay` milliseconds since the last call. | [
"Returns",
"a",
"function",
"that",
"can",
"only",
"be",
"triggered",
"every",
"delay",
"milliseconds",
".",
"In",
"other",
"words",
"the",
"function",
"will",
"not",
"be",
"called",
"unless",
"it",
"has",
"been",
"more",
"than",
"delay",
"milliseconds",
"si... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L447-L459 | train | Returns a function that will be called every delay milliseconds. | [
30522,
3853,
24420,
1006,
4569,
2278,
1010,
8536,
1007,
1063,
13075,
3522,
1025,
2709,
3853,
24420,
2094,
1006,
1007,
1063,
13075,
6123,
1027,
2023,
1025,
13075,
12098,
5620,
1027,
9918,
1025,
13075,
2085,
1027,
1002,
9108,
21823,
2140,
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/thirdparty/less.js | function(isRule) {
var elements, e, index = i, option, extendList, extend;
if (!(isRule ? $re(/^&:extend\(/) : $re(/^:extend\(/))) { return; }
do {
option = null;
elements = null;
while (! (option = $re(/^(all)(?=\s*(\)|,))/))) {
e = this.element();
if (!e) { break; }
if (elements) { elements.push(e); } else { elements = [ e ]; }
}
option = option && option[1];
extend = new(tree.Extend)(new(tree.Selector)(elements), option, index);
if (extendList) { extendList.push(extend); } else { extendList = [ extend ]; }
} while($char(","));
expect(/^\)/);
if (isRule) {
expect(/^;/);
}
return extendList;
} | javascript | function(isRule) {
var elements, e, index = i, option, extendList, extend;
if (!(isRule ? $re(/^&:extend\(/) : $re(/^:extend\(/))) { return; }
do {
option = null;
elements = null;
while (! (option = $re(/^(all)(?=\s*(\)|,))/))) {
e = this.element();
if (!e) { break; }
if (elements) { elements.push(e); } else { elements = [ e ]; }
}
option = option && option[1];
extend = new(tree.Extend)(new(tree.Selector)(elements), option, index);
if (extendList) { extendList.push(extend); } else { extendList = [ extend ]; }
} while($char(","));
expect(/^\)/);
if (isRule) {
expect(/^;/);
}
return extendList;
} | [
"function",
"(",
"isRule",
")",
"{",
"var",
"elements",
",",
"e",
",",
"index",
"=",
"i",
",",
"option",
",",
"extendList",
",",
"extend",
";",
"if",
"(",
"!",
"(",
"isRule",
"?",
"$re",
"(",
"/",
"^&:extend\\(",
"/",
")",
":",
"$re",
"(",
"/",
... | extend syntax - used to extend selectors | [
"extend",
"syntax",
"-",
"used",
"to",
"extend",
"selectors"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L1060-L1088 | train | returns extend list | [
30522,
3853,
1006,
2003,
6820,
2571,
1007,
1063,
13075,
3787,
1010,
1041,
1010,
5950,
1027,
1045,
1010,
5724,
1010,
7949,
9863,
1010,
7949,
1025,
2065,
1006,
999,
1006,
2003,
6820,
2571,
1029,
1002,
2128,
1006,
1013,
1034,
1004,
1024,
794... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.datasetController.js | unlistenArrayEvents | function unlistenArrayEvents(array, listener) {
var stub = array._chartjs;
if (!stub) {
return;
}
var listeners = stub.listeners;
var index = listeners.indexOf(listener);
if (index !== -1) {
listeners.splice(index, 1);
}
if (listeners.length > 0) {
return;
}
arrayEvents.forEach(function(key) {
delete array[key];
});
delete array._chartjs;
} | javascript | function unlistenArrayEvents(array, listener) {
var stub = array._chartjs;
if (!stub) {
return;
}
var listeners = stub.listeners;
var index = listeners.indexOf(listener);
if (index !== -1) {
listeners.splice(index, 1);
}
if (listeners.length > 0) {
return;
}
arrayEvents.forEach(function(key) {
delete array[key];
});
delete array._chartjs;
} | [
"function",
"unlistenArrayEvents",
"(",
"array",
",",
"listener",
")",
"{",
"var",
"stub",
"=",
"array",
".",
"_chartjs",
";",
"if",
"(",
"!",
"stub",
")",
"{",
"return",
";",
"}",
"var",
"listeners",
"=",
"stub",
".",
"listeners",
";",
"var",
"index",... | Removes the given array event listener and cleanup extra attached properties (such as
the _chartjs stub and overridden methods) if array doesn't have any more listeners. | [
"Removes",
"the",
"given",
"array",
"event",
"listener",
"and",
"cleanup",
"extra",
"attached",
"properties",
"(",
"such",
"as",
"the",
"_chartjs",
"stub",
"and",
"overridden",
"methods",
")",
"if",
"array",
"doesn",
"t",
"have",
"any",
"more",
"listeners",
... | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.datasetController.js#L55-L76 | train | Unlisten an array event listener | [
30522,
3853,
4895,
9863,
8189,
11335,
17240,
11187,
1006,
9140,
1010,
19373,
1007,
1063,
13075,
24646,
2497,
1027,
9140,
1012,
1035,
3673,
22578,
1025,
2065,
1006,
999,
24646,
2497,
1007,
1063,
2709,
1025,
1065,
13075,
13810,
1027,
24646,
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... |
aframevr/aframe | src/components/look-controls.js | function (evt) {
if (evt.touches.length !== 1 || !this.data.touchEnabled) { return; }
this.touchStart = {
x: evt.touches[0].pageX,
y: evt.touches[0].pageY
};
this.touchStarted = true;
} | javascript | function (evt) {
if (evt.touches.length !== 1 || !this.data.touchEnabled) { return; }
this.touchStart = {
x: evt.touches[0].pageX,
y: evt.touches[0].pageY
};
this.touchStarted = true;
} | [
"function",
"(",
"evt",
")",
"{",
"if",
"(",
"evt",
".",
"touches",
".",
"length",
"!==",
"1",
"||",
"!",
"this",
".",
"data",
".",
"touchEnabled",
")",
"{",
"return",
";",
"}",
"this",
".",
"touchStart",
"=",
"{",
"x",
":",
"evt",
".",
"touches"... | Register touch down to detect touch drag. | [
"Register",
"touch",
"down",
"to",
"detect",
"touch",
"drag",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/look-controls.js#L304-L311 | train | touchstart event handler | [
30522,
3853,
1006,
23408,
2102,
1007,
1063,
2065,
1006,
23408,
2102,
1012,
12817,
1012,
3091,
999,
1027,
1027,
1015,
1064,
1064,
999,
2023,
1012,
2951,
1012,
3543,
8189,
23242,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
3543,
14117,
2102,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/autocomplete/demoFloatingLabel/script.js | createFilterFor | function createFilterFor(query) {
var lowercaseQuery = query.toLowerCase();
return function filterFn(state) {
return (state.value.indexOf(lowercaseQuery) === 0);
};
} | javascript | function createFilterFor(query) {
var lowercaseQuery = query.toLowerCase();
return function filterFn(state) {
return (state.value.indexOf(lowercaseQuery) === 0);
};
} | [
"function",
"createFilterFor",
"(",
"query",
")",
"{",
"var",
"lowercaseQuery",
"=",
"query",
".",
"toLowerCase",
"(",
")",
";",
"return",
"function",
"filterFn",
"(",
"state",
")",
"{",
"return",
"(",
"state",
".",
"value",
".",
"indexOf",
"(",
"lowercase... | Create filter function for a query string | [
"Create",
"filter",
"function",
"for",
"a",
"query",
"string"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/demoFloatingLabel/script.js#L54-L61 | train | Create a filter function for a given query | [
30522,
3853,
3443,
8873,
21928,
29278,
1006,
23032,
1007,
1063,
13075,
2896,
18382,
4226,
2854,
1027,
23032,
1012,
2000,
27663,
18992,
3366,
1006,
1007,
1025,
2709,
3853,
11307,
2546,
2078,
1006,
2110,
1007,
1063,
2709,
1006,
2110,
1012,
36... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getinsomnia/insomnia | packages/insomnia-app/app/ui/redux/modules/global.js | activeWorkspaceReducer | function activeWorkspaceReducer(state = null, action) {
switch (action.type) {
case SET_ACTIVE_WORKSPACE:
return action.workspaceId;
default:
return state;
}
} | javascript | function activeWorkspaceReducer(state = null, action) {
switch (action.type) {
case SET_ACTIVE_WORKSPACE:
return action.workspaceId;
default:
return state;
}
} | [
"function",
"activeWorkspaceReducer",
"(",
"state",
"=",
"null",
",",
"action",
")",
"{",
"switch",
"(",
"action",
".",
"type",
")",
"{",
"case",
"SET_ACTIVE_WORKSPACE",
":",
"return",
"action",
".",
"workspaceId",
";",
"default",
":",
"return",
"state",
";"... | ~~~~~~~~ // REDUCERS // ~~~~~~~~ // | [
"~~~~~~~~",
"//",
"REDUCERS",
"//",
"~~~~~~~~",
"//"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-app/app/ui/redux/modules/global.js#L35-L42 | train | A workspace reducer that can be used to update the active workspace | [
30522,
3853,
3161,
9316,
15327,
5596,
18796,
2099,
1006,
2110,
1027,
19701,
1010,
2895,
1007,
1063,
6942,
1006,
2895,
1012,
2828,
1007,
1063,
2553,
2275,
1035,
3161,
1035,
2573,
15327,
1024,
2709,
2895,
1012,
2573,
15327,
3593,
1025,
12398,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc-node | packages/grpc-native-core/src/client_interceptors.js | getLastListener | function getLastListener(method_definition, emitter, callback) {
if (emitter instanceof Function) {
callback = emitter;
callback = function() {};
}
if (!(callback instanceof Function)) {
callback = function() {};
}
if (!((emitter instanceof EventEmitter) &&
(callback instanceof Function))) {
throw new Error('Argument mismatch in getLastListener');
}
var method_type = common.getMethodType(method_definition);
var generator = listenerGenerators[method_type];
return generator(method_definition, emitter, callback);
} | javascript | function getLastListener(method_definition, emitter, callback) {
if (emitter instanceof Function) {
callback = emitter;
callback = function() {};
}
if (!(callback instanceof Function)) {
callback = function() {};
}
if (!((emitter instanceof EventEmitter) &&
(callback instanceof Function))) {
throw new Error('Argument mismatch in getLastListener');
}
var method_type = common.getMethodType(method_definition);
var generator = listenerGenerators[method_type];
return generator(method_definition, emitter, callback);
} | [
"function",
"getLastListener",
"(",
"method_definition",
",",
"emitter",
",",
"callback",
")",
"{",
"if",
"(",
"emitter",
"instanceof",
"Function",
")",
"{",
"callback",
"=",
"emitter",
";",
"callback",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}",
"if",
... | Creates the last listener in an interceptor stack.
@param {grpc~MethodDefinition} method_definition
@param {EventEmitter} emitter
@param {function=} callback
@return {grpc~Listener} | [
"Creates",
"the",
"last",
"listener",
"in",
"an",
"interceptor",
"stack",
"."
] | b36b285f4cdb334bbd48f74c12c13bec69961488 | https://github.com/grpc/grpc-node/blob/b36b285f4cdb334bbd48f74c12c13bec69961488/packages/grpc-native-core/src/client_interceptors.js#L1332-L1347 | train | Returns the last listener | [
30522,
3853,
2131,
8523,
19646,
27870,
3678,
1006,
4118,
1035,
6210,
1010,
12495,
12079,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
12495,
12079,
6013,
11253,
3853,
1007,
1063,
2655,
5963,
1027,
12495,
12079,
1025,
2655,
5963,
1027,
3853,
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.f/src/sap/f/GridContainerSettings.js | cssSizeToPx | function cssSizeToPx(sCssSize) {
if (sCssSize === 0 || sCssSize === "0") {
return 0;
}
var aMatch = sCssSize.match(/^(\d+(\.\d+)?)(px|rem)$/),
iValue;
if (aMatch) {
if (aMatch[3] === "px") {
iValue = parseFloat(aMatch[1]);
} else {
iValue = Rem.toPx(parseFloat(aMatch[1]));
}
} else {
Log.error("Css size '" + sCssSize + "' is not supported for GridContainer. Only 'px' and 'rem' are supported.");
iValue = NaN;
}
return Math.ceil(iValue);
} | javascript | function cssSizeToPx(sCssSize) {
if (sCssSize === 0 || sCssSize === "0") {
return 0;
}
var aMatch = sCssSize.match(/^(\d+(\.\d+)?)(px|rem)$/),
iValue;
if (aMatch) {
if (aMatch[3] === "px") {
iValue = parseFloat(aMatch[1]);
} else {
iValue = Rem.toPx(parseFloat(aMatch[1]));
}
} else {
Log.error("Css size '" + sCssSize + "' is not supported for GridContainer. Only 'px' and 'rem' are supported.");
iValue = NaN;
}
return Math.ceil(iValue);
} | [
"function",
"cssSizeToPx",
"(",
"sCssSize",
")",
"{",
"if",
"(",
"sCssSize",
"===",
"0",
"||",
"sCssSize",
"===",
"\"0\"",
")",
"{",
"return",
"0",
";",
"}",
"var",
"aMatch",
"=",
"sCssSize",
".",
"match",
"(",
"/",
"^(\\d+(\\.\\d+)?)(px|rem)$",
"/",
")"... | Converts the given css size to its corresponding 'px' value.
@private
@param {string} sCssSize The css size to parse. For example '5rem'.
@returns {int} The size in 'px'. The result is rounded up with Math.ceil(). Returns NaN if the size can not be parsed. | [
"Converts",
"the",
"given",
"css",
"size",
"to",
"its",
"corresponding",
"px",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.f/src/sap/f/GridContainerSettings.js#L22-L41 | train | Converts a CSS size to px | [
30522,
3853,
20116,
18719,
4371,
14399,
2595,
1006,
8040,
4757,
5332,
4371,
1007,
1063,
2065,
1006,
8040,
4757,
5332,
4371,
1027,
1027,
1027,
1014,
1064,
1064,
8040,
4757,
5332,
4371,
1027,
1027,
1027,
1000,
1014,
1000,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/InlineColorEditor/main.js | inlineColorEditorProvider | function inlineColorEditorProvider(hostEditor, pos) {
var context = prepareEditorForProvider(hostEditor, pos),
inlineColorEditor,
result;
if (!context) {
return null;
} else {
inlineColorEditor = new InlineColorEditor(context.color, context.marker);
inlineColorEditor.load(hostEditor);
result = new $.Deferred();
result.resolve(inlineColorEditor);
return result.promise();
}
} | javascript | function inlineColorEditorProvider(hostEditor, pos) {
var context = prepareEditorForProvider(hostEditor, pos),
inlineColorEditor,
result;
if (!context) {
return null;
} else {
inlineColorEditor = new InlineColorEditor(context.color, context.marker);
inlineColorEditor.load(hostEditor);
result = new $.Deferred();
result.resolve(inlineColorEditor);
return result.promise();
}
} | [
"function",
"inlineColorEditorProvider",
"(",
"hostEditor",
",",
"pos",
")",
"{",
"var",
"context",
"=",
"prepareEditorForProvider",
"(",
"hostEditor",
",",
"pos",
")",
",",
"inlineColorEditor",
",",
"result",
";",
"if",
"(",
"!",
"context",
")",
"{",
"return"... | Registered as an inline editor provider: creates an InlineEditorColor when the cursor
is on a color value (in any flavor of code).
@param {!Editor} hostEditor
@param {!{line:Number, ch:Number}} pos
@return {?$.Promise} synchronously resolved with an InlineWidget, or null if there's
no color at pos. | [
"Registered",
"as",
"an",
"inline",
"editor",
"provider",
":",
"creates",
"an",
"InlineEditorColor",
"when",
"the",
"cursor",
"is",
"on",
"a",
"color",
"value",
"(",
"in",
"any",
"flavor",
"of",
"code",
")",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/main.js#L88-L103 | train | InlineColorEditorProvider - Provider for InlineColorEditor | [
30522,
3853,
23881,
18717,
2098,
15660,
21572,
17258,
2121,
1006,
4354,
15660,
1010,
13433,
2015,
1007,
1063,
13075,
6123,
1027,
7374,
2098,
15660,
29278,
21572,
17258,
2121,
1006,
4354,
15660,
1010,
13433,
2015,
1007,
1010,
23881,
18717,
209... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
tensorflow/tfjs-models | speech-commands/demo/dataset-vis.js | getCanvasClickRelativeXCoordinate | function getCanvasClickRelativeXCoordinate(canvasElement, event) {
let x;
if (event.pageX) {
x = event.pageX;
} else {
x = event.clientX + document.body.scrollLeft +
document.documentElement.scrollLeft;
}
x -= canvasElement.offsetLeft;
return x / canvasElement.width;
} | javascript | function getCanvasClickRelativeXCoordinate(canvasElement, event) {
let x;
if (event.pageX) {
x = event.pageX;
} else {
x = event.clientX + document.body.scrollLeft +
document.documentElement.scrollLeft;
}
x -= canvasElement.offsetLeft;
return x / canvasElement.width;
} | [
"function",
"getCanvasClickRelativeXCoordinate",
"(",
"canvasElement",
",",
"event",
")",
"{",
"let",
"x",
";",
"if",
"(",
"event",
".",
"pageX",
")",
"{",
"x",
"=",
"event",
".",
"pageX",
";",
"}",
"else",
"{",
"x",
"=",
"event",
".",
"clientX",
"+",
... | Get the relative x-coordinate of a click event in a canvas.
@param {HTMLCanvasElement} canvasElement The canvas in which the click
event happened.
@param {Event} event The click event object.
@return {number} The relative x-coordinate: a `number` between 0 and 1. | [
"Get",
"the",
"relative",
"x",
"-",
"coordinate",
"of",
"a",
"click",
"event",
"in",
"a",
"canvas",
"."
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/speech-commands/demo/dataset-vis.js#L41-L51 | train | Get the x coordinate of the click event relative to the canvas element | [
30522,
3853,
2131,
9336,
12044,
20464,
6799,
16570,
8082,
2595,
3597,
8551,
14776,
1006,
10683,
12260,
3672,
1010,
2724,
1007,
1063,
30524,
1025,
1065,
2842,
1063,
1060,
1027,
2724,
1012,
7396,
2595,
1009,
6254,
1012,
2303,
1012,
17186,
257... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/utils.js | formatUrlPref | function formatUrlPref(prefName) {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Ci.nsIURLFormatter);
return formatter.formatURLPref(prefName);
} | javascript | function formatUrlPref(prefName) {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Ci.nsIURLFormatter);
return formatter.formatURLPref(prefName);
} | [
"function",
"formatUrlPref",
"(",
"prefName",
")",
"{",
"var",
"formatter",
"=",
"Cc",
"[",
"\"@mozilla.org/toolkit/URLFormatterService;1\"",
"]",
".",
"getService",
"(",
"Ci",
".",
"nsIURLFormatter",
")",
";",
"return",
"formatter",
".",
"formatURLPref",
"(",
"pr... | Format a URL by replacing all placeholders
@param {string} prefName
The preference name which contains the URL
@return The formatted URL
@type string | [
"Format",
"a",
"URL",
"by",
"replacing",
"all",
"placeholders"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L281-L286 | train | Format a URL pref | [
30522,
3853,
4289,
3126,
14277,
2890,
2546,
1006,
3653,
2546,
18442,
1007,
1063,
13075,
4289,
3334,
1027,
10507,
1031,
1000,
1030,
9587,
5831,
4571,
1012,
8917,
1013,
6994,
23615,
1013,
24471,
10270,
2953,
18900,
7747,
2121,
7903,
2063,
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... |
exceljs/exceljs | lib/utils/stream-buf.js | function(target, targetOffset, offset, length) {
// eslint-disable-next-line no-underscore-dangle
return this._data._buf.copy(target, targetOffset, offset, length);
} | javascript | function(target, targetOffset, offset, length) {
// eslint-disable-next-line no-underscore-dangle
return this._data._buf.copy(target, targetOffset, offset, length);
} | [
"function",
"(",
"target",
",",
"targetOffset",
",",
"offset",
",",
"length",
")",
"{",
"// eslint-disable-next-line no-underscore-dangle",
"return",
"this",
".",
"_data",
".",
"_buf",
".",
"copy",
"(",
"target",
",",
"targetOffset",
",",
"offset",
",",
"length"... | copy to target buffer | [
"copy",
"to",
"target",
"buffer"
] | c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2 | https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/utils/stream-buf.js#L39-L42 | train | Copy the data to the specified buffer. | [
30522,
3853,
1006,
4539,
1010,
4539,
27475,
3388,
1010,
16396,
1010,
3091,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
2279,
1011,
2240,
2053,
1011,
2104,
9363,
2890,
1011,
4907,
9354,
2709,
2023,
1012,
1035,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/VersionInfo.js | transformVersionInfo | function transformVersionInfo() {
// get the transitive dependencies of the given libs from the sap.ui.versioninfo
// only do this once if mKnownLibs is not created yet
if (sap.ui.versioninfo && sap.ui.versioninfo.libraries && !mKnownLibs) {
// flatten dependency lists for all libs
mKnownLibs = {};
sap.ui.versioninfo.libraries.forEach(function(oLib, i) {
mKnownLibs[oLib.name] = {};
var mDeps = oLib.manifestHints && oLib.manifestHints.dependencies &&
oLib.manifestHints.dependencies.libs;
for (var sDep in mDeps) {
if (!mDeps[sDep].lazy) {
mKnownLibs[oLib.name][sDep] = true;
}
}
});
}
// get transitive dependencies for a component
if (sap.ui.versioninfo && sap.ui.versioninfo.components && !mKnownComponents) {
mKnownComponents = {};
Object.keys(sap.ui.versioninfo.components).forEach(function(sComponentName) {
var oComponentInfo = sap.ui.versioninfo.components[sComponentName];
mKnownComponents[sComponentName] = {
library: oComponentInfo.library,
dependencies: []
};
var mDeps = oComponentInfo.manifestHints && oComponentInfo.manifestHints.dependencies &&
oComponentInfo.manifestHints.dependencies.libs;
for (var sDep in mDeps) {
if (!mDeps[sDep].lazy) {
mKnownComponents[sComponentName].dependencies.push(sDep);
}
}
});
}
} | javascript | function transformVersionInfo() {
// get the transitive dependencies of the given libs from the sap.ui.versioninfo
// only do this once if mKnownLibs is not created yet
if (sap.ui.versioninfo && sap.ui.versioninfo.libraries && !mKnownLibs) {
// flatten dependency lists for all libs
mKnownLibs = {};
sap.ui.versioninfo.libraries.forEach(function(oLib, i) {
mKnownLibs[oLib.name] = {};
var mDeps = oLib.manifestHints && oLib.manifestHints.dependencies &&
oLib.manifestHints.dependencies.libs;
for (var sDep in mDeps) {
if (!mDeps[sDep].lazy) {
mKnownLibs[oLib.name][sDep] = true;
}
}
});
}
// get transitive dependencies for a component
if (sap.ui.versioninfo && sap.ui.versioninfo.components && !mKnownComponents) {
mKnownComponents = {};
Object.keys(sap.ui.versioninfo.components).forEach(function(sComponentName) {
var oComponentInfo = sap.ui.versioninfo.components[sComponentName];
mKnownComponents[sComponentName] = {
library: oComponentInfo.library,
dependencies: []
};
var mDeps = oComponentInfo.manifestHints && oComponentInfo.manifestHints.dependencies &&
oComponentInfo.manifestHints.dependencies.libs;
for (var sDep in mDeps) {
if (!mDeps[sDep].lazy) {
mKnownComponents[sComponentName].dependencies.push(sDep);
}
}
});
}
} | [
"function",
"transformVersionInfo",
"(",
")",
"{",
"// get the transitive dependencies of the given libs from the sap.ui.versioninfo",
"// only do this once if mKnownLibs is not created yet",
"if",
"(",
"sap",
".",
"ui",
".",
"versioninfo",
"&&",
"sap",
".",
"ui",
".",
"version... | Transforms the sap.ui.versioninfo to an easier consumable map. | [
"Transforms",
"the",
"sap",
".",
"ui",
".",
"versioninfo",
"to",
"an",
"easier",
"consumable",
"map",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/VersionInfo.js#L188-L229 | train | This function is called by sap. ui. version. js to get the transitive dependencies of all libs and all components from the sap. ui. versioninfo. libraries | [
30522,
3853,
10938,
27774,
2378,
14876,
1006,
1007,
1063,
1013,
1013,
2131,
1996,
6671,
3512,
12530,
15266,
1997,
1996,
2445,
5622,
5910,
2013,
1996,
20066,
1012,
21318,
1012,
2544,
2378,
14876,
1013,
1013,
2069,
2079,
2023,
2320,
2065,
123... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TableGrouping.js | function(oTable) {
if (!oTable.getEnableGrouping()) {
return;
}
var oBinding = Element.prototype.getBinding.call(oTable, "rows");
// check for grouping being supported or not (only for client ListBindings!!)
var oGroupBy = sap.ui.getCore().byId(oTable.getGroupBy());
var bIsSupported = oGroupBy && oGroupBy.getGrouped() && TableGrouping.TableUtils.isA(oBinding, "sap.ui.model.ClientListBinding");
// only enhance the binding if it has not been done yet and supported!
if (!bIsSupported || oBinding._modified) {
return;
}
// once the binding is modified we always return the modified binding
// and don't wanna modifiy the binding once again
oBinding._modified = true;
// set the table into grouping mode
TableGrouping.setGroupMode(oTable);
// we use sorting finally to sort the values and afterwards group them
var sPropertyName = oGroupBy.getSortProperty();
oBinding.sort(new Sorter(sPropertyName));
// fetch the contexts from the original binding
var iLength = oTable._getTotalRowCount(),
aContexts = oBinding.getContexts(0, iLength);
// add the context information for the group headers which are later on
// used for displaying the grouping information of each group
var sKey;
var iCounter = 0;
for (var i = iLength - 1; i >= 0; i--) {
var sNewKey = aContexts[i].getProperty(sPropertyName);
if (!sKey) {
sKey = sNewKey;
}
if (sKey !== sNewKey) {
var oGroupContext = aContexts[i + 1].getModel().getContext("/sap.ui.table.GroupInfo" + i);
oGroupContext.__groupInfo = {
oContext: aContexts[i + 1],
name: sKey,
count: iCounter,
groupHeader: true,
expanded: true
};
aContexts.splice(i + 1, 0,
oGroupContext
);
sKey = sNewKey;
iCounter = 0;
}
iCounter++;
}
var oGroupContext = aContexts[0].getModel().getContext("/sap.ui.table.GroupInfo");
oGroupContext.__groupInfo = {
oContext: aContexts[0],
name: sKey,
count: iCounter,
groupHeader: true,
expanded: true
};
aContexts.splice(0, 0, oGroupContext);
// extend the binding and hook into the relevant functions to provide access to the grouping information
// TODO: Unify this with the "look&feel" of the binding in the TreeTable --> _updateTableContent must only be implemented once
jQuery.extend(oBinding, {
getLength: function() {
return aContexts.length;
},
getContexts: function(iStartIndex, iLength) {
return aContexts.slice(iStartIndex, iStartIndex + iLength);
},
isGroupHeader: function(iIndex) {
var oContext = aContexts[iIndex];
return (oContext && oContext.__groupInfo && oContext.__groupInfo.groupHeader) === true;
},
getTitle: function(iIndex) {
var oContext = aContexts[iIndex];
return oContext && oContext.__groupInfo && oContext.__groupInfo.name + " - " + oContext.__groupInfo.count;
},
isExpanded: function(iIndex) {
var oContext = aContexts[iIndex];
return this.isGroupHeader(iIndex) && oContext.__groupInfo && oContext.__groupInfo.expanded;
},
expand: function(iIndex) {
if (this.isGroupHeader(iIndex) && !aContexts[iIndex].__groupInfo.expanded) {
for (var i = 0; i < aContexts[iIndex].__childs.length; i++) {
aContexts.splice(iIndex + 1 + i, 0, aContexts[iIndex].__childs[i]);
}
delete aContexts[iIndex].__childs;
aContexts[iIndex].__groupInfo.expanded = true;
this._fireChange();
}
},
collapse: function(iIndex) {
if (this.isGroupHeader(iIndex) && aContexts[iIndex].__groupInfo.expanded) {
aContexts[iIndex].__childs = aContexts.splice(iIndex + 1, aContexts[iIndex].__groupInfo.count);
aContexts[iIndex].__groupInfo.expanded = false;
this._fireChange();
}
},
toggleIndex: function(iIndex) {
if (this.isExpanded(iIndex)) {
this.collapse(iIndex);
} else {
this.expand(iIndex);
}
},
// For compatibility with TreeBinding adapters.
nodeHasChildren: function(oContext) {
if (!oContext || !oContext.__groupInfo) {
return false;
} else {
return oContext.__groupInfo.groupHeader === true;
}
},
getNodeByIndex: function(iIndex) {
return aContexts[iIndex];
}
});
// the table need to fetch the updated/changed contexts again, therefore requires the binding to fire a change event
oTable._mTimeouts.groupingFireBindingChange = oTable._mTimeouts.groupingFireBindingChange || window.setTimeout(
function() {oBinding._fireChange();}, 0);
} | javascript | function(oTable) {
if (!oTable.getEnableGrouping()) {
return;
}
var oBinding = Element.prototype.getBinding.call(oTable, "rows");
// check for grouping being supported or not (only for client ListBindings!!)
var oGroupBy = sap.ui.getCore().byId(oTable.getGroupBy());
var bIsSupported = oGroupBy && oGroupBy.getGrouped() && TableGrouping.TableUtils.isA(oBinding, "sap.ui.model.ClientListBinding");
// only enhance the binding if it has not been done yet and supported!
if (!bIsSupported || oBinding._modified) {
return;
}
// once the binding is modified we always return the modified binding
// and don't wanna modifiy the binding once again
oBinding._modified = true;
// set the table into grouping mode
TableGrouping.setGroupMode(oTable);
// we use sorting finally to sort the values and afterwards group them
var sPropertyName = oGroupBy.getSortProperty();
oBinding.sort(new Sorter(sPropertyName));
// fetch the contexts from the original binding
var iLength = oTable._getTotalRowCount(),
aContexts = oBinding.getContexts(0, iLength);
// add the context information for the group headers which are later on
// used for displaying the grouping information of each group
var sKey;
var iCounter = 0;
for (var i = iLength - 1; i >= 0; i--) {
var sNewKey = aContexts[i].getProperty(sPropertyName);
if (!sKey) {
sKey = sNewKey;
}
if (sKey !== sNewKey) {
var oGroupContext = aContexts[i + 1].getModel().getContext("/sap.ui.table.GroupInfo" + i);
oGroupContext.__groupInfo = {
oContext: aContexts[i + 1],
name: sKey,
count: iCounter,
groupHeader: true,
expanded: true
};
aContexts.splice(i + 1, 0,
oGroupContext
);
sKey = sNewKey;
iCounter = 0;
}
iCounter++;
}
var oGroupContext = aContexts[0].getModel().getContext("/sap.ui.table.GroupInfo");
oGroupContext.__groupInfo = {
oContext: aContexts[0],
name: sKey,
count: iCounter,
groupHeader: true,
expanded: true
};
aContexts.splice(0, 0, oGroupContext);
// extend the binding and hook into the relevant functions to provide access to the grouping information
// TODO: Unify this with the "look&feel" of the binding in the TreeTable --> _updateTableContent must only be implemented once
jQuery.extend(oBinding, {
getLength: function() {
return aContexts.length;
},
getContexts: function(iStartIndex, iLength) {
return aContexts.slice(iStartIndex, iStartIndex + iLength);
},
isGroupHeader: function(iIndex) {
var oContext = aContexts[iIndex];
return (oContext && oContext.__groupInfo && oContext.__groupInfo.groupHeader) === true;
},
getTitle: function(iIndex) {
var oContext = aContexts[iIndex];
return oContext && oContext.__groupInfo && oContext.__groupInfo.name + " - " + oContext.__groupInfo.count;
},
isExpanded: function(iIndex) {
var oContext = aContexts[iIndex];
return this.isGroupHeader(iIndex) && oContext.__groupInfo && oContext.__groupInfo.expanded;
},
expand: function(iIndex) {
if (this.isGroupHeader(iIndex) && !aContexts[iIndex].__groupInfo.expanded) {
for (var i = 0; i < aContexts[iIndex].__childs.length; i++) {
aContexts.splice(iIndex + 1 + i, 0, aContexts[iIndex].__childs[i]);
}
delete aContexts[iIndex].__childs;
aContexts[iIndex].__groupInfo.expanded = true;
this._fireChange();
}
},
collapse: function(iIndex) {
if (this.isGroupHeader(iIndex) && aContexts[iIndex].__groupInfo.expanded) {
aContexts[iIndex].__childs = aContexts.splice(iIndex + 1, aContexts[iIndex].__groupInfo.count);
aContexts[iIndex].__groupInfo.expanded = false;
this._fireChange();
}
},
toggleIndex: function(iIndex) {
if (this.isExpanded(iIndex)) {
this.collapse(iIndex);
} else {
this.expand(iIndex);
}
},
// For compatibility with TreeBinding adapters.
nodeHasChildren: function(oContext) {
if (!oContext || !oContext.__groupInfo) {
return false;
} else {
return oContext.__groupInfo.groupHeader === true;
}
},
getNodeByIndex: function(iIndex) {
return aContexts[iIndex];
}
});
// the table need to fetch the updated/changed contexts again, therefore requires the binding to fire a change event
oTable._mTimeouts.groupingFireBindingChange = oTable._mTimeouts.groupingFireBindingChange || window.setTimeout(
function() {oBinding._fireChange();}, 0);
} | [
"function",
"(",
"oTable",
")",
"{",
"if",
"(",
"!",
"oTable",
".",
"getEnableGrouping",
"(",
")",
")",
"{",
"return",
";",
"}",
"var",
"oBinding",
"=",
"Element",
".",
"prototype",
".",
"getBinding",
".",
"call",
"(",
"oTable",
",",
"\"rows\"",
")",
... | /*
EXPERIMENTAL Grouping Feature of sap.ui.table.Table:
Overrides the getBinding to inject the grouping information into the JSON model.
TODO:
- Grouping is not really possible for models based on OData:
- it works when loading data from the beginning because in this case the
model has the relevant information (distinct values) to determine the
count of rows and add them properly in the scrollbar as well as adding
the group information to the contexts array which is used by the
_modifyRow to display the group headers
- it doesn't work when not knowing how many groups are available before
and on which position the group header has to be added - e.g. when
displaying a snapshot in the middle of the model.
- For OData it might be a server-side feature?
Initializes the experimental grouping for sap.ui.table.Table.
@param {sap.ui.table.Table} oTable Instance of the table. | [
"/",
"*",
"EXPERIMENTAL",
"Grouping",
"Feature",
"of",
"sap",
".",
"ui",
".",
"table",
".",
"Table",
":"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableGrouping.js#L545-L674 | train | Returns the binding for the table rows | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1012,
2131,
8189,
3468,
17058,
2075,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
13075,
27885,
22254,
2075,
1027,
5783,
1012,
8773,
1012,
2131,
8428,
4667,
1012,
2655,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
var sPeerParamPropName = null;
if (this._oLowerIntervalBoundaryParameterProperty) {
sPeerParamPropName = this._oLowerIntervalBoundaryParameterProperty.name;
} else {
sPeerParamPropName = this._oUpperIntervalBoundaryParameterProperty.name;
}
if (!sPeerParamPropName) {
throw "Parameter is not an interval boundary";
}
return this._oParameterization.findParameterByName(sPeerParamPropName);
} | javascript | function() {
var sPeerParamPropName = null;
if (this._oLowerIntervalBoundaryParameterProperty) {
sPeerParamPropName = this._oLowerIntervalBoundaryParameterProperty.name;
} else {
sPeerParamPropName = this._oUpperIntervalBoundaryParameterProperty.name;
}
if (!sPeerParamPropName) {
throw "Parameter is not an interval boundary";
}
return this._oParameterization.findParameterByName(sPeerParamPropName);
} | [
"function",
"(",
")",
"{",
"var",
"sPeerParamPropName",
"=",
"null",
";",
"if",
"(",
"this",
".",
"_oLowerIntervalBoundaryParameterProperty",
")",
"{",
"sPeerParamPropName",
"=",
"this",
".",
"_oLowerIntervalBoundaryParameterProperty",
".",
"name",
";",
"}",
"else",... | Get property for the parameter representing the peer boundary of the same
interval
@returns {sap.ui.model.analytics.odata4analytics.Parameter} The parameter representing
the peer boundary of the same interval. This means that if
*this* parameter is a lower boundary, the returned object
@public
@function
@name sap.ui.model.analytics.odata4analytics.Parameter#getPeerIntervalBoundaryParameter | [
"Get",
"property",
"for",
"the",
"parameter",
"representing",
"the",
"peer",
"boundary",
"of",
"the",
"same",
"interval"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L1589-L1600 | train | Returns the parameter that is bound to the peer | [
30522,
3853,
1006,
1007,
1063,
13075,
11867,
11510,
28689,
8737,
18981,
18442,
1027,
19701,
1025,
2065,
1006,
2023,
1012,
1035,
19330,
25114,
18447,
2121,
10175,
15494,
5649,
28689,
22828,
21572,
4842,
3723,
1007,
1063,
11867,
11510,
28689,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/project/ProjectManager.js | getAllFiles | function getAllFiles(filter, includeWorkingSet, sort) {
var viewFiles, deferred;
// The filter and includeWorkingSet params are both optional.
// Handle the case where filter is omitted but includeWorkingSet is
// specified.
if (includeWorkingSet === undefined && typeof (filter) !== "function") {
includeWorkingSet = filter;
filter = null;
}
if (includeWorkingSet) {
viewFiles = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES);
}
deferred = new $.Deferred();
model.getAllFiles(filter, viewFiles, sort)
.done(function (fileList) {
deferred.resolve(fileList);
})
.fail(function (err) {
if (err === FileSystemError.TOO_MANY_ENTRIES && !_projectWarnedForTooManyFiles) {
_showErrorDialog(ERR_TYPE_MAX_FILES);
_projectWarnedForTooManyFiles = true;
}
// resolve with empty list
deferred.resolve([]);
});
return deferred.promise();
} | javascript | function getAllFiles(filter, includeWorkingSet, sort) {
var viewFiles, deferred;
// The filter and includeWorkingSet params are both optional.
// Handle the case where filter is omitted but includeWorkingSet is
// specified.
if (includeWorkingSet === undefined && typeof (filter) !== "function") {
includeWorkingSet = filter;
filter = null;
}
if (includeWorkingSet) {
viewFiles = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES);
}
deferred = new $.Deferred();
model.getAllFiles(filter, viewFiles, sort)
.done(function (fileList) {
deferred.resolve(fileList);
})
.fail(function (err) {
if (err === FileSystemError.TOO_MANY_ENTRIES && !_projectWarnedForTooManyFiles) {
_showErrorDialog(ERR_TYPE_MAX_FILES);
_projectWarnedForTooManyFiles = true;
}
// resolve with empty list
deferred.resolve([]);
});
return deferred.promise();
} | [
"function",
"getAllFiles",
"(",
"filter",
",",
"includeWorkingSet",
",",
"sort",
")",
"{",
"var",
"viewFiles",
",",
"deferred",
";",
"// The filter and includeWorkingSet params are both optional.",
"// Handle the case where filter is omitted but includeWorkingSet is",
"// specified... | Returns an Array of all files for this project, optionally including
files in the working set that are *not* under the project root. Files are
filtered first by ProjectModel.shouldShow(), then by the custom filter
argument (if one was provided).
@param {function (File, number):boolean=} filter Optional function to filter
the file list (does not filter directory traversal). API matches Array.filter().
@param {boolean=} includeWorkingSet If true, include files in the working set
that are not under the project root (*except* for untitled documents).
@param {boolean=} sort If true, The files will be sorted by their paths
@return {$.Promise} Promise that is resolved with an Array of File objects. | [
"Returns",
"an",
"Array",
"of",
"all",
"files",
"for",
"this",
"project",
"optionally",
"including",
"files",
"in",
"the",
"working",
"set",
"that",
"are",
"*",
"not",
"*",
"under",
"the",
"project",
"root",
".",
"Files",
"are",
"filtered",
"first",
"by",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L1394-L1423 | train | Get all files in the project | [
30522,
3853,
2131,
8095,
8873,
4244,
1006,
11307,
1010,
2421,
21398,
13462,
1010,
4066,
1007,
1063,
13075,
3193,
8873,
4244,
1010,
13366,
28849,
2094,
1025,
1013,
1013,
1996,
11307,
1998,
2421,
21398,
13462,
11498,
5244,
2024,
2119,
11887,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function( startMenu ) {
if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
.find( ".ui-menu" )
.hide()
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
.removeClass( "ui-state-active" );
} | javascript | function( startMenu ) {
if ( !startMenu ) {
startMenu = this.active ? this.active.parent() : this.element;
}
startMenu
.find( ".ui-menu" )
.hide()
.attr( "aria-hidden", "true" )
.attr( "aria-expanded", "false" )
.end()
.find( "a.ui-state-active" )
.removeClass( "ui-state-active" );
} | [
"function",
"(",
"startMenu",
")",
"{",
"if",
"(",
"!",
"startMenu",
")",
"{",
"startMenu",
"=",
"this",
".",
"active",
"?",
"this",
".",
"active",
".",
"parent",
"(",
")",
":",
"this",
".",
"element",
";",
"}",
"startMenu",
".",
"find",
"(",
"\".u... | With no arguments, closes the currently active menu - if nothing is active it closes all menus. If passed an argument, it will search for menus BELOW | [
"With",
"no",
"arguments",
"closes",
"the",
"currently",
"active",
"menu",
"-",
"if",
"nothing",
"is",
"active",
"it",
"closes",
"all",
"menus",
".",
"If",
"passed",
"an",
"argument",
"it",
"will",
"search",
"for",
"menus",
"BELOW"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L11899-L11912 | train | Hide the menu | [
30522,
3853,
30524,
3549,
2226,
1007,
1063,
2707,
3549,
2226,
1027,
2023,
1012,
3161,
1029,
2023,
1012,
3161,
1012,
6687,
1006,
1007,
1024,
2023,
1012,
5783,
1025,
1065,
2707,
3549,
2226,
1012,
2424,
1006,
1000,
1012,
21318,
1011,
12183,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/autocomplete/js/highlightDirective.js | MdHighlight | function MdHighlight ($interpolate, $parse) {
return {
terminal: true,
controller: 'MdHighlightCtrl',
compile: function mdHighlightCompile(tElement, tAttr) {
var termExpr = $parse(tAttr.mdHighlightText);
var unsafeContentExpr = $interpolate(tElement.html());
return function mdHighlightLink(scope, element, attr, ctrl) {
ctrl.init(termExpr, unsafeContentExpr);
};
}
};
} | javascript | function MdHighlight ($interpolate, $parse) {
return {
terminal: true,
controller: 'MdHighlightCtrl',
compile: function mdHighlightCompile(tElement, tAttr) {
var termExpr = $parse(tAttr.mdHighlightText);
var unsafeContentExpr = $interpolate(tElement.html());
return function mdHighlightLink(scope, element, attr, ctrl) {
ctrl.init(termExpr, unsafeContentExpr);
};
}
};
} | [
"function",
"MdHighlight",
"(",
"$interpolate",
",",
"$parse",
")",
"{",
"return",
"{",
"terminal",
":",
"true",
",",
"controller",
":",
"'MdHighlightCtrl'",
",",
"compile",
":",
"function",
"mdHighlightCompile",
"(",
"tElement",
",",
"tAttr",
")",
"{",
"var",... | @ngdoc directive
@name mdHighlightText
@module material.components.autocomplete
@description
The `md-highlight-text` directive allows you to specify text that should be highlighted within
an element. Highlighted text will be wrapped in `<span class="highlight"></span>` which can
be styled through CSS. Please note that child elements may not be used with this directive.
@param {string} md-highlight-text A model to be searched for
@param {string=} md-highlight-flags A list of flags (loosely based on JavaScript RexExp flags).
#### **Supported flags**:
- `g`: Find all matches within the provided text
- `i`: Ignore case when searching for matches
- `$`: Only match if the text ends with the search term
- `^`: Only match if the text begins with the search term
@usage
<hljs lang="html">
<input placeholder="Enter a search term..." ng-model="searchTerm" type="text" />
<ul>
<li ng-repeat="result in results" md-highlight-text="searchTerm" md-highlight-flags="i">
{{result.text}}
</li>
</ul>
</hljs> | [
"@ngdoc",
"directive",
"@name",
"mdHighlightText",
"@module",
"material",
".",
"components",
".",
"autocomplete"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/highlightDirective.js#L34-L47 | train | A link to the md - highlight directive | [
30522,
3853,
9108,
4048,
5603,
7138,
1006,
1002,
6970,
18155,
3686,
1010,
1002,
11968,
3366,
1007,
1063,
2709,
1063,
5536,
1024,
2995,
1010,
11486,
1024,
1005,
9108,
4048,
5603,
7138,
6593,
12190,
1005,
1010,
4012,
22090,
1024,
3853,
9108,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(array, key, defaultValue)
{
var value = (array != null) ? array[key] : null;
if (value == null)
{
value = defaultValue;
}
return value;
} | javascript | function(array, key, defaultValue)
{
var value = (array != null) ? array[key] : null;
if (value == null)
{
value = defaultValue;
}
return value;
} | [
"function",
"(",
"array",
",",
"key",
",",
"defaultValue",
")",
"{",
"var",
"value",
"=",
"(",
"array",
"!=",
"null",
")",
"?",
"array",
"[",
"key",
"]",
":",
"null",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"value",
"=",
"defaultValue",
... | Function: getValue
Returns the value for the given key in the given associative array or
the given default value if the value is null.
Parameters:
array - Associative array that contains the value for the key.
key - Key whose value should be returned.
defaultValue - Value to be returned if the value for the given
key is null. | [
"Function",
":",
"getValue"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L3774-L3784 | train | Get the value of a key in an array | [
30522,
3853,
1006,
9140,
1010,
3145,
1010,
12398,
10175,
5657,
1007,
1063,
13075,
3643,
1027,
1006,
9140,
999,
1027,
19701,
1007,
1029,
9140,
1031,
3145,
1033,
1024,
19701,
1025,
2065,
1006,
3643,
1027,
1027,
19701,
1007,
1063,
3643,
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... | |
websockets/ws | lib/websocket.js | tlsConnect | function tlsConnect(options) {
options.path = undefined;
options.servername = options.servername || options.host;
return tls.connect(options);
} | javascript | function tlsConnect(options) {
options.path = undefined;
options.servername = options.servername || options.host;
return tls.connect(options);
} | [
"function",
"tlsConnect",
"(",
"options",
")",
"{",
"options",
".",
"path",
"=",
"undefined",
";",
"options",
".",
"servername",
"=",
"options",
".",
"servername",
"||",
"options",
".",
"host",
";",
"return",
"tls",
".",
"connect",
"(",
"options",
")",
"... | Create a `tls.TLSSocket` and initiate a connection.
@param {Object} options Connection options
@return {tls.TLSSocket} The newly created socket used to start the connection
@private | [
"Create",
"a",
"tls",
".",
"TLSSocket",
"and",
"initiate",
"a",
"connection",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/websocket.js#L669-L673 | train | Connect to TLS | [
30522,
3853,
1056,
4877,
8663,
2638,
6593,
1006,
7047,
1007,
1063,
7047,
1012,
4130,
1027,
6151,
28344,
1025,
7047,
1012,
8241,
18442,
1027,
7047,
1012,
8241,
18442,
1064,
1064,
7047,
1012,
3677,
1025,
2709,
1056,
4877,
1012,
7532,
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... |
eslint/eslint | lib/rules/no-irregular-whitespace.js | checkForIrregularLineTerminators | function checkForIrregularLineTerminators(node) {
const source = sourceCode.getText(),
sourceLines = sourceCode.lines,
linebreaks = source.match(LINE_BREAK);
let lastLineIndex = -1,
match;
while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
const lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
const location = {
line: lineIndex + 1,
column: sourceLines[lineIndex].length
};
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
lastLineIndex = lineIndex;
}
} | javascript | function checkForIrregularLineTerminators(node) {
const source = sourceCode.getText(),
sourceLines = sourceCode.lines,
linebreaks = source.match(LINE_BREAK);
let lastLineIndex = -1,
match;
while ((match = IRREGULAR_LINE_TERMINATORS.exec(source)) !== null) {
const lineIndex = linebreaks.indexOf(match[0], lastLineIndex + 1) || 0;
const location = {
line: lineIndex + 1,
column: sourceLines[lineIndex].length
};
errors.push({ node, message: "Irregular whitespace not allowed.", loc: location });
lastLineIndex = lineIndex;
}
} | [
"function",
"checkForIrregularLineTerminators",
"(",
"node",
")",
"{",
"const",
"source",
"=",
"sourceCode",
".",
"getText",
"(",
")",
",",
"sourceLines",
"=",
"sourceCode",
".",
"lines",
",",
"linebreaks",
"=",
"source",
".",
"match",
"(",
"LINE_BREAK",
")",
... | Checks the program source for irregular line terminators
@param {ASTNode} node The program node
@returns {void}
@private | [
"Checks",
"the",
"program",
"source",
"for",
"irregular",
"line",
"terminators"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-irregular-whitespace.js#L175-L192 | train | Check if the line terminators are irregular | [
30522,
3853,
4638,
29278,
4313,
2890,
24848,
2906,
4179,
3334,
22311,
6591,
1006,
13045,
1007,
1063,
9530,
3367,
3120,
1027,
3120,
16044,
1012,
2131,
18209,
1006,
1007,
1010,
3120,
12735,
1027,
3120,
16044,
1012,
3210,
1010,
2240,
23890,
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... |
SeleniumHQ/selenium | javascript/node/optparse.js | wrapStr | function wrapStr(text, width, opt_indent) {
var out = [],
indent = opt_indent || '';
if (indent.length >= width) {
throw Error('Wrapped line indentation is longer than permitted width: ' +
indent.length + ' >= ' + width);
}
text.split('\n').forEach(function(line) {
if (/^\s*$/.test(line)) {
out.push(''); // Push a blank line.
return;
}
do {
line = indent + trimStr(line);
out.push(line.substring(0, width));
line = line.substring(width);
} while (line);
});
return out;
} | javascript | function wrapStr(text, width, opt_indent) {
var out = [],
indent = opt_indent || '';
if (indent.length >= width) {
throw Error('Wrapped line indentation is longer than permitted width: ' +
indent.length + ' >= ' + width);
}
text.split('\n').forEach(function(line) {
if (/^\s*$/.test(line)) {
out.push(''); // Push a blank line.
return;
}
do {
line = indent + trimStr(line);
out.push(line.substring(0, width));
line = line.substring(width);
} while (line);
});
return out;
} | [
"function",
"wrapStr",
"(",
"text",
",",
"width",
",",
"opt_indent",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"indent",
"=",
"opt_indent",
"||",
"''",
";",
"if",
"(",
"indent",
".",
"length",
">=",
"width",
")",
"{",
"throw",
"Error",
"(",
"'Wra... | Wraps the provided {@code text} so every line is at most {@code width}
characters long.
@param {string} text The text to wrap.
@param {number} width The maximum line length.
@param {string=} opt_indent String that will be prepended to each line.
Defaults to the empty string.
@return {!Array.<string>} A list of lines, without newline characters. | [
"Wraps",
"the",
"provided",
"{"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/optparse.js#L57-L80 | train | Wrap a string with spaces | [
30522,
3853,
19735,
16344,
1006,
3793,
1010,
9381,
1010,
23569,
1035,
27427,
4765,
1007,
1063,
13075,
2041,
1027,
1031,
1033,
1010,
27427,
4765,
1027,
23569,
1035,
27427,
4765,
30524,
1063,
5466,
7561,
1006,
1005,
5058,
2240,
27427,
19304,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
juliangarnier/anime | src/index.js | normalizeTweenValues | function normalizeTweenValues(tween, animatable) {
const t = {};
for (let p in tween) {
let value = getFunctionValue(tween[p], animatable);
if (is.arr(value)) {
value = value.map(v => getFunctionValue(v, animatable));
if (value.length === 1) value = value[0];
}
t[p] = value;
}
t.duration = parseFloat(t.duration);
t.delay = parseFloat(t.delay);
return t;
} | javascript | function normalizeTweenValues(tween, animatable) {
const t = {};
for (let p in tween) {
let value = getFunctionValue(tween[p], animatable);
if (is.arr(value)) {
value = value.map(v => getFunctionValue(v, animatable));
if (value.length === 1) value = value[0];
}
t[p] = value;
}
t.duration = parseFloat(t.duration);
t.delay = parseFloat(t.delay);
return t;
} | [
"function",
"normalizeTweenValues",
"(",
"tween",
",",
"animatable",
")",
"{",
"const",
"t",
"=",
"{",
"}",
";",
"for",
"(",
"let",
"p",
"in",
"tween",
")",
"{",
"let",
"value",
"=",
"getFunctionValue",
"(",
"tween",
"[",
"p",
"]",
",",
"animatable",
... | Tweens | [
"Tweens"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/src/index.js#L718-L731 | train | Normalizes tween values | [
30522,
3853,
3671,
4697,
2102,
28394,
2078,
10175,
15808,
1006,
1056,
28394,
2078,
1010,
2019,
9581,
10880,
1007,
1063,
9530,
3367,
1056,
1027,
1063,
1065,
1025,
2005,
1006,
2292,
1052,
1999,
1056,
28394,
2078,
1007,
1063,
2292,
3643,
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... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(context) {
var element = context.createElement("div"),
html5 = "<article>foo</article>";
element.innerHTML = html5;
return element.innerHTML.toLowerCase() === html5;
} | javascript | function(context) {
var element = context.createElement("div"),
html5 = "<article>foo</article>";
element.innerHTML = html5;
return element.innerHTML.toLowerCase() === html5;
} | [
"function",
"(",
"context",
")",
"{",
"var",
"element",
"=",
"context",
".",
"createElement",
"(",
"\"div\"",
")",
",",
"html5",
"=",
"\"<article>foo</article>\"",
";",
"element",
".",
"innerHTML",
"=",
"html5",
";",
"return",
"element",
".",
"innerHTML",
".... | Everything below IE9 doesn't know how to treat HTML5 tags
@param {Object} context The document object on which to check HTML5 support
@example
wysihtml5.browser.supportsHTML5Tags(document); | [
"Everything",
"below",
"IE9",
"doesn",
"t",
"know",
"how",
"to",
"treat",
"HTML5",
"tags"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L4345-L4350 | train | returns true if the element is a div | [
30522,
3853,
1006,
6123,
1007,
1063,
13075,
5783,
1027,
6123,
1012,
3443,
12260,
3672,
1006,
1000,
4487,
2615,
1000,
1007,
1010,
16129,
2629,
1027,
1000,
1026,
3720,
1028,
29379,
1026,
1013,
3720,
1028,
1000,
1025,
5783,
1012,
5110,
11039,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/errors.js | createInvalidExceptionError | function createInvalidExceptionError(message, value) {
var err = new Error(message);
err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
err.valueType = typeof value;
err.value = value;
return err;
} | javascript | function createInvalidExceptionError(message, value) {
var err = new Error(message);
err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
err.valueType = typeof value;
err.value = value;
return err;
} | [
"function",
"createInvalidExceptionError",
"(",
"message",
",",
"value",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"message",
")",
";",
"err",
".",
"code",
"=",
"'ERR_MOCHA_INVALID_EXCEPTION'",
";",
"err",
".",
"valueType",
"=",
"typeof",
"value",
";... | Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
@public
@param {string} message - Error message to be displayed.
@returns {Error} instance detailing the error condition | [
"Creates",
"an",
"error",
"object",
"to",
"be",
"thrown",
"when",
"an",
"exception",
"was",
"caught",
"but",
"the",
"Error",
"is",
"falsy",
"or",
"undefined",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/errors.js#L124-L130 | train | Creates an error object that can be thrown when the value is not a valid type | [
30522,
3853,
3443,
2378,
10175,
5178,
2595,
24422,
2121,
29165,
1006,
4471,
1010,
3643,
1007,
1063,
13075,
9413,
2099,
1027,
2047,
7561,
1006,
4471,
1007,
1025,
9413,
2099,
1012,
3642,
1027,
1005,
9413,
2099,
1035,
9587,
7507,
1035,
19528,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/one-var.js | startBlock | function startBlock() {
blockStack.push({
let: { initialized: false, uninitialized: false },
const: { initialized: false, uninitialized: false }
});
} | javascript | function startBlock() {
blockStack.push({
let: { initialized: false, uninitialized: false },
const: { initialized: false, uninitialized: false }
});
} | [
"function",
"startBlock",
"(",
")",
"{",
"blockStack",
".",
"push",
"(",
"{",
"let",
":",
"{",
"initialized",
":",
"false",
",",
"uninitialized",
":",
"false",
"}",
",",
"const",
":",
"{",
"initialized",
":",
"false",
",",
"uninitialized",
":",
"false",
... | Increments the blockStack counter.
@returns {void}
@private | [
"Increments",
"the",
"blockStack",
"counter",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L109-L114 | train | Start the block | [
30522,
3853,
2707,
23467,
1006,
1007,
1063,
5991,
2696,
3600,
1012,
5245,
1006,
1063,
2292,
1024,
1063,
3988,
3550,
1024,
6270,
1010,
4895,
5498,
20925,
3550,
1024,
6270,
1065,
1010,
9530,
3367,
1024,
1063,
3988,
3550,
1024,
6270,
1010,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jiahaog/nativefier | app/src/static/preload.js | setNotificationCallback | function setNotificationCallback(createCallback, clickCallback) {
const OldNotify = window.Notification;
const newNotify = (title, opt) => {
createCallback(title, opt);
const instance = new OldNotify(title, opt);
instance.addEventListener('click', clickCallback);
return instance;
};
newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
Object.defineProperty(newNotify, 'permission', {
get: () => OldNotify.permission,
});
window.Notification = newNotify;
} | javascript | function setNotificationCallback(createCallback, clickCallback) {
const OldNotify = window.Notification;
const newNotify = (title, opt) => {
createCallback(title, opt);
const instance = new OldNotify(title, opt);
instance.addEventListener('click', clickCallback);
return instance;
};
newNotify.requestPermission = OldNotify.requestPermission.bind(OldNotify);
Object.defineProperty(newNotify, 'permission', {
get: () => OldNotify.permission,
});
window.Notification = newNotify;
} | [
"function",
"setNotificationCallback",
"(",
"createCallback",
",",
"clickCallback",
")",
"{",
"const",
"OldNotify",
"=",
"window",
".",
"Notification",
";",
"const",
"newNotify",
"=",
"(",
"title",
",",
"opt",
")",
"=>",
"{",
"createCallback",
"(",
"title",
",... | Patches window.Notification to:
- set a callback on a new Notification
- set a callback for clicks on notifications
@param createCallback
@param clickCallback | [
"Patches",
"window",
".",
"Notification",
"to",
":",
"-",
"set",
"a",
"callback",
"on",
"a",
"new",
"Notification",
"-",
"set",
"a",
"callback",
"for",
"clicks",
"on",
"notifications"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/app/src/static/preload.js#L30-L44 | train | Sets a callback function to be called when the user clicks on a notification. | [
30522,
3853,
2275,
17048,
9031,
9289,
20850,
8684,
1006,
3443,
9289,
20850,
8684,
1010,
11562,
9289,
20850,
8684,
1007,
1063,
9530,
3367,
2214,
17048,
8757,
1027,
3332,
1012,
26828,
1025,
9530,
3367,
2047,
17048,
8757,
1027,
1006,
2516,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/sidenav/sidenav.js | SidenavService | function SidenavService($mdComponentRegistry, $mdUtil, $q, $log) {
var errorMsg = "SideNav '{0}' is not available! Did you use md-component-id='{0}'?";
var service = {
find: findInstance, // sync - returns proxy API
waitFor: waitForInstance // async - returns promise
};
/**
* Service API that supports three (3) usages:
* $mdSidenav().find("left") // sync (must already exist) or returns undefined
* $mdSidenav("left").toggle(); // sync (must already exist) or returns reject promise;
* $mdSidenav("left",true).then(function(left) { // async returns instance when available
* left.toggle();
* });
*/
return function(handle, enableWait) {
if (angular.isUndefined(handle)) {
return service;
}
var shouldWait = enableWait === true;
var instance = service.find(handle, shouldWait);
return !instance && shouldWait ? service.waitFor(handle) :
!instance && angular.isUndefined(enableWait) ? addLegacyAPI(service, handle) : instance;
};
/**
* For failed instance/handle lookups, older-clients expect an response object with noops
* that include `rejected promise APIs`
* @param service
* @param handle
* @returns {Object}
*/
function addLegacyAPI(service, handle) {
var falseFn = function() {
return false;
};
var rejectFn = function() {
return $q.when($mdUtil.supplant(errorMsg, [handle || ""]));
};
return angular.extend({
isLockedOpen: falseFn,
isOpen: falseFn,
toggle: rejectFn,
open: rejectFn,
close: rejectFn,
onClose: angular.noop,
then: function(callback) {
return waitForInstance(handle).then(callback || angular.noop);
}
}, service);
}
/**
* Synchronously lookup the controller instance for the specified sidNav instance which has been
* registered with the markup `md-component-id`
*/
function findInstance(handle, shouldWait) {
var instance = $mdComponentRegistry.get(handle);
if (!instance && !shouldWait) {
// Report missing instance
$log.error($mdUtil.supplant(errorMsg, [handle || ""]));
// The component has not registered itself... most like NOT yet created
// return null to indicate that the Sidenav is not in the DOM
return undefined;
}
return instance;
}
/**
* Asynchronously wait for the component instantiation,
* Deferred lookup of component instance using $component registry
*/
function waitForInstance(handle) {
return $mdComponentRegistry.when(handle).catch($log.error);
}
} | javascript | function SidenavService($mdComponentRegistry, $mdUtil, $q, $log) {
var errorMsg = "SideNav '{0}' is not available! Did you use md-component-id='{0}'?";
var service = {
find: findInstance, // sync - returns proxy API
waitFor: waitForInstance // async - returns promise
};
/**
* Service API that supports three (3) usages:
* $mdSidenav().find("left") // sync (must already exist) or returns undefined
* $mdSidenav("left").toggle(); // sync (must already exist) or returns reject promise;
* $mdSidenav("left",true).then(function(left) { // async returns instance when available
* left.toggle();
* });
*/
return function(handle, enableWait) {
if (angular.isUndefined(handle)) {
return service;
}
var shouldWait = enableWait === true;
var instance = service.find(handle, shouldWait);
return !instance && shouldWait ? service.waitFor(handle) :
!instance && angular.isUndefined(enableWait) ? addLegacyAPI(service, handle) : instance;
};
/**
* For failed instance/handle lookups, older-clients expect an response object with noops
* that include `rejected promise APIs`
* @param service
* @param handle
* @returns {Object}
*/
function addLegacyAPI(service, handle) {
var falseFn = function() {
return false;
};
var rejectFn = function() {
return $q.when($mdUtil.supplant(errorMsg, [handle || ""]));
};
return angular.extend({
isLockedOpen: falseFn,
isOpen: falseFn,
toggle: rejectFn,
open: rejectFn,
close: rejectFn,
onClose: angular.noop,
then: function(callback) {
return waitForInstance(handle).then(callback || angular.noop);
}
}, service);
}
/**
* Synchronously lookup the controller instance for the specified sidNav instance which has been
* registered with the markup `md-component-id`
*/
function findInstance(handle, shouldWait) {
var instance = $mdComponentRegistry.get(handle);
if (!instance && !shouldWait) {
// Report missing instance
$log.error($mdUtil.supplant(errorMsg, [handle || ""]));
// The component has not registered itself... most like NOT yet created
// return null to indicate that the Sidenav is not in the DOM
return undefined;
}
return instance;
}
/**
* Asynchronously wait for the component instantiation,
* Deferred lookup of component instance using $component registry
*/
function waitForInstance(handle) {
return $mdComponentRegistry.when(handle).catch($log.error);
}
} | [
"function",
"SidenavService",
"(",
"$mdComponentRegistry",
",",
"$mdUtil",
",",
"$q",
",",
"$log",
")",
"{",
"var",
"errorMsg",
"=",
"\"SideNav '{0}' is not available! Did you use md-component-id='{0}'?\"",
";",
"var",
"service",
"=",
"{",
"find",
":",
"findInstance",
... | @ngdoc service
@name $mdSidenav
@module material.components.sidenav
@description
`$mdSidenav` makes it easy to interact with multiple sidenavs in an app. When looking up a
sidenav instance, you can either look it up synchronously or wait for it to be initialized
asynchronously. This is done by passing the second argument to `$mdSidenav`.
@usage
<hljs lang="js">
// Async lookup for sidenav instance; will resolve when the instance is available
$mdSidenav(componentId, true).then(function(instance) {
$log.debug( componentId + "is now ready" );
});
// Sync lookup for sidenav instance; this will resolve immediately.
$mdSidenav(componentId).then(function(instance) {
$log.debug( componentId + "is now ready" );
});
// Async toggle the given sidenav;
// when instance is known ready and lazy lookup is not needed.
$mdSidenav(componentId)
.toggle()
.then(function(){
$log.debug('toggled');
});
// Async open the given sidenav
$mdSidenav(componentId)
.open()
.then(function(){
$log.debug('opened');
});
// Async close the given sidenav
$mdSidenav(componentId)
.close()
.then(function(){
$log.debug('closed');
});
// Async lookup for sidenav instance
$mdSidenav(componentId, true).then(function(instance) {
// On close callback to handle close, backdrop click, or escape key pressed.
// Callback happens BEFORE the close action occurs.
instance.onClose(function() {
$log.debug('closing');
});
});
// Sync check to see if the specified sidenav is set to be open
$mdSidenav(componentId).isOpen();
// Sync check to whether given sidenav is locked open
// If this is true, the sidenav will be open regardless of close()
$mdSidenav(componentId).isLockedOpen();
</hljs> | [
"@ngdoc",
"service",
"@name",
"$mdSidenav",
"@module",
"material",
".",
"components",
".",
"sidenav"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sidenav/sidenav.js#L73-L152 | train | The SidenavService constructor. | [
30522,
3853,
2217,
2532,
15088,
2121,
7903,
2063,
1006,
1002,
9108,
9006,
29513,
3372,
2890,
24063,
2854,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
1053,
1010,
1002,
8833,
1007,
1063,
13075,
7561,
5244,
2290,
1027,
1000,
2217,
2532,
2615,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/descriptorRelated/api/DescriptorChangeFactory.js | function(mChangeFile,oInlineChange,oSettings) { //so far, parameter correspond to inline change format
this._mChangeFile = mChangeFile;
this._mChangeFile.packageName = '$TMP';
this._oInlineChange = oInlineChange;
this._sTransportRequest = null;
this._oSettings = oSettings;
} | javascript | function(mChangeFile,oInlineChange,oSettings) { //so far, parameter correspond to inline change format
this._mChangeFile = mChangeFile;
this._mChangeFile.packageName = '$TMP';
this._oInlineChange = oInlineChange;
this._sTransportRequest = null;
this._oSettings = oSettings;
} | [
"function",
"(",
"mChangeFile",
",",
"oInlineChange",
",",
"oSettings",
")",
"{",
"//so far, parameter correspond to inline change format",
"this",
".",
"_mChangeFile",
"=",
"mChangeFile",
";",
"this",
".",
"_mChangeFile",
".",
"packageName",
"=",
"'$TMP'",
";",
"this... | Descriptor Related Apis
@namespace
@name sap.ui.fl.descriptorRelated.api
@author SAP SE
@version ${version}
@private
@sap-restricted
Descriptor Change
@param {object} mChangeFile change file
@param {sap.ui.fl.descriptorRelated.api.DescriptorInlineChange} oInlineChange inline change object
@param {sap.ui.fl.registry.Settings} oSettings settings
@constructor
@alias sap.ui.fl.descriptorRelated.api.DescriptorChange
@author SAP SE
@version ${version}
@private
@sap-restricted | [
"Descriptor",
"Related",
"Apis",
"@namespace",
"@name",
"sap",
".",
"ui",
".",
"fl",
".",
"descriptorRelated",
".",
"api",
"@author",
"SAP",
"SE",
"@version",
"$",
"{",
"version",
"}",
"@private",
"@sap",
"-",
"restricted",
"Descriptor",
"Change"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/descriptorRelated/api/DescriptorChangeFactory.js#L59-L65 | train | This function is called by the change processor to create a new change file | [
30522,
3853,
1006,
11338,
18003,
12879,
9463,
1010,
1051,
2378,
4179,
22305,
2063,
1010,
9808,
18319,
3070,
2015,
1007,
1063,
1013,
1013,
2061,
2521,
1010,
16381,
17254,
2000,
23881,
2689,
4289,
2023,
1012,
1035,
11338,
18003,
12879,
9463,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Freeboard/freeboard | js/freeboard.thirdparty.js | function( event, eventData ) {
var that = this,
toShow = eventData.newPanel,
toHide = eventData.oldPanel;
this.running = true;
function complete() {
that.running = false;
that._trigger( "activate", event, eventData );
}
function show() {
eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
if ( toShow.length && that.options.show ) {
that._show( toShow, that.options.show, complete );
} else {
toShow.show();
complete();
}
}
// start out by hiding, then showing, then completing
if ( toHide.length && this.options.hide ) {
this._hide( toHide, this.options.hide, function() {
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
show();
});
} else {
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
toHide.hide();
show();
}
toHide.attr({
"aria-expanded": "false",
"aria-hidden": "true"
});
eventData.oldTab.attr( "aria-selected", "false" );
// If we're switching tabs, remove the old tab from the tab order.
// If we're opening from collapsed state, remove the previous tab from the tab order.
// If we're collapsing, then keep the collapsing tab in the tab order.
if ( toShow.length && toHide.length ) {
eventData.oldTab.attr( "tabIndex", -1 );
} else if ( toShow.length ) {
this.tabs.filter(function() {
return $( this ).attr( "tabIndex" ) === 0;
})
.attr( "tabIndex", -1 );
}
toShow.attr({
"aria-expanded": "true",
"aria-hidden": "false"
});
eventData.newTab.attr({
"aria-selected": "true",
tabIndex: 0
});
} | javascript | function( event, eventData ) {
var that = this,
toShow = eventData.newPanel,
toHide = eventData.oldPanel;
this.running = true;
function complete() {
that.running = false;
that._trigger( "activate", event, eventData );
}
function show() {
eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
if ( toShow.length && that.options.show ) {
that._show( toShow, that.options.show, complete );
} else {
toShow.show();
complete();
}
}
// start out by hiding, then showing, then completing
if ( toHide.length && this.options.hide ) {
this._hide( toHide, this.options.hide, function() {
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
show();
});
} else {
eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
toHide.hide();
show();
}
toHide.attr({
"aria-expanded": "false",
"aria-hidden": "true"
});
eventData.oldTab.attr( "aria-selected", "false" );
// If we're switching tabs, remove the old tab from the tab order.
// If we're opening from collapsed state, remove the previous tab from the tab order.
// If we're collapsing, then keep the collapsing tab in the tab order.
if ( toShow.length && toHide.length ) {
eventData.oldTab.attr( "tabIndex", -1 );
} else if ( toShow.length ) {
this.tabs.filter(function() {
return $( this ).attr( "tabIndex" ) === 0;
})
.attr( "tabIndex", -1 );
}
toShow.attr({
"aria-expanded": "true",
"aria-hidden": "false"
});
eventData.newTab.attr({
"aria-selected": "true",
tabIndex: 0
});
} | [
"function",
"(",
"event",
",",
"eventData",
")",
"{",
"var",
"that",
"=",
"this",
",",
"toShow",
"=",
"eventData",
".",
"newPanel",
",",
"toHide",
"=",
"eventData",
".",
"oldPanel",
";",
"this",
".",
"running",
"=",
"true",
";",
"function",
"complete",
... | handles show/hide for selecting tabs | [
"handles",
"show",
"/",
"hide",
"for",
"selecting",
"tabs"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L14364-L14424 | train | When the user clicks on a tab | [
30522,
3853,
1006,
2724,
1010,
2724,
2850,
2696,
1007,
1063,
13075,
2008,
1027,
2023,
1010,
2000,
22231,
2860,
1027,
2724,
2850,
2696,
1012,
2047,
9739,
2884,
1010,
2000,
26100,
1027,
2724,
2850,
2696,
1012,
2214,
9739,
2884,
1025,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/NotificationBar.js | function(oThis, oMN) {
if (oMN && oMN.hasItems()) {
var $messageCount = oMN.$("counter");
// remove all possible classes
$messageCount.removeClass("sapUiMessageInformation");
$messageCount.removeClass("sapUiMessageSuccess");
$messageCount.removeClass("sapUiMessageWarning");
$messageCount.removeClass("sapUiMessageError");
// re-sort the messages and re-calc the severity level because they could have been changed
// if the NotiBar was invisible
fnSortMessages(oThis, oMN);
// add new corresponding class
var sLvl = oThis._sSeverestMessageLevel;
$messageCount.addClass("sapUiMessage" + sLvl);
// create key for description text
var iCount = oMN.getMessages().length;
var sKey = "NOTIBAR_MESSAGE_NOTIFIER_DESC_LEVEL_" + sLvl.toUpperCase() + (iCount === 1 ? "_SING" : "_PL");
// set description (i.e. "3 messages available: Highest severity
// "Error")
fnSetNotifierDescription(oThis, oMN, sKey, iCount);
}
} | javascript | function(oThis, oMN) {
if (oMN && oMN.hasItems()) {
var $messageCount = oMN.$("counter");
// remove all possible classes
$messageCount.removeClass("sapUiMessageInformation");
$messageCount.removeClass("sapUiMessageSuccess");
$messageCount.removeClass("sapUiMessageWarning");
$messageCount.removeClass("sapUiMessageError");
// re-sort the messages and re-calc the severity level because they could have been changed
// if the NotiBar was invisible
fnSortMessages(oThis, oMN);
// add new corresponding class
var sLvl = oThis._sSeverestMessageLevel;
$messageCount.addClass("sapUiMessage" + sLvl);
// create key for description text
var iCount = oMN.getMessages().length;
var sKey = "NOTIBAR_MESSAGE_NOTIFIER_DESC_LEVEL_" + sLvl.toUpperCase() + (iCount === 1 ? "_SING" : "_PL");
// set description (i.e. "3 messages available: Highest severity
// "Error")
fnSetNotifierDescription(oThis, oMN, sKey, iCount);
}
} | [
"function",
"(",
"oThis",
",",
"oMN",
")",
"{",
"if",
"(",
"oMN",
"&&",
"oMN",
".",
"hasItems",
"(",
")",
")",
"{",
"var",
"$messageCount",
"=",
"oMN",
".",
"$",
"(",
"\"counter\"",
")",
";",
"// remove all possible classes",
"$messageCount",
".",
"remov... | This method sets the corresponding CSS class to the message notifier's
counter to set its corresponding color and sets the corresponding ARIA
information to the notifier's description element
@private | [
"This",
"method",
"sets",
"the",
"corresponding",
"CSS",
"class",
"to",
"the",
"message",
"notifier",
"s",
"counter",
"to",
"set",
"its",
"corresponding",
"color",
"and",
"sets",
"the",
"corresponding",
"ARIA",
"information",
"to",
"the",
"notifier",
"s",
"des... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/NotificationBar.js#L986-L1011 | train | Updates the notifier description | [
30522,
3853,
1006,
27178,
24158,
1010,
18168,
2078,
1007,
1063,
2065,
1006,
18168,
2078,
1004,
1004,
18168,
2078,
1012,
2038,
4221,
5244,
1006,
1007,
1007,
1063,
13075,
1002,
4471,
3597,
16671,
1027,
18168,
2078,
1012,
1002,
1006,
1000,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Component.js | function(oPromise) {
// In order to make the error handling of the Promise.all() happen after all Promises finish, we catch all rejected Promises and make them resolve with an marked object.
oPromise = oPromise.then(
function(v) {
return {
result: v,
rejected: false
};
},
function(v) {
return {
result: v,
rejected: true
};
}
);
return oPromise;
} | javascript | function(oPromise) {
// In order to make the error handling of the Promise.all() happen after all Promises finish, we catch all rejected Promises and make them resolve with an marked object.
oPromise = oPromise.then(
function(v) {
return {
result: v,
rejected: false
};
},
function(v) {
return {
result: v,
rejected: true
};
}
);
return oPromise;
} | [
"function",
"(",
"oPromise",
")",
"{",
"// In order to make the error handling of the Promise.all() happen after all Promises finish, we catch all rejected Promises and make them resolve with an marked object.",
"oPromise",
"=",
"oPromise",
".",
"then",
"(",
"function",
"(",
"v",
")",
... | trigger loading of libraries and component preloads and collect the given promises | [
"trigger",
"loading",
"of",
"libraries",
"and",
"component",
"preloads",
"and",
"collect",
"the",
"given",
"promises"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L2670-L2687 | train | This function is called by the Promise. all function to resolve the promise | [
30522,
3853,
1006,
6728,
21716,
5562,
1007,
1063,
1013,
1013,
1999,
2344,
2000,
2191,
1996,
7561,
8304,
1997,
1996,
4872,
1012,
2035,
1006,
1007,
4148,
2044,
2035,
10659,
3926,
1010,
2057,
4608,
2035,
5837,
10659,
1998,
2191,
2068,
10663,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function (sVersion) {
// remove all whitespaces
sVersion = sVersion.replace(/\s/g, "");
// get version without snapshot
// we need to run the regex twice to avoid that version 1-2-3-SNAPSHOT will result in version 1.
var oRegexp1 = /\b\d{1,5}(.\d{1,5}){0,2}/g;
var oRegexp2 = /\b\d{1,5}(\.\d{1,5}){0,2}/g;
var nLength = sVersion.match(oRegexp1) ? sVersion.match(oRegexp1)[0].length : 0;
var nLenghtWithDot = sVersion.match(oRegexp2) ? sVersion.match(oRegexp2)[0].length : 0;
if (nLenghtWithDot < 1 || nLenghtWithDot != nLength){
return false;
}
//if the character after the version is also a number or a dot, it should also be a format error
if (nLenghtWithDot && sVersion != sVersion.substr(0,nLenghtWithDot)){
var cNextCharacter = sVersion.substr(nLenghtWithDot, 1);
var oRegexp = /^[0-9.]$/;
if (oRegexp.test(cNextCharacter)){
return false;
}
}
// split into number-parts and check if there are max. three parts
var aVersionParts = sVersion.substr(0,nLenghtWithDot).split(".");
if (aVersionParts.length > 3){
return false;
}
// 5 digits maximum per part
if (!aVersionParts.every(function(sPart){return sPart.length <= 5;})){
return false;
}
return true;
} | javascript | function (sVersion) {
// remove all whitespaces
sVersion = sVersion.replace(/\s/g, "");
// get version without snapshot
// we need to run the regex twice to avoid that version 1-2-3-SNAPSHOT will result in version 1.
var oRegexp1 = /\b\d{1,5}(.\d{1,5}){0,2}/g;
var oRegexp2 = /\b\d{1,5}(\.\d{1,5}){0,2}/g;
var nLength = sVersion.match(oRegexp1) ? sVersion.match(oRegexp1)[0].length : 0;
var nLenghtWithDot = sVersion.match(oRegexp2) ? sVersion.match(oRegexp2)[0].length : 0;
if (nLenghtWithDot < 1 || nLenghtWithDot != nLength){
return false;
}
//if the character after the version is also a number or a dot, it should also be a format error
if (nLenghtWithDot && sVersion != sVersion.substr(0,nLenghtWithDot)){
var cNextCharacter = sVersion.substr(nLenghtWithDot, 1);
var oRegexp = /^[0-9.]$/;
if (oRegexp.test(cNextCharacter)){
return false;
}
}
// split into number-parts and check if there are max. three parts
var aVersionParts = sVersion.substr(0,nLenghtWithDot).split(".");
if (aVersionParts.length > 3){
return false;
}
// 5 digits maximum per part
if (!aVersionParts.every(function(sPart){return sPart.length <= 5;})){
return false;
}
return true;
} | [
"function",
"(",
"sVersion",
")",
"{",
"// remove all whitespaces",
"sVersion",
"=",
"sVersion",
".",
"replace",
"(",
"/",
"\\s",
"/",
"g",
",",
"\"\"",
")",
";",
"// get version without snapshot",
"// we need to run the regex twice to avoid that version 1-2-3-SNAPSHOT will... | Checks if the application version has the correct format: "major.minor.patch".
@param {string} sVersion - Version of application
@returns {boolean} true if the format is correct, otherwise false
@public | [
"Checks",
"if",
"the",
"application",
"version",
"has",
"the",
"correct",
"format",
":",
"major",
".",
"minor",
".",
"patch",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L1192-L1227 | train | returns true if the version is a valid version | [
30522,
3853,
1006,
17917,
2545,
3258,
1007,
1063,
1013,
1013,
6366,
2035,
12461,
15327,
2015,
17917,
2545,
3258,
1027,
17917,
2545,
3258,
1012,
5672,
1006,
1013,
1032,
1055,
1013,
1043,
1010,
1000,
1000,
1007,
1025,
1013,
1013,
2131,
2544,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | build/lib/treeshaking.js | getTokenAtPosition | function getTokenAtPosition(sourceFile, position, allowPositionInLeadingTrivia, includeEndPosition) {
let current = sourceFile;
outer: while (true) {
// find the child that contains 'position'
for (const child of current.getChildren()) {
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true);
if (start > position) {
// If this child begins after position, then all subsequent children will as well.
break;
}
const end = child.getEnd();
if (position < end || (position === end && (child.kind === ts.SyntaxKind.EndOfFileToken || includeEndPosition))) {
current = child;
continue outer;
}
}
return current;
}
} | javascript | function getTokenAtPosition(sourceFile, position, allowPositionInLeadingTrivia, includeEndPosition) {
let current = sourceFile;
outer: while (true) {
// find the child that contains 'position'
for (const child of current.getChildren()) {
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true);
if (start > position) {
// If this child begins after position, then all subsequent children will as well.
break;
}
const end = child.getEnd();
if (position < end || (position === end && (child.kind === ts.SyntaxKind.EndOfFileToken || includeEndPosition))) {
current = child;
continue outer;
}
}
return current;
}
} | [
"function",
"getTokenAtPosition",
"(",
"sourceFile",
",",
"position",
",",
"allowPositionInLeadingTrivia",
",",
"includeEndPosition",
")",
"{",
"let",
"current",
"=",
"sourceFile",
";",
"outer",
":",
"while",
"(",
"true",
")",
"{",
"// find the child that contains 'po... | Get the token whose text contains the position | [
"Get",
"the",
"token",
"whose",
"text",
"contains",
"the",
"position"
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/lib/treeshaking.js#L663-L681 | train | Get the token at the given position | [
30522,
3853,
2131,
18715,
8189,
25856,
19234,
1006,
3120,
8873,
2571,
1010,
2597,
1010,
3499,
26994,
2378,
19738,
4667,
18886,
9035,
1010,
2421,
10497,
26994,
1007,
1063,
2292,
2783,
1027,
3120,
8873,
2571,
1025,
6058,
1024,
2096,
1006,
299... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/zyngascroll.js | function(id) {
var cleared = running[id] != null;
if (cleared) {
running[id] = null;
}
return cleared;
} | javascript | function(id) {
var cleared = running[id] != null;
if (cleared) {
running[id] = null;
}
return cleared;
} | [
"function",
"(",
"id",
")",
"{",
"var",
"cleared",
"=",
"running",
"[",
"id",
"]",
"!=",
"null",
";",
"if",
"(",
"cleared",
")",
"{",
"running",
"[",
"id",
"]",
"=",
"null",
";",
"}",
"return",
"cleared",
";",
"}"
] | Stops the given animation.
@param {Integer} id Unique animation ID
@return {Boolean} Whether the animation was stopped (aka, was running before) | [
"Stops",
"the",
"given",
"animation",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/zyngascroll.js#L182-L189 | train | Clears the context associated with the specified context id. | [
30522,
3853,
1006,
8909,
1007,
1063,
13075,
5985,
1027,
2770,
1031,
8909,
1033,
999,
1027,
19701,
1025,
2065,
1006,
5985,
1007,
1063,
2770,
1031,
8909,
1033,
1027,
19701,
1025,
1065,
2709,
5985,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function(node, ignoreSelfAndKids) {
function nextSiblingEl(n) {
do {
n = n.nextSibling;
} while (n && n.nodeType !== n.ELEMENT_NODE);
return n;
}
// First check for kids if those aren't being ignored
if (!ignoreSelfAndKids && node.children[0]) {
return node.children[0];
}
// Then for siblings...
var next = nextSiblingEl(node);
if (next) {
return next;
}
// And finally, move up the parent chain *and* find a sibling
// (because this is depth-first traversal, we will have already
// seen the parent nodes themselves).
do {
node = node.parentNode;
if (node)
next = nextSiblingEl(node);
} while (node && !next);
return node && next;
} | javascript | function(node, ignoreSelfAndKids) {
function nextSiblingEl(n) {
do {
n = n.nextSibling;
} while (n && n.nodeType !== n.ELEMENT_NODE);
return n;
}
// First check for kids if those aren't being ignored
if (!ignoreSelfAndKids && node.children[0]) {
return node.children[0];
}
// Then for siblings...
var next = nextSiblingEl(node);
if (next) {
return next;
}
// And finally, move up the parent chain *and* find a sibling
// (because this is depth-first traversal, we will have already
// seen the parent nodes themselves).
do {
node = node.parentNode;
if (node)
next = nextSiblingEl(node);
} while (node && !next);
return node && next;
} | [
"function",
"(",
"node",
",",
"ignoreSelfAndKids",
")",
"{",
"function",
"nextSiblingEl",
"(",
"n",
")",
"{",
"do",
"{",
"n",
"=",
"n",
".",
"nextSibling",
";",
"}",
"while",
"(",
"n",
"&&",
"n",
".",
"nodeType",
"!==",
"n",
".",
"ELEMENT_NODE",
")",... | Like _getNextNode, but for DOM implementations with no
firstElementChild/nextElementSibling functionality... | [
"Like",
"_getNextNode",
"but",
"for",
"DOM",
"implementations",
"with",
"no",
"firstElementChild",
"/",
"nextElementSibling",
"functionality",
"..."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L698-L723 | train | Returns the next sibling of node | [
30522,
3853,
1006,
13045,
1010,
26663,
2884,
15143,
2094,
3211,
5104,
1007,
1063,
3853,
2279,
5332,
9709,
2884,
1006,
1050,
1007,
1063,
2079,
1063,
1050,
1027,
1050,
1012,
2279,
5332,
9709,
1025,
1065,
2096,
1006,
1050,
1004,
1004,
1050,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
vuejs/vue-devtools | src/backend/index.js | walk | function walk (node, fn) {
if (node.childNodes) {
for (let i = 0, l = node.childNodes.length; i < l; i++) {
const child = node.childNodes[i]
const stop = fn(child)
if (!stop) {
walk(child, fn)
}
}
}
// also walk shadow DOM
if (node.shadowRoot) {
walk(node.shadowRoot, fn)
}
} | javascript | function walk (node, fn) {
if (node.childNodes) {
for (let i = 0, l = node.childNodes.length; i < l; i++) {
const child = node.childNodes[i]
const stop = fn(child)
if (!stop) {
walk(child, fn)
}
}
}
// also walk shadow DOM
if (node.shadowRoot) {
walk(node.shadowRoot, fn)
}
} | [
"function",
"walk",
"(",
"node",
",",
"fn",
")",
"{",
"if",
"(",
"node",
".",
"childNodes",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"node",
".",
"childNodes",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"... | DOM walk helper
@param {NodeList} nodes
@param {Function} fn | [
"DOM",
"walk",
"helper"
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/backend/index.js#L251-L266 | train | walks the node recursively | [
30522,
3853,
3328,
1006,
13045,
1010,
1042,
2078,
1007,
1063,
2065,
1006,
13045,
1012,
2775,
3630,
6155,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1010,
1048,
1027,
13045,
1012,
2775,
3630,
6155,
1012,
3091,
1025,
1045,
1026,
1048,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/ui-element.js | CommandMatcher | function CommandMatcher(commandMatcherShorthand)
{
/**
* Ensure the shorthand notation used to initialize the CommandMatcher has
* all required values.
*
* @param commandMatcherShorthand an object containing information about
* the CommandMatcher
*/
this.validate = function(commandMatcherShorthand) {
var msg = "CommandMatcher validation error:\n"
+ print_r(commandMatcherShorthand);
if (!commandMatcherShorthand.command) {
throw new CommandMatcherException(msg + 'no command specified!');
}
if (!commandMatcherShorthand.target) {
throw new CommandMatcherException(msg + 'no target specified!');
}
if (commandMatcherShorthand.minMatches &&
commandMatcherShorthand.maxMatches &&
commandMatcherShorthand.minMatches >
commandMatcherShorthand.maxMatches) {
throw new CommandMatcherException(msg + 'minMatches > maxMatches!');
}
};
/**
* Initialize this object.
*
* @param commandMatcherShorthand an object containing information used to
* initialize the CommandMatcher
*/
this.init = function(commandMatcherShorthand) {
this.validate(commandMatcherShorthand);
this.command = commandMatcherShorthand.command;
this.target = commandMatcherShorthand.target;
this.value = commandMatcherShorthand.value || null;
this.minMatches = commandMatcherShorthand.minMatches || 1;
this.maxMatches = commandMatcherShorthand.maxMatches || 1;
this.updateArgs = commandMatcherShorthand.updateArgs ||
function(command, args) { return args; };
};
/**
* Determines whether a given command matches. Updates args by "reference"
* and returns true if it does; return false otherwise.
*
* @param command the command to attempt to match
*/
this.isMatch = function(command) {
var re = new RegExp('^' + this.command + '$');
if (! re.test(command.command)) {
return false;
}
re = new RegExp('^' + this.target + '$');
if (! re.test(command.target)) {
return false;
}
if (this.value != null) {
re = new RegExp('^' + this.value + '$');
if (! re.test(command.value)) {
return false;
}
}
// okay, the command matches
return true;
};
// initialization
this.init(commandMatcherShorthand);
} | javascript | function CommandMatcher(commandMatcherShorthand)
{
/**
* Ensure the shorthand notation used to initialize the CommandMatcher has
* all required values.
*
* @param commandMatcherShorthand an object containing information about
* the CommandMatcher
*/
this.validate = function(commandMatcherShorthand) {
var msg = "CommandMatcher validation error:\n"
+ print_r(commandMatcherShorthand);
if (!commandMatcherShorthand.command) {
throw new CommandMatcherException(msg + 'no command specified!');
}
if (!commandMatcherShorthand.target) {
throw new CommandMatcherException(msg + 'no target specified!');
}
if (commandMatcherShorthand.minMatches &&
commandMatcherShorthand.maxMatches &&
commandMatcherShorthand.minMatches >
commandMatcherShorthand.maxMatches) {
throw new CommandMatcherException(msg + 'minMatches > maxMatches!');
}
};
/**
* Initialize this object.
*
* @param commandMatcherShorthand an object containing information used to
* initialize the CommandMatcher
*/
this.init = function(commandMatcherShorthand) {
this.validate(commandMatcherShorthand);
this.command = commandMatcherShorthand.command;
this.target = commandMatcherShorthand.target;
this.value = commandMatcherShorthand.value || null;
this.minMatches = commandMatcherShorthand.minMatches || 1;
this.maxMatches = commandMatcherShorthand.maxMatches || 1;
this.updateArgs = commandMatcherShorthand.updateArgs ||
function(command, args) { return args; };
};
/**
* Determines whether a given command matches. Updates args by "reference"
* and returns true if it does; return false otherwise.
*
* @param command the command to attempt to match
*/
this.isMatch = function(command) {
var re = new RegExp('^' + this.command + '$');
if (! re.test(command.command)) {
return false;
}
re = new RegExp('^' + this.target + '$');
if (! re.test(command.target)) {
return false;
}
if (this.value != null) {
re = new RegExp('^' + this.value + '$');
if (! re.test(command.value)) {
return false;
}
}
// okay, the command matches
return true;
};
// initialization
this.init(commandMatcherShorthand);
} | [
"function",
"CommandMatcher",
"(",
"commandMatcherShorthand",
")",
"{",
"/**\n * Ensure the shorthand notation used to initialize the CommandMatcher has\n * all required values.\n *\n * @param commandMatcherShorthand an object containing information about\n * ... | A CommandMatcher object matches commands during the application of a
RollupRule. It's specified with a shorthand format, for example:
new CommandMatcher({
command: 'click'
, target: 'ui=allPages::.+'
})
which is intended to match click commands whose target is an element in the
allPages PageSet. The matching expressions are given as regular expressions;
in the example above, the command must be "click"; "clickAndWait" would be
acceptable if 'click.*' were used. Here's a more complete example:
new CommandMatcher({
command: 'type'
, target: 'ui=loginPages::username()'
, value: '.+_test'
, updateArgs: function(command, args) {
args.username = command.value;
}
})
Here, the command and target are fixed, but there is variability in the
value of the command. When a command matches, the username is saved to the
arguments object. | [
"A",
"CommandMatcher",
"object",
"matches",
"commands",
"during",
"the",
"application",
"of",
"a",
"RollupRule",
".",
"It",
"s",
"specified",
"with",
"a",
"shorthand",
"format",
"for",
"example",
":"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L1218-L1290 | train | The CommandMatcher class | [
30522,
3853,
3094,
18900,
7474,
1006,
3094,
18900,
21844,
27794,
11774,
1007,
1063,
1013,
1008,
1008,
1008,
5676,
1996,
2460,
11774,
14869,
2109,
2000,
3988,
4697,
1996,
3094,
18900,
7474,
2038,
1008,
2035,
3223,
5300,
1012,
1008,
1008,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Inspector/Inspector.js | _verifySignature | function _verifySignature(signature, value) {
if (value === undefined) {
console.assert(signature.optional === true, "Missing argument: " + signature.name);
}
return true;
} | javascript | function _verifySignature(signature, value) {
if (value === undefined) {
console.assert(signature.optional === true, "Missing argument: " + signature.name);
}
return true;
} | [
"function",
"_verifySignature",
"(",
"signature",
",",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"console",
".",
"assert",
"(",
"signature",
".",
"optional",
"===",
"true",
",",
"\"Missing argument: \"",
"+",
"signature",
".",
"nam... | user agent string Check a parameter value against the given signature
This only checks for optional parameters, not types
Type checking is complex because of $ref and done on the remote end anyways
@param {signature}
@param {value} | [
"user",
"agent",
"string",
"Check",
"a",
"parameter",
"value",
"against",
"the",
"given",
"signature",
"This",
"only",
"checks",
"for",
"optional",
"parameters",
"not",
"types",
"Type",
"checking",
"is",
"complex",
"because",
"of",
"$ref",
"and",
"done",
"on",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Inspector/Inspector.js#L104-L109 | train | Verify signature | [
30522,
3853,
1035,
20410,
5332,
16989,
11244,
1006,
8085,
1010,
3643,
1007,
1063,
2065,
1006,
3643,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
10122,
1012,
20865,
1006,
8085,
1012,
11887,
1027,
1027,
1027,
2995,
1010,
1000,
4394,
6685,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | src/ol/resolutionconstraint.js | getSmoothClampedResolution | function getSmoothClampedResolution(resolution, maxResolution, minResolution) {
let result = Math.min(resolution, maxResolution);
const ratio = 50;
result *= Math.log(1 + ratio * Math.max(0, resolution / maxResolution - 1)) / ratio + 1;
if (minResolution) {
result = Math.max(result, minResolution);
result /= Math.log(1 + ratio * Math.max(0, minResolution / resolution - 1)) / ratio + 1;
}
return clamp(result, minResolution / 2, maxResolution * 2);
} | javascript | function getSmoothClampedResolution(resolution, maxResolution, minResolution) {
let result = Math.min(resolution, maxResolution);
const ratio = 50;
result *= Math.log(1 + ratio * Math.max(0, resolution / maxResolution - 1)) / ratio + 1;
if (minResolution) {
result = Math.max(result, minResolution);
result /= Math.log(1 + ratio * Math.max(0, minResolution / resolution - 1)) / ratio + 1;
}
return clamp(result, minResolution / 2, maxResolution * 2);
} | [
"function",
"getSmoothClampedResolution",
"(",
"resolution",
",",
"maxResolution",
",",
"minResolution",
")",
"{",
"let",
"result",
"=",
"Math",
".",
"min",
"(",
"resolution",
",",
"maxResolution",
")",
";",
"const",
"ratio",
"=",
"50",
";",
"result",
"*=",
... | Returns a modified resolution to be between maxResolution and minResolution while
still allowing the value to be slightly out of bounds.
Note: the computation is based on the logarithm function (ln):
- at 1, ln(x) is 0
- above 1, ln(x) keeps increasing but at a much slower pace than x
The final result is clamped to prevent getting too far away from bounds.
@param {number} resolution Resolution.
@param {number} maxResolution Max resolution.
@param {number} minResolution Min resolution.
@return {number} Smoothed resolution. | [
"Returns",
"a",
"modified",
"resolution",
"to",
"be",
"between",
"maxResolution",
"and",
"minResolution",
"while",
"still",
"allowing",
"the",
"value",
"to",
"be",
"slightly",
"out",
"of",
"bounds",
".",
"Note",
":",
"the",
"computation",
"is",
"based",
"on",
... | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/resolutionconstraint.js#L39-L49 | train | Returns the smooth clamped resolution | [
30522,
3853,
4152,
5302,
14573,
20464,
16613,
2098,
6072,
4747,
13700,
1006,
5813,
1010,
4098,
6072,
4747,
13700,
1010,
8117,
6072,
4747,
13700,
1007,
1063,
2292,
2765,
1027,
8785,
1012,
8117,
1006,
5813,
1010,
4098,
6072,
4747,
13700,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.