repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
facebook/relay | packages/relay-compiler/core/GraphQLSchemaUtils.js | mayImplement | function mayImplement(
schema: GraphQLSchema,
type: GraphQLType,
typeName: string,
): boolean {
const unmodifiedType = getRawType(type);
return (
unmodifiedType.toString() === typeName ||
implementsInterface(unmodifiedType, typeName) ||
(isAbstractType(unmodifiedType) &&
hasConcreteTypeThatImplements(schema, unmodifiedType, typeName))
);
} | javascript | function mayImplement(
schema: GraphQLSchema,
type: GraphQLType,
typeName: string,
): boolean {
const unmodifiedType = getRawType(type);
return (
unmodifiedType.toString() === typeName ||
implementsInterface(unmodifiedType, typeName) ||
(isAbstractType(unmodifiedType) &&
hasConcreteTypeThatImplements(schema, unmodifiedType, typeName))
);
} | [
"function",
"mayImplement",
"(",
"schema",
":",
"GraphQLSchema",
",",
"type",
":",
"GraphQLType",
",",
"typeName",
":",
"string",
",",
")",
":",
"boolean",
"{",
"const",
"unmodifiedType",
"=",
"getRawType",
"(",
"type",
")",
";",
"return",
"(",
"unmodifiedTy... | Determine if the given type may implement the named type:
- it is the named type
- it implements the named interface
- it is an abstract type and *some* of its concrete types may
implement the named type | [
"Determine",
"if",
"the",
"given",
"type",
"may",
"implement",
"the",
"named",
"type",
":",
"-",
"it",
"is",
"the",
"named",
"type",
"-",
"it",
"implements",
"the",
"named",
"interface",
"-",
"it",
"is",
"an",
"abstract",
"type",
"and",
"*",
"some",
"*... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/core/GraphQLSchemaUtils.js#L62-L74 | train | Returns true if the given type implements the given type | [
30522,
3853,
2089,
30524,
5403,
2863,
1010,
2828,
1024,
10629,
4160,
24228,
5051,
1010,
2828,
18442,
1024,
5164,
1010,
1007,
1024,
22017,
20898,
1063,
9530,
3367,
4895,
5302,
4305,
10451,
13874,
1027,
2131,
2527,
26677,
18863,
1006,
2828,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_BrtRowHdr | function parse_BrtRowHdr(data, length) {
var z = ({});
var tgt = data.l + length;
z.r = data.read_shift(4);
data.l += 4; // TODO: ixfe
var miyRw = data.read_shift(2);
data.l += 1; // TODO: top/bot padding
var flags = data.read_shift(1);
data.l = tgt;
if(flags & 0x07) z.level = flags & 0x07;
if(flags & 0x10) z.hidden = true;
if(flags & 0x20) z.hpt = miyRw / 20;
return z;
} | javascript | function parse_BrtRowHdr(data, length) {
var z = ({});
var tgt = data.l + length;
z.r = data.read_shift(4);
data.l += 4; // TODO: ixfe
var miyRw = data.read_shift(2);
data.l += 1; // TODO: top/bot padding
var flags = data.read_shift(1);
data.l = tgt;
if(flags & 0x07) z.level = flags & 0x07;
if(flags & 0x10) z.hidden = true;
if(flags & 0x20) z.hpt = miyRw / 20;
return z;
} | [
"function",
"parse_BrtRowHdr",
"(",
"data",
",",
"length",
")",
"{",
"var",
"z",
"=",
"(",
"{",
"}",
")",
";",
"var",
"tgt",
"=",
"data",
".",
"l",
"+",
"length",
";",
"z",
".",
"r",
"=",
"data",
".",
"read_shift",
"(",
"4",
")",
";",
"data",
... | /* [MS-XLSB] 2.4.726 BrtRowHdr | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"726",
"BrtRowHdr"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L13385-L13398 | train | Parse a BrtRow header | [
30522,
3853,
11968,
3366,
1035,
7987,
13181,
2860,
14945,
2099,
1006,
2951,
1010,
3091,
1007,
1063,
13075,
1062,
1027,
1006,
1063,
1065,
1007,
1025,
13075,
1056,
13512,
1027,
2951,
1012,
1048,
1009,
3091,
1025,
1062,
1012,
1054,
1027,
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... |
SheetJS/js-xlsx | xlsx.js | parse_RString | function parse_RString(blob, length, opts) {
var end = blob.l + length;
var cell = parse_XLSCell(blob, 6);
var cch = blob.read_shift(2);
var str = parse_XLUnicodeStringNoCch(blob, cch, opts);
blob.l = end;
cell.t = 'str';
cell.val = str;
return cell;
} | javascript | function parse_RString(blob, length, opts) {
var end = blob.l + length;
var cell = parse_XLSCell(blob, 6);
var cch = blob.read_shift(2);
var str = parse_XLUnicodeStringNoCch(blob, cch, opts);
blob.l = end;
cell.t = 'str';
cell.val = str;
return cell;
} | [
"function",
"parse_RString",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"end",
"=",
"blob",
".",
"l",
"+",
"length",
";",
"var",
"cell",
"=",
"parse_XLSCell",
"(",
"blob",
",",
"6",
")",
";",
"var",
"cch",
"=",
"blob",
".",
"read_shi... | /* TODO: parse rich text runs | [
"/",
"*",
"TODO",
":",
"parse",
"rich",
"text",
"runs"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6617-L6626 | train | ECMA - 262 12. 2. 2 String | [
30522,
3853,
11968,
3366,
1035,
12667,
18886,
3070,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2203,
1027,
1038,
4135,
2497,
1012,
1048,
1009,
3091,
1025,
13075,
3526,
1027,
11968,
3366,
1035,
28712,
11020,
53... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/workbox | packages/workbox-build/src/entry-points/generate-sw.js | generateSW | async function generateSW(config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, generateSWSchema);
const destDirectory = path.dirname(options.swDest);
// Do nothing if importWorkboxFrom is set to 'disabled'. Otherwise, check:
if (options.importWorkboxFrom === 'cdn') {
const cdnURL = cdnUtils.getModuleURL('workbox-sw');
options.workboxSWImport = cdnURL;
} else if (options.importWorkboxFrom === 'local') {
// Copy over the dev + prod version of all of the core libraries.
const workboxDirectoryName = await copyWorkboxLibraries(destDirectory);
// The Workbox library files should not be precached, since they're cached
// automatically by virtue of being used with importScripts().
options.globIgnores = [
`**/${workboxDirectoryName}/*.+(js|mjs)*`,
].concat(options.globIgnores || []);
const workboxSWPkg = require(`workbox-sw/package.json`);
const workboxSWFilename = path.basename(workboxSWPkg.main);
options.workboxSWImport = `${workboxDirectoryName}/${workboxSWFilename}`;
options.modulePathPrefix = workboxDirectoryName;
}
const {count, size, manifestEntries, warnings} =
await getFileManifestEntries(options);
await writeServiceWorkerUsingDefaultTemplate(Object.assign({
manifestEntries,
}, options));
// Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {count, size, warnings};
} | javascript | async function generateSW(config) {
// This check needs to be done before validation, since the deprecated options
// will be renamed.
const deprecationWarnings = checkForDeprecatedOptions(config);
const options = validate(config, generateSWSchema);
const destDirectory = path.dirname(options.swDest);
// Do nothing if importWorkboxFrom is set to 'disabled'. Otherwise, check:
if (options.importWorkboxFrom === 'cdn') {
const cdnURL = cdnUtils.getModuleURL('workbox-sw');
options.workboxSWImport = cdnURL;
} else if (options.importWorkboxFrom === 'local') {
// Copy over the dev + prod version of all of the core libraries.
const workboxDirectoryName = await copyWorkboxLibraries(destDirectory);
// The Workbox library files should not be precached, since they're cached
// automatically by virtue of being used with importScripts().
options.globIgnores = [
`**/${workboxDirectoryName}/*.+(js|mjs)*`,
].concat(options.globIgnores || []);
const workboxSWPkg = require(`workbox-sw/package.json`);
const workboxSWFilename = path.basename(workboxSWPkg.main);
options.workboxSWImport = `${workboxDirectoryName}/${workboxSWFilename}`;
options.modulePathPrefix = workboxDirectoryName;
}
const {count, size, manifestEntries, warnings} =
await getFileManifestEntries(options);
await writeServiceWorkerUsingDefaultTemplate(Object.assign({
manifestEntries,
}, options));
// Add in any deprecation warnings.
warnings.push(...deprecationWarnings);
return {count, size, warnings};
} | [
"async",
"function",
"generateSW",
"(",
"config",
")",
"{",
"// This check needs to be done before validation, since the deprecated options",
"// will be renamed.",
"const",
"deprecationWarnings",
"=",
"checkForDeprecatedOptions",
"(",
"config",
")",
";",
"const",
"options",
"=... | This method creates a list of URLs to precache, referred to as a "precache
manifest", based on the options you provide.
It also takes in additional options that configures the service worker's
behavior, like any `runtimeCaching` rules it should use.
Based on the precache manifest and the additional configuration, it writes
a ready-to-use service worker file to disk at `swDest`.
@param {Object} config Please refer to the
[configuration guide](https://developers.google.com/web/tools/workbox/modules/workbox-build#full_generatesw_config).
@return {Promise<{count: number, size: number, warnings: Array<string>}>}
A promise that resolves once the service worker file has been written to
`swDest`. The `size` property contains the aggregate size of all the
precached entries, in bytes, and the `count` property contains the total
number of precached entries. Any non-fatal warning messages will be returned
via `warnings`.
@memberof module:workbox-build | [
"This",
"method",
"creates",
"a",
"list",
"of",
"URLs",
"to",
"precache",
"referred",
"to",
"as",
"a",
"precache",
"manifest",
"based",
"on",
"the",
"options",
"you",
"provide",
"."
] | 8379c51b6deaf52faed5879206fe84579cae41f0 | https://github.com/GoogleChrome/workbox/blob/8379c51b6deaf52faed5879206fe84579cae41f0/packages/workbox-build/src/entry-points/generate-sw.js#L42-L83 | train | Generates a service worker using the given configuration. | [
30522,
2004,
6038,
2278,
3853,
19421,
2860,
1006,
9530,
8873,
2290,
1007,
1063,
1013,
1013,
2023,
4638,
3791,
2000,
2022,
2589,
2077,
27354,
1010,
2144,
1996,
2139,
28139,
12921,
7047,
1013,
1013,
2097,
2022,
4096,
1012,
9530,
3367,
2139,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/scales/scale.time.js | determineUnitForAutoTicks | function determineUnitForAutoTicks(minUnit, min, max, capacity) {
var ilen = UNITS.length;
var i, interval, factor;
for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
interval = INTERVALS[UNITS[i]];
factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
return UNITS[i];
}
}
return UNITS[ilen - 1];
} | javascript | function determineUnitForAutoTicks(minUnit, min, max, capacity) {
var ilen = UNITS.length;
var i, interval, factor;
for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
interval = INTERVALS[UNITS[i]];
factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {
return UNITS[i];
}
}
return UNITS[ilen - 1];
} | [
"function",
"determineUnitForAutoTicks",
"(",
"minUnit",
",",
"min",
",",
"max",
",",
"capacity",
")",
"{",
"var",
"ilen",
"=",
"UNITS",
".",
"length",
";",
"var",
"i",
",",
"interval",
",",
"factor",
";",
"for",
"(",
"i",
"=",
"UNITS",
".",
"indexOf",... | Figures out what unit results in an appropriate number of auto-generated ticks | [
"Figures",
"out",
"what",
"unit",
"results",
"in",
"an",
"appropriate",
"number",
"of",
"auto",
"-",
"generated",
"ticks"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/scales/scale.time.js#L278-L292 | train | Determines the unit that should be used for auto tick | [
30522,
3853,
5646,
19496,
24475,
6525,
16161,
26348,
2015,
1006,
8117,
19496,
2102,
1010,
8117,
1010,
4098,
1010,
3977,
1007,
1063,
13075,
17869,
2078,
1027,
3197,
1012,
3091,
1025,
13075,
1045,
1010,
13483,
1010,
5387,
1025,
2005,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Microsoft/vscode | build/lib/git.js | getVersion | function getVersion(repo) {
const git = path.join(repo, '.git');
const headPath = path.join(git, 'HEAD');
let head;
try {
head = fs.readFileSync(headPath, 'utf8').trim();
}
catch (e) {
return undefined;
}
if (/^[0-9a-f]{40}$/i.test(head)) {
return head;
}
const refMatch = /^ref: (.*)$/.exec(head);
if (!refMatch) {
return undefined;
}
const ref = refMatch[1];
const refPath = path.join(git, ref);
try {
return fs.readFileSync(refPath, 'utf8').trim();
}
catch (e) {
// noop
}
const packedRefsPath = path.join(git, 'packed-refs');
let refsRaw;
try {
refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
}
catch (e) {
return undefined;
}
const refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
let refsMatch;
let refs = {};
while (refsMatch = refsRegex.exec(refsRaw)) {
refs[refsMatch[2]] = refsMatch[1];
}
return refs[ref];
} | javascript | function getVersion(repo) {
const git = path.join(repo, '.git');
const headPath = path.join(git, 'HEAD');
let head;
try {
head = fs.readFileSync(headPath, 'utf8').trim();
}
catch (e) {
return undefined;
}
if (/^[0-9a-f]{40}$/i.test(head)) {
return head;
}
const refMatch = /^ref: (.*)$/.exec(head);
if (!refMatch) {
return undefined;
}
const ref = refMatch[1];
const refPath = path.join(git, ref);
try {
return fs.readFileSync(refPath, 'utf8').trim();
}
catch (e) {
// noop
}
const packedRefsPath = path.join(git, 'packed-refs');
let refsRaw;
try {
refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
}
catch (e) {
return undefined;
}
const refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
let refsMatch;
let refs = {};
while (refsMatch = refsRegex.exec(refsRaw)) {
refs[refsMatch[2]] = refsMatch[1];
}
return refs[ref];
} | [
"function",
"getVersion",
"(",
"repo",
")",
"{",
"const",
"git",
"=",
"path",
".",
"join",
"(",
"repo",
",",
"'.git'",
")",
";",
"const",
"headPath",
"=",
"path",
".",
"join",
"(",
"git",
",",
"'HEAD'",
")",
";",
"let",
"head",
";",
"try",
"{",
"... | Returns the sha1 commit version of a repository or undefined in case of failure. | [
"Returns",
"the",
"sha1",
"commit",
"version",
"of",
"a",
"repository",
"or",
"undefined",
"in",
"case",
"of",
"failure",
"."
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/lib/git.js#L12-L52 | train | Get the version of the current branch | [
30522,
3853,
2131,
27774,
1006,
16360,
2080,
1007,
1063,
9530,
3367,
21025,
2102,
1027,
4130,
1012,
3693,
1006,
16360,
2080,
1010,
1005,
1012,
21025,
2102,
1005,
1007,
1025,
9530,
3367,
2132,
15069,
1027,
4130,
1012,
3693,
1006,
21025,
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/chips/demoCustomInputs/script.js | createFilterFor | function createFilterFor(query) {
var lowercaseQuery = query.toLowerCase();
return function filterFn(vegetable) {
return (vegetable._lowername.indexOf(lowercaseQuery) === 0) ||
(vegetable._lowertype.indexOf(lowercaseQuery) === 0);
};
} | javascript | function createFilterFor(query) {
var lowercaseQuery = query.toLowerCase();
return function filterFn(vegetable) {
return (vegetable._lowername.indexOf(lowercaseQuery) === 0) ||
(vegetable._lowertype.indexOf(lowercaseQuery) === 0);
};
} | [
"function",
"createFilterFor",
"(",
"query",
")",
"{",
"var",
"lowercaseQuery",
"=",
"query",
".",
"toLowerCase",
"(",
")",
";",
"return",
"function",
"filterFn",
"(",
"vegetable",
")",
"{",
"return",
"(",
"vegetable",
".",
"_lowername",
".",
"indexOf",
"(",... | Create filter function for a query string | [
"Create",
"filter",
"function",
"for",
"a",
"query",
"string"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/chips/demoCustomInputs/script.js#L46-L54 | 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,
15415,
1007,
1063,
2709,
1006,
15415,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/Decimal.js | validateDecimal | function validateDecimal(sValue, sName) {
if (sValue) {
if (sValue.match(rDecimal)) {
return sValue;
}
logWarning(sValue, sName);
}
} | javascript | function validateDecimal(sValue, sName) {
if (sValue) {
if (sValue.match(rDecimal)) {
return sValue;
}
logWarning(sValue, sName);
}
} | [
"function",
"validateDecimal",
"(",
"sValue",
",",
"sName",
")",
"{",
"if",
"(",
"sValue",
")",
"{",
"if",
"(",
"sValue",
".",
"match",
"(",
"rDecimal",
")",
")",
"{",
"return",
"sValue",
";",
"}",
"logWarning",
"(",
"sValue",
",",
"sName",
")",
";",... | /*
Validates whether the given value is a valid Edm.Decimal value.
@param {string} sValue
the constraint minimum or maximum value
@param {string} sName
name for logging
@returns {string}
the validated value or undefined | [
"/",
"*",
"Validates",
"whether",
"the",
"given",
"value",
"is",
"a",
"valid",
"Edm",
".",
"Decimal",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/Decimal.js#L110-L117 | train | Validates the given value for a decimal property. | [
30522,
3853,
9398,
4383,
8586,
9581,
2140,
1006,
17917,
2389,
5657,
1010,
1055,
18442,
1007,
1063,
2065,
1006,
17917,
2389,
5657,
1007,
1063,
2065,
1006,
17917,
2389,
5657,
1012,
2674,
1006,
16428,
8586,
9581,
2140,
1007,
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... |
nhn/tui.editor | src/js/codemirror/markdown.js | getType | function getType(state) {
var styles = [];
if (state.formatting) {
styles.push(tokenTypes.formatting);
if (typeof state.formatting === "string") state.formatting = [state.formatting];
for (var i = 0; i < state.formatting.length; i++) {
styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
if (state.formatting[i] === "header") {
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
}
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
// Add `error` instead if the maximum blockquote nesting depth is passed
if (state.formatting[i] === "quote") {
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
} else {
styles.push("error");
}
}
}
}
if (state.taskOpen) {
styles.push("meta");
return styles.length ? styles.join(' ') : null;
}
if (state.taskClosed) {
styles.push("property");
return styles.length ? styles.join(' ') : null;
}
if (state.linkHref) {
styles.push(tokenTypes.linkHref, "url");
} else { // Only apply inline styles to non-url text
if (state.strong) { styles.push(tokenTypes.strong); }
if (state.em) { styles.push(tokenTypes.em); }
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
if (state.emoji) { styles.push(tokenTypes.emoji); }
if (state.linkText) { styles.push(tokenTypes.linkText); }
if (state.code) { styles.push(tokenTypes.code); }
if (state.image) { styles.push(tokenTypes.image); }
if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
}
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
if (state.quote) {
styles.push(tokenTypes.quote);
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
styles.push(tokenTypes.quote + "-" + state.quote);
} else {
styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
}
}
if (state.list !== false) {
var listMod = (state.listStack.length - 1) % 3;
if (!listMod) {
styles.push(tokenTypes.list1);
} else if (listMod === 1) {
styles.push(tokenTypes.list2);
} else {
styles.push(tokenTypes.list3);
}
}
if (state.trailingSpaceNewLine) {
styles.push("trailing-space-new-line");
} else if (state.trailingSpace) {
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
}
return styles.length ? styles.join(' ') : null;
} | javascript | function getType(state) {
var styles = [];
if (state.formatting) {
styles.push(tokenTypes.formatting);
if (typeof state.formatting === "string") state.formatting = [state.formatting];
for (var i = 0; i < state.formatting.length; i++) {
styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
if (state.formatting[i] === "header") {
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
}
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
// Add `error` instead if the maximum blockquote nesting depth is passed
if (state.formatting[i] === "quote") {
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
} else {
styles.push("error");
}
}
}
}
if (state.taskOpen) {
styles.push("meta");
return styles.length ? styles.join(' ') : null;
}
if (state.taskClosed) {
styles.push("property");
return styles.length ? styles.join(' ') : null;
}
if (state.linkHref) {
styles.push(tokenTypes.linkHref, "url");
} else { // Only apply inline styles to non-url text
if (state.strong) { styles.push(tokenTypes.strong); }
if (state.em) { styles.push(tokenTypes.em); }
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
if (state.emoji) { styles.push(tokenTypes.emoji); }
if (state.linkText) { styles.push(tokenTypes.linkText); }
if (state.code) { styles.push(tokenTypes.code); }
if (state.image) { styles.push(tokenTypes.image); }
if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
}
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
if (state.quote) {
styles.push(tokenTypes.quote);
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
styles.push(tokenTypes.quote + "-" + state.quote);
} else {
styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
}
}
if (state.list !== false) {
var listMod = (state.listStack.length - 1) % 3;
if (!listMod) {
styles.push(tokenTypes.list1);
} else if (listMod === 1) {
styles.push(tokenTypes.list2);
} else {
styles.push(tokenTypes.list3);
}
}
if (state.trailingSpaceNewLine) {
styles.push("trailing-space-new-line");
} else if (state.trailingSpace) {
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
}
return styles.length ? styles.join(' ') : null;
} | [
"function",
"getType",
"(",
"state",
")",
"{",
"var",
"styles",
"=",
"[",
"]",
";",
"if",
"(",
"state",
".",
"formatting",
")",
"{",
"styles",
".",
"push",
"(",
"tokenTypes",
".",
"formatting",
")",
";",
"if",
"(",
"typeof",
"state",
".",
"formatting... | Inline | [
"Inline"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/codemirror/markdown.js#L318-L399 | train | Get the type of the given state | [
30522,
3853,
2131,
13874,
1006,
2110,
1007,
1063,
13075,
6782,
1027,
1031,
1033,
1025,
2065,
1006,
2110,
1012,
4289,
3436,
1007,
1063,
6782,
1012,
5245,
1006,
19204,
13874,
2015,
1012,
4289,
3436,
1007,
1025,
2065,
1006,
2828,
11253,
2110,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | scripts/docgen/generate-docs.js | generateNodeSource | async function generateNodeSource() {
const sourceText = await fs.readFile(sourceFile, 'utf8');
// Parse index.d.ts. A dummy filename is required but it doesn't create a
// file.
let typescriptSourceFile = typescript.createSourceFile(
'temp.d.ts',
sourceText,
typescript.ScriptTarget.ES2015,
/*setParentNodes */ false
);
/**
* Typescript transformer function. Removes nodes tagged with @webonly.
*/
const removeWebOnlyNodes = context => rootNode => {
function visit(node) {
if (
node.jsDoc &&
node.jsDoc.some(
item =>
item.tags &&
item.tags.some(tag => tag.tagName.escapedText === 'webonly')
)
) {
return null;
}
return typescript.visitEachChild(node, visit, context);
}
return typescript.visitNode(rootNode, visit);
};
// Use above transformer on source AST to remove nodes tagged with @webonly.
const result = typescript.transform(typescriptSourceFile, [
removeWebOnlyNodes
]);
// Convert transformed AST to text and write to file.
const printer = typescript.createPrinter();
return fs.writeFile(
tempNodeSourcePath,
printer.printFile(result.transformed[0])
);
} | javascript | async function generateNodeSource() {
const sourceText = await fs.readFile(sourceFile, 'utf8');
// Parse index.d.ts. A dummy filename is required but it doesn't create a
// file.
let typescriptSourceFile = typescript.createSourceFile(
'temp.d.ts',
sourceText,
typescript.ScriptTarget.ES2015,
/*setParentNodes */ false
);
/**
* Typescript transformer function. Removes nodes tagged with @webonly.
*/
const removeWebOnlyNodes = context => rootNode => {
function visit(node) {
if (
node.jsDoc &&
node.jsDoc.some(
item =>
item.tags &&
item.tags.some(tag => tag.tagName.escapedText === 'webonly')
)
) {
return null;
}
return typescript.visitEachChild(node, visit, context);
}
return typescript.visitNode(rootNode, visit);
};
// Use above transformer on source AST to remove nodes tagged with @webonly.
const result = typescript.transform(typescriptSourceFile, [
removeWebOnlyNodes
]);
// Convert transformed AST to text and write to file.
const printer = typescript.createPrinter();
return fs.writeFile(
tempNodeSourcePath,
printer.printFile(result.transformed[0])
);
} | [
"async",
"function",
"generateNodeSource",
"(",
")",
"{",
"const",
"sourceText",
"=",
"await",
"fs",
".",
"readFile",
"(",
"sourceFile",
",",
"'utf8'",
")",
";",
"// Parse index.d.ts. A dummy filename is required but it doesn't create a",
"// file.",
"let",
"typescriptSou... | Generate an temporary abridged version of index.d.ts used to create
Node docs. | [
"Generate",
"an",
"temporary",
"abridged",
"version",
"of",
"index",
".",
"d",
".",
"ts",
"used",
"to",
"create",
"Node",
"docs",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/scripts/docgen/generate-docs.js#L250-L293 | train | Generate a node source file | [
30522,
2004,
6038,
2278,
3853,
9699,
3630,
6155,
8162,
3401,
1006,
1007,
1063,
9530,
3367,
3120,
18209,
1027,
26751,
1042,
2015,
1012,
3191,
8873,
2571,
1006,
3120,
8873,
2571,
1010,
1005,
21183,
2546,
2620,
1005,
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... |
getinsomnia/insomnia | packages/insomnia-importers/src/importers/openapi3.js | prepareQueryParams | function prepareQueryParams(endpointSchema) {
const isSendInQuery = p => p.in === 'query';
const parameters = endpointSchema.parameters || [];
const queryParameters = parameters.filter(isSendInQuery);
return convertParameters(queryParameters);
} | javascript | function prepareQueryParams(endpointSchema) {
const isSendInQuery = p => p.in === 'query';
const parameters = endpointSchema.parameters || [];
const queryParameters = parameters.filter(isSendInQuery);
return convertParameters(queryParameters);
} | [
"function",
"prepareQueryParams",
"(",
"endpointSchema",
")",
"{",
"const",
"isSendInQuery",
"=",
"p",
"=>",
"p",
".",
"in",
"===",
"'query'",
";",
"const",
"parameters",
"=",
"endpointSchema",
".",
"parameters",
"||",
"[",
"]",
";",
"const",
"queryParameters"... | Imports insomnia definitions of query parameters.
@param {Object} endpointSchema - OpenAPI 3 endpoint schema
@returns {Object[]} array of parameters definitions | [
"Imports",
"insomnia",
"definitions",
"of",
"query",
"parameters",
"."
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-importers/src/importers/openapi3.js#L196-L201 | train | Converts endpoint schema query parameters to query parameters | [
30522,
3853,
7374,
4226,
2854,
28689,
5244,
1006,
2203,
26521,
5403,
2863,
1007,
1063,
9530,
3367,
26354,
10497,
2378,
4226,
2854,
1027,
1052,
1027,
1028,
1052,
1012,
1999,
1027,
1027,
1027,
1005,
23032,
1005,
1025,
9530,
3367,
11709,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function() {
if (this._aDimensionNames) {
return this._aDimensionNames;
}
this._aDimensionNames = [];
for ( var sName in this._oDimensionSet) {
this._aDimensionNames.push(this._oDimensionSet[sName].getName());
}
return this._aDimensionNames;
} | javascript | function() {
if (this._aDimensionNames) {
return this._aDimensionNames;
}
this._aDimensionNames = [];
for ( var sName in this._oDimensionSet) {
this._aDimensionNames.push(this._oDimensionSet[sName].getName());
}
return this._aDimensionNames;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_aDimensionNames",
")",
"{",
"return",
"this",
".",
"_aDimensionNames",
";",
"}",
"this",
".",
"_aDimensionNames",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"sName",
"in",
"this",
".",
"_oDimensionSet",
... | Get the names of all dimensions included in the query result
@returns {string[]} List of all dimension names
@public
@function
@name sap.ui.model.analytics.odata4analytics.QueryResult#getAllDimensionNames | [
"Get",
"the",
"names",
"of",
"all",
"dimensions",
"included",
"in",
"the",
"query",
"result"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L1009-L1021 | train | Returns an array of dimension names | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
1035,
27133,
3549,
10992,
18442,
2015,
1007,
1063,
2709,
2023,
1012,
1035,
27133,
3549,
10992,
18442,
2015,
1025,
1065,
2023,
1012,
1035,
27133,
3549,
10992,
18442,
2015,
1027,
1031,
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/LiveDevelopment/Agents/RemoteFunctions.js | _validEvent | function _validEvent(event) {
if (window.navigator.platform.substr(0, 3) === "Mac") {
// Mac
return event.metaKey;
} else {
// Windows
return event.ctrlKey;
}
} | javascript | function _validEvent(event) {
if (window.navigator.platform.substr(0, 3) === "Mac") {
// Mac
return event.metaKey;
} else {
// Windows
return event.ctrlKey;
}
} | [
"function",
"_validEvent",
"(",
"event",
")",
"{",
"if",
"(",
"window",
".",
"navigator",
".",
"platform",
".",
"substr",
"(",
"0",
",",
"3",
")",
"===",
"\"Mac\"",
")",
"{",
"// Mac",
"return",
"event",
".",
"metaKey",
";",
"}",
"else",
"{",
"// Win... | Keep alive timeout value, in milliseconds determine whether an event should be processed for Live Development | [
"Keep",
"alive",
"timeout",
"value",
"in",
"milliseconds",
"determine",
"whether",
"an",
"event",
"should",
"be",
"processed",
"for",
"Live",
"Development"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteFunctions.js#L66-L74 | train | Check if the event is valid | [
30522,
3853,
1035,
9398,
18697,
3372,
1006,
2724,
1007,
1063,
2065,
1006,
3332,
1012,
20532,
1012,
4132,
1012,
4942,
3367,
2099,
1006,
1014,
1010,
1017,
1007,
1027,
1027,
1027,
1000,
6097,
1000,
1007,
1063,
1013,
1013,
6097,
2709,
2724,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.unified/src/sap/ui/unified/CalendarRow.js | _determineVisibleAppointments | function _determineVisibleAppointments() {
var aAppointments = this._getAppointmentsSorted();
var oAppointment;
var oGroupAppointment;
var oGroupAppointment2;
var iIntervals = this.getIntervals();
var sIntervalType = this.getIntervalType();
var oStartDate = this._getStartDate();
var iStartTime = oStartDate.getTime();
var oEndDate = this._oUTCEndDate;
var iEndTime = oEndDate.getTime();
var aVisibleAppointments = [];
var bFocusIdFound = false;
var i = 0;
var j = 0;
var bGroupsEnabled = _isGroupAppointmentsEnabled.call(this);
this.destroyAggregation("groupAppointments", true);
for (i = 0; i < aAppointments.length; i++) {
oAppointment = aAppointments[i];
var oAppointmentStartDate = CalendarUtils._createUniversalUTCDate(oAppointment.getStartDate(), undefined, true);
oAppointmentStartDate.setUTCSeconds(0); // ignore seconds
oAppointmentStartDate.setUTCMilliseconds(0); // ignore milliseconds
var oAppointmentEndDate = oAppointment.getEndDate()
? CalendarUtils._createUniversalUTCDate(oAppointment.getEndDate(), undefined, true)
: CalendarUtils._createUniversalUTCDate(new Date(864000000000000), undefined, true); //max date
oAppointmentEndDate.setUTCSeconds(0); // ignore seconds
oAppointmentEndDate.setUTCMilliseconds(0); // ignore milliseconds
// set start and end time to be in visible range for minimum calculation
var bCut = false;
if (oAppointmentStartDate.getTime() < iStartTime && oAppointmentEndDate.getTime() >= iStartTime) {
oAppointmentStartDate = new UniversalDate(iStartTime);
bCut = true;
}
if (oAppointmentEndDate.getTime() > iEndTime && oAppointmentStartDate.getTime() <= iEndTime) {
oAppointmentEndDate = new UniversalDate(iEndTime);
bCut = true;
}
// adjust start date to min. delta
var iStartMinutes = oAppointmentStartDate.getUTCHours() * 60 + oAppointmentStartDate.getUTCMinutes();
oAppointmentStartDate.setUTCMinutes(oAppointmentStartDate.getUTCMinutes() - (iStartMinutes % this._iMinDelta));
var iDelta = (oAppointmentEndDate.getTime() - oAppointmentStartDate.getTime()) / 60000;
if (bCut && iDelta == 0) {
// no size after cut -> e.g. starts in past and ends exactly on startDate
continue;
}
var iBegin = 0;
var iEnd = 0;
var iLevel = -1;
oGroupAppointment = undefined;
oGroupAppointment2 = undefined;
if (oAppointmentStartDate && oAppointmentStartDate.getTime() <= iEndTime &&
oAppointmentEndDate && oAppointmentEndDate.getTime() >= iStartTime) {
if (bGroupsEnabled &&
(sIntervalType == CalendarIntervalType.Month) &&
((oAppointmentEndDate.getTime() - oAppointmentStartDate.getTime()) < 604800000/*7 days*/)) {
// in month mode, group appointment < one week
oGroupAppointment = _getGroupAppointment.call(this, oAppointmentStartDate, oAppointment, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, aVisibleAppointments);
var oGroupEndDate = CalendarUtils._createUniversalUTCDate(oGroupAppointment.getEndDate(), undefined, true);
if (oAppointmentEndDate.getTime() > oGroupEndDate.getTime()) {
// appointment ends in next group
oGroupAppointment2 = _getGroupAppointment.call(this, oAppointmentEndDate, oAppointment, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, aVisibleAppointments);
}
}
iBegin = _calculateBegin.call(this, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, oAppointmentStartDate);
iEnd = _calculateEnd.call(this, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, oAppointmentEndDate);
if (oGroupAppointment) {
oGroupAppointment._iBegin = iBegin;
oGroupAppointment._iEnd = iEnd;
oGroupAppointment._iLevel = iLevel;
if (oGroupAppointment2) {
oGroupAppointment2._iBegin = iBegin;
oGroupAppointment2._iEnd = iEnd;
oGroupAppointment2._iLevel = iLevel;
}
continue;
}
aVisibleAppointments.push({appointment: oAppointment, begin: iBegin, end: iEnd, calculatedEnd: iEnd, level: iLevel});
if (this._sFocusedAppointmentId && this._sFocusedAppointmentId == oAppointment.getId()) {
bFocusIdFound = true;
}
}
}
// if group appointment only has one appointment -> show this appointment
var aGroupAppointments = this.getAggregation("groupAppointments", []);
if (aGroupAppointments.length > 0) {
for (i = 0; i < aVisibleAppointments.length; i++) {
oAppointment = aVisibleAppointments[i];
if (oAppointment.appointment._aAppointments && oAppointment.appointment._aAppointments.length <= 1) {
oGroupAppointment = oAppointment.appointment;
// check if already shown
var bFound = false;
if (oGroupAppointment._aAppointments.length == 0) {
// group has no appointment - removed before -> remove from visible appointments
bFound = true;
} else {
for (j = 0; j < aVisibleAppointments.length; j++) {
if (aVisibleAppointments[j].appointment == oGroupAppointment._aAppointments[0]) {
bFound = true;
break;
}
}
}
if (!bFound) {
// check if in other group appointment - remove it
for (j = 0; j < aGroupAppointments.length; j++) {
oGroupAppointment2 = aGroupAppointments[j];
if (oGroupAppointment != oGroupAppointment2) {
for (var k = 0; k < oGroupAppointment2._aAppointments.length; k++) {
if (oGroupAppointment._aAppointments[0] == oGroupAppointment2._aAppointments[k]) {
oGroupAppointment2._aAppointments.splice(k, 1);
if (oGroupAppointment2._aAppointments.length == 1) {
// no appointments left -> delete group
this.removeAggregation("groupAppointments", oGroupAppointment2);
oGroupAppointment2.destroy();
aGroupAppointments = this.getAggregation("groupAppointments", []);
} else {
oGroupAppointment2.setProperty("title", oGroupAppointment2._aAppointments.length, true);
}
break;
}
}
}
}
oAppointment.begin = oGroupAppointment._iBegin;
oAppointment.end = oGroupAppointment._iEnd;
oAppointment.calculatedEnd = oGroupAppointment._iEnd;
oAppointment.level = oGroupAppointment._iLevel;
oAppointment.appointment = oGroupAppointment._aAppointments[0];
} else {
aVisibleAppointments.splice(i, 1);
i--;
}
this.removeAggregation("groupAppointments", oGroupAppointment);
oGroupAppointment.destroy();
aGroupAppointments = this.getAggregation("groupAppointments", []);
}
}
}
// determine levels after rendering because min. size must be used in calculation
if (!bFocusIdFound) {
// focused appointment not visible or no focus set
if (aVisibleAppointments.length > 0) {
this._sFocusedAppointmentId = aVisibleAppointments[0].appointment.getId();
}else {
this._sFocusedAppointmentId = undefined;
}
}
this._aVisibleAppointments = aVisibleAppointments;
return this._aVisibleAppointments;
} | javascript | function _determineVisibleAppointments() {
var aAppointments = this._getAppointmentsSorted();
var oAppointment;
var oGroupAppointment;
var oGroupAppointment2;
var iIntervals = this.getIntervals();
var sIntervalType = this.getIntervalType();
var oStartDate = this._getStartDate();
var iStartTime = oStartDate.getTime();
var oEndDate = this._oUTCEndDate;
var iEndTime = oEndDate.getTime();
var aVisibleAppointments = [];
var bFocusIdFound = false;
var i = 0;
var j = 0;
var bGroupsEnabled = _isGroupAppointmentsEnabled.call(this);
this.destroyAggregation("groupAppointments", true);
for (i = 0; i < aAppointments.length; i++) {
oAppointment = aAppointments[i];
var oAppointmentStartDate = CalendarUtils._createUniversalUTCDate(oAppointment.getStartDate(), undefined, true);
oAppointmentStartDate.setUTCSeconds(0); // ignore seconds
oAppointmentStartDate.setUTCMilliseconds(0); // ignore milliseconds
var oAppointmentEndDate = oAppointment.getEndDate()
? CalendarUtils._createUniversalUTCDate(oAppointment.getEndDate(), undefined, true)
: CalendarUtils._createUniversalUTCDate(new Date(864000000000000), undefined, true); //max date
oAppointmentEndDate.setUTCSeconds(0); // ignore seconds
oAppointmentEndDate.setUTCMilliseconds(0); // ignore milliseconds
// set start and end time to be in visible range for minimum calculation
var bCut = false;
if (oAppointmentStartDate.getTime() < iStartTime && oAppointmentEndDate.getTime() >= iStartTime) {
oAppointmentStartDate = new UniversalDate(iStartTime);
bCut = true;
}
if (oAppointmentEndDate.getTime() > iEndTime && oAppointmentStartDate.getTime() <= iEndTime) {
oAppointmentEndDate = new UniversalDate(iEndTime);
bCut = true;
}
// adjust start date to min. delta
var iStartMinutes = oAppointmentStartDate.getUTCHours() * 60 + oAppointmentStartDate.getUTCMinutes();
oAppointmentStartDate.setUTCMinutes(oAppointmentStartDate.getUTCMinutes() - (iStartMinutes % this._iMinDelta));
var iDelta = (oAppointmentEndDate.getTime() - oAppointmentStartDate.getTime()) / 60000;
if (bCut && iDelta == 0) {
// no size after cut -> e.g. starts in past and ends exactly on startDate
continue;
}
var iBegin = 0;
var iEnd = 0;
var iLevel = -1;
oGroupAppointment = undefined;
oGroupAppointment2 = undefined;
if (oAppointmentStartDate && oAppointmentStartDate.getTime() <= iEndTime &&
oAppointmentEndDate && oAppointmentEndDate.getTime() >= iStartTime) {
if (bGroupsEnabled &&
(sIntervalType == CalendarIntervalType.Month) &&
((oAppointmentEndDate.getTime() - oAppointmentStartDate.getTime()) < 604800000/*7 days*/)) {
// in month mode, group appointment < one week
oGroupAppointment = _getGroupAppointment.call(this, oAppointmentStartDate, oAppointment, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, aVisibleAppointments);
var oGroupEndDate = CalendarUtils._createUniversalUTCDate(oGroupAppointment.getEndDate(), undefined, true);
if (oAppointmentEndDate.getTime() > oGroupEndDate.getTime()) {
// appointment ends in next group
oGroupAppointment2 = _getGroupAppointment.call(this, oAppointmentEndDate, oAppointment, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, aVisibleAppointments);
}
}
iBegin = _calculateBegin.call(this, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, oAppointmentStartDate);
iEnd = _calculateEnd.call(this, sIntervalType, iIntervals, oStartDate, oEndDate, iStartTime, oAppointmentEndDate);
if (oGroupAppointment) {
oGroupAppointment._iBegin = iBegin;
oGroupAppointment._iEnd = iEnd;
oGroupAppointment._iLevel = iLevel;
if (oGroupAppointment2) {
oGroupAppointment2._iBegin = iBegin;
oGroupAppointment2._iEnd = iEnd;
oGroupAppointment2._iLevel = iLevel;
}
continue;
}
aVisibleAppointments.push({appointment: oAppointment, begin: iBegin, end: iEnd, calculatedEnd: iEnd, level: iLevel});
if (this._sFocusedAppointmentId && this._sFocusedAppointmentId == oAppointment.getId()) {
bFocusIdFound = true;
}
}
}
// if group appointment only has one appointment -> show this appointment
var aGroupAppointments = this.getAggregation("groupAppointments", []);
if (aGroupAppointments.length > 0) {
for (i = 0; i < aVisibleAppointments.length; i++) {
oAppointment = aVisibleAppointments[i];
if (oAppointment.appointment._aAppointments && oAppointment.appointment._aAppointments.length <= 1) {
oGroupAppointment = oAppointment.appointment;
// check if already shown
var bFound = false;
if (oGroupAppointment._aAppointments.length == 0) {
// group has no appointment - removed before -> remove from visible appointments
bFound = true;
} else {
for (j = 0; j < aVisibleAppointments.length; j++) {
if (aVisibleAppointments[j].appointment == oGroupAppointment._aAppointments[0]) {
bFound = true;
break;
}
}
}
if (!bFound) {
// check if in other group appointment - remove it
for (j = 0; j < aGroupAppointments.length; j++) {
oGroupAppointment2 = aGroupAppointments[j];
if (oGroupAppointment != oGroupAppointment2) {
for (var k = 0; k < oGroupAppointment2._aAppointments.length; k++) {
if (oGroupAppointment._aAppointments[0] == oGroupAppointment2._aAppointments[k]) {
oGroupAppointment2._aAppointments.splice(k, 1);
if (oGroupAppointment2._aAppointments.length == 1) {
// no appointments left -> delete group
this.removeAggregation("groupAppointments", oGroupAppointment2);
oGroupAppointment2.destroy();
aGroupAppointments = this.getAggregation("groupAppointments", []);
} else {
oGroupAppointment2.setProperty("title", oGroupAppointment2._aAppointments.length, true);
}
break;
}
}
}
}
oAppointment.begin = oGroupAppointment._iBegin;
oAppointment.end = oGroupAppointment._iEnd;
oAppointment.calculatedEnd = oGroupAppointment._iEnd;
oAppointment.level = oGroupAppointment._iLevel;
oAppointment.appointment = oGroupAppointment._aAppointments[0];
} else {
aVisibleAppointments.splice(i, 1);
i--;
}
this.removeAggregation("groupAppointments", oGroupAppointment);
oGroupAppointment.destroy();
aGroupAppointments = this.getAggregation("groupAppointments", []);
}
}
}
// determine levels after rendering because min. size must be used in calculation
if (!bFocusIdFound) {
// focused appointment not visible or no focus set
if (aVisibleAppointments.length > 0) {
this._sFocusedAppointmentId = aVisibleAppointments[0].appointment.getId();
}else {
this._sFocusedAppointmentId = undefined;
}
}
this._aVisibleAppointments = aVisibleAppointments;
return this._aVisibleAppointments;
} | [
"function",
"_determineVisibleAppointments",
"(",
")",
"{",
"var",
"aAppointments",
"=",
"this",
".",
"_getAppointmentsSorted",
"(",
")",
";",
"var",
"oAppointment",
";",
"var",
"oGroupAppointment",
";",
"var",
"oGroupAppointment2",
";",
"var",
"iIntervals",
"=",
... | /*
returns an array of visible appointments
each entry is an object with the following properties
- appointment: the appointment object
- begin: begin position in %
- end: end position in %
- level: level of the appointment to not overlap | [
"/",
"*",
"returns",
"an",
"array",
"of",
"visible",
"appointments",
"each",
"entry",
"is",
"an",
"object",
"with",
"the",
"following",
"properties",
"-",
"appointment",
":",
"the",
"appointment",
"object",
"-",
"begin",
":",
"begin",
"position",
"in",
"%",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.unified/src/sap/ui/unified/CalendarRow.js#L1092-L1262 | train | Determines if the calendar is visible. | [
30522,
3853,
1035,
5646,
11365,
7028,
29098,
25785,
8163,
1006,
1007,
1063,
13075,
9779,
9397,
25785,
8163,
1027,
2023,
1012,
1035,
2131,
29098,
25785,
8163,
21748,
3064,
1006,
1007,
1025,
13075,
1051,
29098,
25785,
3672,
1025,
13075,
13958,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
mochajs/mocha | lib/reporters/list.js | List | function List(runner, options) {
Base.call(this, runner, options);
var self = this;
var n = 0;
runner.on(EVENT_RUN_BEGIN, function() {
console.log();
});
runner.on(EVENT_TEST_BEGIN, function(test) {
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
});
runner.on(EVENT_TEST_PENDING, function(test) {
var fmt = color('checkmark', ' -') + color('pending', ' %s');
console.log(fmt, test.fullTitle());
});
runner.on(EVENT_TEST_PASS, function(test) {
var fmt =
color('checkmark', ' ' + Base.symbols.ok) +
color('pass', ' %s: ') +
color(test.speed, '%dms');
cursor.CR();
console.log(fmt, test.fullTitle(), test.duration);
});
runner.on(EVENT_TEST_FAIL, function(test) {
cursor.CR();
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
});
runner.once(EVENT_RUN_END, self.epilogue.bind(self));
} | javascript | function List(runner, options) {
Base.call(this, runner, options);
var self = this;
var n = 0;
runner.on(EVENT_RUN_BEGIN, function() {
console.log();
});
runner.on(EVENT_TEST_BEGIN, function(test) {
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
});
runner.on(EVENT_TEST_PENDING, function(test) {
var fmt = color('checkmark', ' -') + color('pending', ' %s');
console.log(fmt, test.fullTitle());
});
runner.on(EVENT_TEST_PASS, function(test) {
var fmt =
color('checkmark', ' ' + Base.symbols.ok) +
color('pass', ' %s: ') +
color(test.speed, '%dms');
cursor.CR();
console.log(fmt, test.fullTitle(), test.duration);
});
runner.on(EVENT_TEST_FAIL, function(test) {
cursor.CR();
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
});
runner.once(EVENT_RUN_END, self.epilogue.bind(self));
} | [
"function",
"List",
"(",
"runner",
",",
"options",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
",",
"options",
")",
";",
"var",
"self",
"=",
"this",
";",
"var",
"n",
"=",
"0",
";",
"runner",
".",
"on",
"(",
"EVENT_RUN_BEGIN",
",",
... | Constructs a new `List` reporter instance.
@public
@class
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options | [
"Constructs",
"a",
"new",
"List",
"reporter",
"instance",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/list.js#L37-L71 | train | List of tests in a phrase. | [
30522,
3853,
2862,
1006,
5479,
1010,
7047,
1007,
1063,
2918,
1012,
2655,
1006,
2023,
1010,
5479,
1010,
7047,
1007,
1025,
13075,
2969,
1027,
2023,
1025,
13075,
1050,
1027,
1014,
1025,
5479,
1012,
2006,
1006,
2724,
1035,
2448,
1035,
4088,
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/extensions/default/RecentProjects/main.js | checkHovers | function checkHovers(pageX, pageY) {
$dropdown.children().each(function () {
var offset = $(this).offset(),
width = $(this).outerWidth(),
height = $(this).outerHeight();
if (pageX >= offset.left && pageX <= offset.left + width &&
pageY >= offset.top && pageY <= offset.top + height) {
$(".recent-folder-link", this).triggerHandler("mouseenter");
}
});
} | javascript | function checkHovers(pageX, pageY) {
$dropdown.children().each(function () {
var offset = $(this).offset(),
width = $(this).outerWidth(),
height = $(this).outerHeight();
if (pageX >= offset.left && pageX <= offset.left + width &&
pageY >= offset.top && pageY <= offset.top + height) {
$(".recent-folder-link", this).triggerHandler("mouseenter");
}
});
} | [
"function",
"checkHovers",
"(",
"pageX",
",",
"pageY",
")",
"{",
"$dropdown",
".",
"children",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"offset",
"=",
"$",
"(",
"this",
")",
".",
"offset",
"(",
")",
",",
"width",
"=",
"$",
"(... | Check the list of items to see if any of them are hovered, and if so trigger a mouseenter.
Normally the mouseenter event handles this, but when a previous item is deleted and the next
item moves up to be underneath the mouse, we don't get a mouseenter event for that item. | [
"Check",
"the",
"list",
"of",
"items",
"to",
"see",
"if",
"any",
"of",
"them",
"are",
"hovered",
"and",
"if",
"so",
"trigger",
"a",
"mouseenter",
".",
"Normally",
"the",
"mouseenter",
"event",
"handles",
"this",
"but",
"when",
"a",
"previous",
"item",
"i... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/RecentProjects/main.js#L98-L109 | train | check hovers | [
30522,
3853,
4638,
6806,
14028,
1006,
3931,
2595,
1010,
3931,
2100,
1007,
1063,
1002,
4530,
7698,
1012,
2336,
1006,
1007,
1012,
2169,
1006,
3853,
1006,
1007,
1063,
13075,
16396,
1027,
1002,
1006,
2023,
1007,
1012,
16396,
1006,
1007,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | stopAndGo | function stopAndGo(aElements, fnCallback) {
var i = -1;
/*
* Visits the next element, taking the result of the previous callback into account.
*
* @param {boolean} bFound
* Whether an element was approved by the corresponding callback
* @returns {sap.ui.base.SyncPromise|any}
* First call returns a <code>sap.ui.base.SyncPromise</code> which resolves with a later
* call's result.
*/
function next(bFound) {
if (bFound) {
return aElements[i];
}
i += 1;
if (i < aElements.length) {
return fnCallback(aElements[i], i, aElements).then(next);
}
}
return aElements.length
? next()
: oSyncPromiseResolved;
} | javascript | function stopAndGo(aElements, fnCallback) {
var i = -1;
/*
* Visits the next element, taking the result of the previous callback into account.
*
* @param {boolean} bFound
* Whether an element was approved by the corresponding callback
* @returns {sap.ui.base.SyncPromise|any}
* First call returns a <code>sap.ui.base.SyncPromise</code> which resolves with a later
* call's result.
*/
function next(bFound) {
if (bFound) {
return aElements[i];
}
i += 1;
if (i < aElements.length) {
return fnCallback(aElements[i], i, aElements).then(next);
}
}
return aElements.length
? next()
: oSyncPromiseResolved;
} | [
"function",
"stopAndGo",
"(",
"aElements",
",",
"fnCallback",
")",
"{",
"var",
"i",
"=",
"-",
"1",
";",
"/*\n\t\t * Visits the next element, taking the result of the previous callback into account.\n\t\t *\n\t\t * @param {boolean} bFound\n\t\t * Whether an element was approved by the c... | Visits the given elements one-by-one, calls the given callback for each of them and stops
and waits for each sync promise returned by the callback before going on to the next element.
If a sync promise resolves with a truthy value, iteration stops and the corresponding element
becomes the result of the returned sync promise.
@param {any[]} aElements
Whatever elements we want to visit
@param {function} fnCallback
A function to be called with a single element and its index and the array (like
{@link Array#find} does it), returning a {@link sap.ui.base.SyncPromise}.
@returns {sap.ui.base.SyncPromise}
A sync promise which resolves with the first element where the callback's sync promise
resolved with a truthy value, or resolves with <code>undefined</code> as soon as the last
callback's sync promise has resolved, or is rejected with a corresponding error if any
callback returns a rejected sync promise or throws an error
@throws {Error}
If the first callback throws | [
"Visits",
"the",
"given",
"elements",
"one",
"-",
"by",
"-",
"one",
"calls",
"the",
"given",
"callback",
"for",
"each",
"of",
"them",
"and",
"stops",
"and",
"waits",
"for",
"each",
"sync",
"promise",
"returned",
"by",
"the",
"callback",
"before",
"going",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L429-L454 | train | Calls the callback function for each element in the array and stops the iteration. | [
30522,
3853,
2644,
5685,
3995,
1006,
29347,
16930,
11187,
1010,
1042,
20909,
3363,
5963,
1007,
1063,
13075,
1045,
1027,
1011,
1015,
1025,
1013,
1008,
1008,
7879,
1996,
2279,
5783,
1010,
2635,
1996,
2765,
1997,
1996,
3025,
2655,
5963,
2046,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | populateActionCodes | function populateActionCodes() {
var emailForSignIn = null;
var signInTime = 0;
if ('localStorage' in window && window['localStorage'] !== null) {
try {
// Try to parse as JSON first using new storage format.
var emailForSignInData =
JSON.parse(window.localStorage.getItem('emailForSignIn'));
emailForSignIn = emailForSignInData['email'] || null;
signInTime = emailForSignInData['timestamp'] || 0;
} catch (e) {
// JSON parsing failed. This means the email is stored in the old string
// format.
emailForSignIn = window.localStorage.getItem('emailForSignIn');
}
if (emailForSignIn) {
// Clear old codes. Old format codes should be cleared immediately.
if (new Date().getTime() - signInTime >= 1 * 24 * 3600 * 1000) {
// Remove email from storage.
window.localStorage.removeItem('emailForSignIn');
}
}
}
var actionCode = getParameterByName('oobCode');
if (actionCode != null) {
var mode = getParameterByName('mode');
if (mode == 'verifyEmail') {
$('#email-verification-code').val(actionCode);
} else if (mode == 'resetPassword') {
$('#password-reset-code').val(actionCode);
} else if (mode == 'signIn') {
if (emailForSignIn) {
$('#sign-in-with-email-link-email').val(emailForSignIn);
$('#sign-in-with-email-link-link').val(window.location.href);
onSignInWithEmailLink();
// Remove email from storage as the code is only usable once.
window.localStorage.removeItem('emailForSignIn');
}
} else {
$('#email-verification-code').val(actionCode);
$('#password-reset-code').val(actionCode);
}
}
} | javascript | function populateActionCodes() {
var emailForSignIn = null;
var signInTime = 0;
if ('localStorage' in window && window['localStorage'] !== null) {
try {
// Try to parse as JSON first using new storage format.
var emailForSignInData =
JSON.parse(window.localStorage.getItem('emailForSignIn'));
emailForSignIn = emailForSignInData['email'] || null;
signInTime = emailForSignInData['timestamp'] || 0;
} catch (e) {
// JSON parsing failed. This means the email is stored in the old string
// format.
emailForSignIn = window.localStorage.getItem('emailForSignIn');
}
if (emailForSignIn) {
// Clear old codes. Old format codes should be cleared immediately.
if (new Date().getTime() - signInTime >= 1 * 24 * 3600 * 1000) {
// Remove email from storage.
window.localStorage.removeItem('emailForSignIn');
}
}
}
var actionCode = getParameterByName('oobCode');
if (actionCode != null) {
var mode = getParameterByName('mode');
if (mode == 'verifyEmail') {
$('#email-verification-code').val(actionCode);
} else if (mode == 'resetPassword') {
$('#password-reset-code').val(actionCode);
} else if (mode == 'signIn') {
if (emailForSignIn) {
$('#sign-in-with-email-link-email').val(emailForSignIn);
$('#sign-in-with-email-link-link').val(window.location.href);
onSignInWithEmailLink();
// Remove email from storage as the code is only usable once.
window.localStorage.removeItem('emailForSignIn');
}
} else {
$('#email-verification-code').val(actionCode);
$('#password-reset-code').val(actionCode);
}
}
} | [
"function",
"populateActionCodes",
"(",
")",
"{",
"var",
"emailForSignIn",
"=",
"null",
";",
"var",
"signInTime",
"=",
"0",
";",
"if",
"(",
"'localStorage'",
"in",
"window",
"&&",
"window",
"[",
"'localStorage'",
"]",
"!==",
"null",
")",
"{",
"try",
"{",
... | Detects if an action code is passed in the URL, and populates accordingly
the input field for the confirm email verification process. | [
"Detects",
"if",
"an",
"action",
"code",
"is",
"passed",
"in",
"the",
"URL",
"and",
"populates",
"accordingly",
"the",
"input",
"field",
"for",
"the",
"confirm",
"email",
"verification",
"process",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L1128-L1171 | train | Populate the action codes | [
30522,
3853,
3769,
9869,
18908,
3258,
23237,
1006,
1007,
1063,
13075,
10373,
29278,
5332,
29076,
2078,
1027,
19701,
1025,
13075,
3696,
18447,
14428,
1027,
1014,
1025,
2065,
1006,
1005,
10575,
4263,
4270,
1005,
1999,
3332,
1004,
1004,
3332,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/command/KeyBindingManager.js | _addBinding | function _addBinding(commandID, keyBinding, platform, userBindings) {
var key,
result = null,
normalized,
normalizedDisplay,
explicitPlatform = keyBinding.platform || platform,
targetPlatform,
command,
bindingsToDelete = [],
existing;
// For platform: "all", use explicit current platform
if (explicitPlatform && explicitPlatform !== "all") {
targetPlatform = explicitPlatform;
} else {
targetPlatform = brackets.platform;
}
// Skip if the key binding is not for this platform.
if (explicitPlatform === "mac" && brackets.platform !== "mac") {
return null;
}
// if the request does not specify an explicit platform, and we're
// currently on a mac, then replace Ctrl with Cmd.
key = (keyBinding.key) || keyBinding;
if (brackets.platform === "mac" && (explicitPlatform === undefined || explicitPlatform === "all")) {
key = key.replace("Ctrl", "Cmd");
if (keyBinding.displayKey !== undefined) {
keyBinding.displayKey = keyBinding.displayKey.replace("Ctrl", "Cmd");
}
}
normalized = normalizeKeyDescriptorString(key);
// skip if the key binding is invalid
if (!normalized) {
console.error("Unable to parse key binding " + key + ". Permitted modifiers: Ctrl, Cmd, Alt, Opt, Shift; separated by '-' (not '+').");
return null;
}
// check for duplicate key bindings
existing = _keyMap[normalized];
// for cross-platform compatibility
if (exports.useWindowsCompatibleBindings) {
// windows-only key bindings are used as the default binding
// only if a default binding wasn't already defined
if (explicitPlatform === "win") {
// search for a generic or platform-specific binding if it
// already exists
if (existing && (!existing.explicitPlatform ||
existing.explicitPlatform === brackets.platform ||
existing.explicitPlatform === "all")) {
// do not clobber existing binding with windows-only binding
return null;
}
// target this windows binding for the current platform
targetPlatform = brackets.platform;
}
}
// skip if this binding doesn't match the current platform
if (targetPlatform !== brackets.platform) {
return null;
}
// skip if the key is already assigned
if (existing) {
if (!existing.explicitPlatform && explicitPlatform) {
// remove the the generic binding to replace with this new platform-specific binding
removeBinding(normalized);
existing = false;
}
}
// delete existing bindings when
// (1) replacing a windows-compatible binding with a generic or
// platform-specific binding
// (2) replacing a generic binding with a platform-specific binding
var existingBindings = _commandMap[commandID] || [],
isWindowsCompatible,
isReplaceGeneric,
ignoreGeneric;
existingBindings.forEach(function (binding) {
// remove windows-only bindings in _commandMap
isWindowsCompatible = exports.useWindowsCompatibleBindings &&
binding.explicitPlatform === "win";
// remove existing generic binding
isReplaceGeneric = !binding.explicitPlatform &&
explicitPlatform;
if (isWindowsCompatible || isReplaceGeneric) {
bindingsToDelete.push(binding);
} else {
// existing binding is platform-specific and the requested binding is generic
ignoreGeneric = binding.explicitPlatform && !explicitPlatform;
}
});
if (ignoreGeneric) {
// explicit command binding overrides this one
return null;
}
if (existing) {
// do not re-assign a key binding
console.error("Cannot assign " + normalized + " to " + commandID + ". It is already assigned to " + _keyMap[normalized].commandID);
return null;
}
// remove generic or windows-compatible bindings
bindingsToDelete.forEach(function (binding) {
removeBinding(binding.key);
});
// optional display-friendly string (e.g. CMD-+ instead of CMD-=)
normalizedDisplay = (keyBinding.displayKey) ? normalizeKeyDescriptorString(keyBinding.displayKey) : normalized;
// 1-to-many commandID mapping to key binding
if (!_commandMap[commandID]) {
_commandMap[commandID] = [];
}
result = {
key : normalized,
displayKey : normalizedDisplay,
explicitPlatform : explicitPlatform
};
_commandMap[commandID].push(result);
// 1-to-1 key binding to commandID
_keyMap[normalized] = {
commandID : commandID,
key : normalized,
displayKey : normalizedDisplay,
explicitPlatform : explicitPlatform
};
if (!userBindings) {
_updateCommandAndKeyMaps(_keyMap[normalized]);
}
// notify listeners
command = CommandManager.get(commandID);
if (command) {
command.trigger("keyBindingAdded", result);
}
return result;
} | javascript | function _addBinding(commandID, keyBinding, platform, userBindings) {
var key,
result = null,
normalized,
normalizedDisplay,
explicitPlatform = keyBinding.platform || platform,
targetPlatform,
command,
bindingsToDelete = [],
existing;
// For platform: "all", use explicit current platform
if (explicitPlatform && explicitPlatform !== "all") {
targetPlatform = explicitPlatform;
} else {
targetPlatform = brackets.platform;
}
// Skip if the key binding is not for this platform.
if (explicitPlatform === "mac" && brackets.platform !== "mac") {
return null;
}
// if the request does not specify an explicit platform, and we're
// currently on a mac, then replace Ctrl with Cmd.
key = (keyBinding.key) || keyBinding;
if (brackets.platform === "mac" && (explicitPlatform === undefined || explicitPlatform === "all")) {
key = key.replace("Ctrl", "Cmd");
if (keyBinding.displayKey !== undefined) {
keyBinding.displayKey = keyBinding.displayKey.replace("Ctrl", "Cmd");
}
}
normalized = normalizeKeyDescriptorString(key);
// skip if the key binding is invalid
if (!normalized) {
console.error("Unable to parse key binding " + key + ". Permitted modifiers: Ctrl, Cmd, Alt, Opt, Shift; separated by '-' (not '+').");
return null;
}
// check for duplicate key bindings
existing = _keyMap[normalized];
// for cross-platform compatibility
if (exports.useWindowsCompatibleBindings) {
// windows-only key bindings are used as the default binding
// only if a default binding wasn't already defined
if (explicitPlatform === "win") {
// search for a generic or platform-specific binding if it
// already exists
if (existing && (!existing.explicitPlatform ||
existing.explicitPlatform === brackets.platform ||
existing.explicitPlatform === "all")) {
// do not clobber existing binding with windows-only binding
return null;
}
// target this windows binding for the current platform
targetPlatform = brackets.platform;
}
}
// skip if this binding doesn't match the current platform
if (targetPlatform !== brackets.platform) {
return null;
}
// skip if the key is already assigned
if (existing) {
if (!existing.explicitPlatform && explicitPlatform) {
// remove the the generic binding to replace with this new platform-specific binding
removeBinding(normalized);
existing = false;
}
}
// delete existing bindings when
// (1) replacing a windows-compatible binding with a generic or
// platform-specific binding
// (2) replacing a generic binding with a platform-specific binding
var existingBindings = _commandMap[commandID] || [],
isWindowsCompatible,
isReplaceGeneric,
ignoreGeneric;
existingBindings.forEach(function (binding) {
// remove windows-only bindings in _commandMap
isWindowsCompatible = exports.useWindowsCompatibleBindings &&
binding.explicitPlatform === "win";
// remove existing generic binding
isReplaceGeneric = !binding.explicitPlatform &&
explicitPlatform;
if (isWindowsCompatible || isReplaceGeneric) {
bindingsToDelete.push(binding);
} else {
// existing binding is platform-specific and the requested binding is generic
ignoreGeneric = binding.explicitPlatform && !explicitPlatform;
}
});
if (ignoreGeneric) {
// explicit command binding overrides this one
return null;
}
if (existing) {
// do not re-assign a key binding
console.error("Cannot assign " + normalized + " to " + commandID + ". It is already assigned to " + _keyMap[normalized].commandID);
return null;
}
// remove generic or windows-compatible bindings
bindingsToDelete.forEach(function (binding) {
removeBinding(binding.key);
});
// optional display-friendly string (e.g. CMD-+ instead of CMD-=)
normalizedDisplay = (keyBinding.displayKey) ? normalizeKeyDescriptorString(keyBinding.displayKey) : normalized;
// 1-to-many commandID mapping to key binding
if (!_commandMap[commandID]) {
_commandMap[commandID] = [];
}
result = {
key : normalized,
displayKey : normalizedDisplay,
explicitPlatform : explicitPlatform
};
_commandMap[commandID].push(result);
// 1-to-1 key binding to commandID
_keyMap[normalized] = {
commandID : commandID,
key : normalized,
displayKey : normalizedDisplay,
explicitPlatform : explicitPlatform
};
if (!userBindings) {
_updateCommandAndKeyMaps(_keyMap[normalized]);
}
// notify listeners
command = CommandManager.get(commandID);
if (command) {
command.trigger("keyBindingAdded", result);
}
return result;
} | [
"function",
"_addBinding",
"(",
"commandID",
",",
"keyBinding",
",",
"platform",
",",
"userBindings",
")",
"{",
"var",
"key",
",",
"result",
"=",
"null",
",",
"normalized",
",",
"normalizedDisplay",
",",
"explicitPlatform",
"=",
"keyBinding",
".",
"platform",
... | @private
@param {string} commandID
@param {string|{{key: string, displayKey: string}}} keyBinding - a single shortcut.
@param {?string} platform
- "all" indicates all platforms, not overridable
- undefined indicates all platforms, overridden by platform-specific binding
@param {boolean=} userBindings true if adding a user key binding or undefined otherwise.
@return {?{key: string, displayKey:String}} Returns a record for valid key bindings.
Returns null when key binding platform does not match, binding does not normalize,
or is already assigned. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/command/KeyBindingManager.js#L636-L792 | train | Add a key binding to the command list | [
30522,
3853,
1035,
5587,
8428,
4667,
1006,
3094,
3593,
1010,
3145,
8428,
4667,
1010,
4132,
1010,
5310,
8428,
4667,
2015,
1007,
1063,
13075,
3145,
1010,
2765,
1027,
19701,
1010,
3671,
3550,
1010,
3671,
3550,
10521,
13068,
1010,
13216,
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... |
eslint/eslint | lib/rules/no-duplicate-imports.js | handleImports | function handleImports(context, includeExports, importsInFile, exportsInFile) {
return function(node) {
const value = getValue(node);
if (value) {
checkAndReport(context, node, value, importsInFile, "import");
if (includeExports) {
checkAndReport(context, node, value, exportsInFile, "importAs");
}
importsInFile.push(value);
}
};
} | javascript | function handleImports(context, includeExports, importsInFile, exportsInFile) {
return function(node) {
const value = getValue(node);
if (value) {
checkAndReport(context, node, value, importsInFile, "import");
if (includeExports) {
checkAndReport(context, node, value, exportsInFile, "importAs");
}
importsInFile.push(value);
}
};
} | [
"function",
"handleImports",
"(",
"context",
",",
"includeExports",
",",
"importsInFile",
",",
"exportsInFile",
")",
"{",
"return",
"function",
"(",
"node",
")",
"{",
"const",
"value",
"=",
"getValue",
"(",
"node",
")",
";",
"if",
"(",
"value",
")",
"{",
... | @callback nodeCallback
@param {ASTNode} node - A node to handle.
Returns a function handling the imports of a given file
@param {RuleContext} context - The ESLint rule context object.
@param {boolean} includeExports - Whether or not to check for exports in addition to imports.
@param {string[]} importsInFile - The array containing other imports in the file.
@param {string[]} exportsInFile - The array containing other exports in the file.
@returns {nodeCallback} A function passed to ESLint to handle the statement. | [
"@callback",
"nodeCallback",
"@param",
"{",
"ASTNode",
"}",
"node",
"-",
"A",
"node",
"to",
"handle",
".",
"Returns",
"a",
"function",
"handling",
"the",
"imports",
"of",
"a",
"given",
"file"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-duplicate-imports.js#L63-L77 | train | Handle imports | [
30522,
3853,
5047,
5714,
25378,
1006,
6123,
1010,
2421,
10288,
25378,
1010,
17589,
2378,
8873,
2571,
1010,
14338,
2378,
8873,
2571,
1007,
1063,
2709,
3853,
1006,
13045,
1007,
1063,
9530,
3367,
3643,
1027,
2131,
10175,
5657,
1006,
13045,
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... |
eslint/eslint | lib/rules/max-len.js | groupByLineNumber | function groupByLineNumber(acc, node) {
for (let i = node.loc.start.line; i <= node.loc.end.line; ++i) {
ensureArrayAndPush(acc, i, node);
}
return acc;
} | javascript | function groupByLineNumber(acc, node) {
for (let i = node.loc.start.line; i <= node.loc.end.line; ++i) {
ensureArrayAndPush(acc, i, node);
}
return acc;
} | [
"function",
"groupByLineNumber",
"(",
"acc",
",",
"node",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"node",
".",
"loc",
".",
"start",
".",
"line",
";",
"i",
"<=",
"node",
".",
"loc",
".",
"end",
".",
"line",
";",
"++",
"i",
")",
"{",
"ensureArrayAnd... | A reducer to group an AST node by line number, both start and end.
@param {Object} acc the accumulator
@param {ASTNode} node the AST node in question
@returns {Object} the modified accumulator
@private | [
"A",
"reducer",
"to",
"group",
"an",
"AST",
"node",
"by",
"line",
"number",
"both",
"start",
"and",
"end",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-len.js#L253-L258 | train | group by line number | [
30522,
3853,
2177,
3762,
4179,
19172,
5677,
1006,
16222,
1010,
13045,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
13045,
1012,
8840,
2278,
1012,
2707,
1012,
2240,
1025,
1045,
1026,
1027,
13045,
1012,
8840,
2278,
1012,
2203,
1012,
2240,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-shadow-restricted-names.js | safelyShadowsUndefined | function safelyShadowsUndefined(variable) {
return variable.name === "undefined" &&
variable.references.every(ref => !ref.isWrite()) &&
variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
} | javascript | function safelyShadowsUndefined(variable) {
return variable.name === "undefined" &&
variable.references.every(ref => !ref.isWrite()) &&
variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
} | [
"function",
"safelyShadowsUndefined",
"(",
"variable",
")",
"{",
"return",
"variable",
".",
"name",
"===",
"\"undefined\"",
"&&",
"variable",
".",
"references",
".",
"every",
"(",
"ref",
"=>",
"!",
"ref",
".",
"isWrite",
"(",
")",
")",
"&&",
"variable",
".... | Determines if a variable safely shadows undefined.
This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value
as the global).
@param {eslintScope.Variable} variable The variable to check
@returns {boolean} true if this variable safely shadows `undefined` | [
"Determines",
"if",
"a",
"variable",
"safely",
"shadows",
"undefined",
".",
"This",
"is",
"the",
"case",
"when",
"a",
"variable",
"named",
"undefined",
"is",
"never",
"assigned",
"to",
"a",
"value",
"(",
"i",
".",
"e",
".",
"it",
"always",
"shares",
"the... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-shadow-restricted-names.js#L14-L18 | train | Check if a variable is shadowed to undefined | [
30522,
3853,
9689,
7377,
3527,
9333,
8630,
28344,
1006,
8023,
1007,
1063,
2709,
8023,
1012,
2171,
1027,
1027,
1027,
1000,
6151,
28344,
1000,
1004,
1004,
8023,
1012,
7604,
1012,
2296,
1006,
25416,
1027,
1028,
999,
25416,
1012,
2003,
26373,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/colors/colors.js | extractPalette | function extractPalette(parts, theme) {
// If the next section is one of the palettes we assume it's a two word palette
// Two word palette can be also written in camelCase, forming camelCase to dash-case
var isTwoWord = parts.length > 1 && colorPalettes.indexOf(parts[1]) !== -1;
var palette = parts[0].replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
if (isTwoWord) palette = parts[0] + '-' + parts.splice(1, 1);
if (colorPalettes.indexOf(palette) === -1) {
// If the palette is not in the palette list it's one of primary/accent/warn/background
var scheme = $mdTheming.THEMES[theme].colors[palette];
if (!scheme) {
throw new Error($mdUtil.supplant(
'mdColors: couldn\'t find \'{palette}\' in the palettes.',
{palette: palette}));
}
palette = scheme.name;
}
return palette;
} | javascript | function extractPalette(parts, theme) {
// If the next section is one of the palettes we assume it's a two word palette
// Two word palette can be also written in camelCase, forming camelCase to dash-case
var isTwoWord = parts.length > 1 && colorPalettes.indexOf(parts[1]) !== -1;
var palette = parts[0].replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
if (isTwoWord) palette = parts[0] + '-' + parts.splice(1, 1);
if (colorPalettes.indexOf(palette) === -1) {
// If the palette is not in the palette list it's one of primary/accent/warn/background
var scheme = $mdTheming.THEMES[theme].colors[palette];
if (!scheme) {
throw new Error($mdUtil.supplant(
'mdColors: couldn\'t find \'{palette}\' in the palettes.',
{palette: palette}));
}
palette = scheme.name;
}
return palette;
} | [
"function",
"extractPalette",
"(",
"parts",
",",
"theme",
")",
"{",
"// If the next section is one of the palettes we assume it's a two word palette",
"// Two word palette can be also written in camelCase, forming camelCase to dash-case",
"var",
"isTwoWord",
"=",
"parts",
".",
"length"... | Calculate the theme palette name
@param {Array} parts
@param {string} theme name
@return {string} | [
"Calculate",
"the",
"theme",
"palette",
"name"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/colors/colors.js#L194-L215 | train | Extract the palette from the next section of the palette list | [
30522,
3853,
14817,
12952,
7585,
1006,
3033,
1010,
4323,
1007,
1063,
1013,
1013,
2065,
1996,
2279,
2930,
2003,
2028,
1997,
1996,
27396,
2015,
2057,
7868,
2009,
1005,
1055,
1037,
2048,
2773,
27396,
1013,
1013,
2048,
2773,
27396,
2064,
2022,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
TryGhost/Ghost | core/server/models/base/index.js | onFetching | function onFetching(model, columns, options) {
if (options.forUpdate && options.transacting) {
options.query.forUpdate();
}
} | javascript | function onFetching(model, columns, options) {
if (options.forUpdate && options.transacting) {
options.query.forUpdate();
}
} | [
"function",
"onFetching",
"(",
"model",
",",
"columns",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"forUpdate",
"&&",
"options",
".",
"transacting",
")",
"{",
"options",
".",
"query",
".",
"forUpdate",
"(",
")",
";",
"}",
"}"
] | http://knexjs.org/#Builder-forUpdate
https://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html
Lock target collection/model for further update operations.
This avoids collisions and possible content override cases. | [
"http",
":",
"//",
"knexjs",
".",
"org",
"/",
"#Builder",
"-",
"forUpdate",
"https",
":",
"//",
"dev",
".",
"mysql",
".",
"com",
"/",
"doc",
"/",
"refman",
"/",
"5",
".",
"7",
"/",
"en",
"/",
"innodb",
"-",
"locking",
"-",
"reads",
".",
"html"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L286-L290 | train | When the database is fetched we need to fetch the record from the database | [
30522,
3853,
2006,
7959,
10649,
2075,
1006,
2944,
1010,
7753,
1010,
7047,
1007,
1063,
2065,
1006,
7047,
1012,
2005,
6279,
13701,
1004,
1004,
7047,
1012,
9099,
18908,
2075,
1007,
1063,
7047,
1012,
23032,
1012,
2005,
6279,
13701,
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... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (msgStr) {
var msg;
try {
msg = JSON.parse(msgStr);
} catch (e) {
console.log("[Brackets LiveDev] Malformed message received: ", msgStr);
return;
}
// delegates handling/routing to MessageBroker.
MessageBroker.trigger(msg);
} | javascript | function (msgStr) {
var msg;
try {
msg = JSON.parse(msgStr);
} catch (e) {
console.log("[Brackets LiveDev] Malformed message received: ", msgStr);
return;
}
// delegates handling/routing to MessageBroker.
MessageBroker.trigger(msg);
} | [
"function",
"(",
"msgStr",
")",
"{",
"var",
"msg",
";",
"try",
"{",
"msg",
"=",
"JSON",
".",
"parse",
"(",
"msgStr",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Malformed message received: \"",
",",
"msgS... | Handles a message from the transport. Parses it as JSON and delegates
to MessageBroker who is in charge of routing them to handlers.
@param {string} msgStr The protocol message as stringified JSON. | [
"Handles",
"a",
"message",
"from",
"the",
"transport",
".",
"Parses",
"it",
"as",
"JSON",
"and",
"delegates",
"to",
"MessageBroker",
"who",
"is",
"in",
"charge",
"of",
"routing",
"them",
"to",
"handlers",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L353-L363 | train | Parse a message and trigger a message broker | [
30522,
3853,
1006,
5796,
5620,
16344,
1007,
1063,
13075,
5796,
2290,
1025,
3046,
1063,
5796,
2290,
1027,
1046,
3385,
1012,
11968,
3366,
1006,
5796,
5620,
16344,
1007,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
10122,
1012,
8833,
1006,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
mochajs/mocha | lib/reporters/html.js | makeUrl | function makeUrl(s) {
var search = window.location.search;
// Remove previous grep query parameter if present
if (search) {
search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
}
return (
window.location.pathname +
(search ? search + '&' : '?') +
'grep=' +
encodeURIComponent(escapeRe(s))
);
} | javascript | function makeUrl(s) {
var search = window.location.search;
// Remove previous grep query parameter if present
if (search) {
search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
}
return (
window.location.pathname +
(search ? search + '&' : '?') +
'grep=' +
encodeURIComponent(escapeRe(s))
);
} | [
"function",
"makeUrl",
"(",
"s",
")",
"{",
"var",
"search",
"=",
"window",
".",
"location",
".",
"search",
";",
"// Remove previous grep query parameter if present",
"if",
"(",
"search",
")",
"{",
"search",
"=",
"search",
".",
"replace",
"(",
"/",
"[?&]grep=[^... | Makes a URL, preserving querystring ("search") parameters.
@param {string} s
@return {string} A new URL. | [
"Makes",
"a",
"URL",
"preserving",
"querystring",
"(",
"search",
")",
"parameters",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/html.js#L255-L269 | train | Make a url from a string | [
30522,
3853,
2191,
3126,
2140,
1006,
1055,
1007,
1063,
13075,
3945,
1027,
3332,
1012,
3295,
1012,
3945,
1025,
1013,
1013,
6366,
3025,
24665,
13699,
23032,
16381,
2065,
2556,
2065,
1006,
3945,
1007,
1063,
3945,
1027,
3945,
1012,
5672,
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... |
mochajs/mocha | lib/reporters/nyan.js | NyanCat | function NyanCat(runner, options) {
Base.call(this, runner, options);
var self = this;
var width = (Base.window.width * 0.75) | 0;
var nyanCatWidth = (this.nyanCatWidth = 11);
this.colorIndex = 0;
this.numberOfLines = 4;
this.rainbowColors = self.generateColors();
this.scoreboardWidth = 5;
this.tick = 0;
this.trajectories = [[], [], [], []];
this.trajectoryWidthMax = width - nyanCatWidth;
runner.on(EVENT_RUN_BEGIN, function() {
Base.cursor.hide();
self.draw();
});
runner.on(EVENT_TEST_PENDING, function() {
self.draw();
});
runner.on(EVENT_TEST_PASS, function() {
self.draw();
});
runner.on(EVENT_TEST_FAIL, function() {
self.draw();
});
runner.once(EVENT_RUN_END, function() {
Base.cursor.show();
for (var i = 0; i < self.numberOfLines; i++) {
write('\n');
}
self.epilogue();
});
} | javascript | function NyanCat(runner, options) {
Base.call(this, runner, options);
var self = this;
var width = (Base.window.width * 0.75) | 0;
var nyanCatWidth = (this.nyanCatWidth = 11);
this.colorIndex = 0;
this.numberOfLines = 4;
this.rainbowColors = self.generateColors();
this.scoreboardWidth = 5;
this.tick = 0;
this.trajectories = [[], [], [], []];
this.trajectoryWidthMax = width - nyanCatWidth;
runner.on(EVENT_RUN_BEGIN, function() {
Base.cursor.hide();
self.draw();
});
runner.on(EVENT_TEST_PENDING, function() {
self.draw();
});
runner.on(EVENT_TEST_PASS, function() {
self.draw();
});
runner.on(EVENT_TEST_FAIL, function() {
self.draw();
});
runner.once(EVENT_RUN_END, function() {
Base.cursor.show();
for (var i = 0; i < self.numberOfLines; i++) {
write('\n');
}
self.epilogue();
});
} | [
"function",
"NyanCat",
"(",
"runner",
",",
"options",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
",",
"options",
")",
";",
"var",
"self",
"=",
"this",
";",
"var",
"width",
"=",
"(",
"Base",
".",
"window",
".",
"width",
"*",
"0.75",
... | Constructs a new `Nyan` reporter instance.
@public
@class Nyan
@memberof Mocha.reporters
@extends Mocha.reporters.Base
@param {Runner} runner - Instance triggers reporter actions.
@param {Object} [options] - runner options | [
"Constructs",
"a",
"new",
"Nyan",
"reporter",
"instance",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/reporters/nyan.js#L34-L73 | train | Nyan Cat class | [
30522,
3853,
6396,
2319,
11266,
1006,
5479,
1010,
7047,
1007,
1063,
2918,
1012,
2655,
1006,
2023,
1010,
5479,
1010,
7047,
1007,
1025,
13075,
2969,
1027,
2023,
1025,
13075,
9381,
1027,
1006,
2918,
1012,
3332,
1012,
9381,
1008,
1014,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentCommandHandlers.js | handleFileClose | function handleFileClose(commandData) {
var file,
promptOnly,
_forceClose,
_spawnedRequest,
paneId = MainViewManager.ACTIVE_PANE;
if (commandData) {
file = commandData.file;
promptOnly = commandData.promptOnly;
_forceClose = commandData._forceClose;
paneId = commandData.paneId || paneId;
_spawnedRequest = commandData.spawnedRequest || false;
}
// utility function for handleFileClose: closes document & removes from workingset
function doClose(file) {
if (!promptOnly) {
MainViewManager._close(paneId, file);
HealthLogger.fileClosed(file);
}
}
var result = new $.Deferred(), promise = result.promise();
// Default to current document if doc is null
if (!file) {
file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
}
// No-op if called when nothing is open; TODO: (issue #273) should command be grayed out instead?
if (!file) {
result.resolve();
return promise;
}
var doc = DocumentManager.getOpenDocumentForPath(file.fullPath);
if (doc && doc.isDirty && !_forceClose && (MainViewManager.isExclusiveToPane(doc.file, paneId) || _spawnedRequest)) {
// Document is dirty: prompt to save changes before closing if only the document is exclusively
// listed in the requested pane or this is part of a list close request
var filename = FileUtils.getBaseName(doc.file.fullPath);
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_SAVE_CLOSE,
Strings.SAVE_CLOSE_TITLE,
StringUtils.format(
Strings.SAVE_CLOSE_MESSAGE,
StringUtils.breakableUrl(filename)
),
[
{
className : Dialogs.DIALOG_BTN_CLASS_LEFT,
id : Dialogs.DIALOG_BTN_DONTSAVE,
text : Strings.DONT_SAVE
},
{
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
id : Dialogs.DIALOG_BTN_CANCEL,
text : Strings.CANCEL
},
{
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id : Dialogs.DIALOG_BTN_OK,
text : Strings.SAVE
}
]
)
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_CANCEL) {
dispatchAppQuitCancelledEvent();
result.reject();
} else if (id === Dialogs.DIALOG_BTN_OK) {
// "Save" case: wait until we confirm save has succeeded before closing
handleFileSave({doc: doc})
.done(function (newFile) {
doClose(newFile);
result.resolve();
})
.fail(function () {
result.reject();
});
} else {
// "Don't Save" case: even though we're closing the main editor, other views of
// the Document may remain in the UI. So we need to revert the Document to a clean
// copy of whatever's on disk.
doClose(file);
// Only reload from disk if we've executed the Close for real.
if (promptOnly) {
result.resolve();
} else {
// Even if there are no listeners attached to the document at this point, we want
// to do the revert anyway, because clients who are listening to the global documentChange
// event from the Document module (rather than attaching to the document directly),
// such as the Find in Files panel, should get a change event. However, in that case,
// we want to ignore errors during the revert, since we don't want a failed revert
// to throw a dialog if the document isn't actually open in the UI.
var suppressError = !DocumentManager.getOpenDocumentForPath(file.fullPath);
_doRevert(doc, suppressError)
.then(result.resolve, result.reject);
}
}
});
result.always(function () {
MainViewManager.focusActivePane();
});
} else {
// File is not open, or IS open but Document not dirty: close immediately
doClose(file);
MainViewManager.focusActivePane();
result.resolve();
}
return promise;
} | javascript | function handleFileClose(commandData) {
var file,
promptOnly,
_forceClose,
_spawnedRequest,
paneId = MainViewManager.ACTIVE_PANE;
if (commandData) {
file = commandData.file;
promptOnly = commandData.promptOnly;
_forceClose = commandData._forceClose;
paneId = commandData.paneId || paneId;
_spawnedRequest = commandData.spawnedRequest || false;
}
// utility function for handleFileClose: closes document & removes from workingset
function doClose(file) {
if (!promptOnly) {
MainViewManager._close(paneId, file);
HealthLogger.fileClosed(file);
}
}
var result = new $.Deferred(), promise = result.promise();
// Default to current document if doc is null
if (!file) {
file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);
}
// No-op if called when nothing is open; TODO: (issue #273) should command be grayed out instead?
if (!file) {
result.resolve();
return promise;
}
var doc = DocumentManager.getOpenDocumentForPath(file.fullPath);
if (doc && doc.isDirty && !_forceClose && (MainViewManager.isExclusiveToPane(doc.file, paneId) || _spawnedRequest)) {
// Document is dirty: prompt to save changes before closing if only the document is exclusively
// listed in the requested pane or this is part of a list close request
var filename = FileUtils.getBaseName(doc.file.fullPath);
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_SAVE_CLOSE,
Strings.SAVE_CLOSE_TITLE,
StringUtils.format(
Strings.SAVE_CLOSE_MESSAGE,
StringUtils.breakableUrl(filename)
),
[
{
className : Dialogs.DIALOG_BTN_CLASS_LEFT,
id : Dialogs.DIALOG_BTN_DONTSAVE,
text : Strings.DONT_SAVE
},
{
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
id : Dialogs.DIALOG_BTN_CANCEL,
text : Strings.CANCEL
},
{
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id : Dialogs.DIALOG_BTN_OK,
text : Strings.SAVE
}
]
)
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_CANCEL) {
dispatchAppQuitCancelledEvent();
result.reject();
} else if (id === Dialogs.DIALOG_BTN_OK) {
// "Save" case: wait until we confirm save has succeeded before closing
handleFileSave({doc: doc})
.done(function (newFile) {
doClose(newFile);
result.resolve();
})
.fail(function () {
result.reject();
});
} else {
// "Don't Save" case: even though we're closing the main editor, other views of
// the Document may remain in the UI. So we need to revert the Document to a clean
// copy of whatever's on disk.
doClose(file);
// Only reload from disk if we've executed the Close for real.
if (promptOnly) {
result.resolve();
} else {
// Even if there are no listeners attached to the document at this point, we want
// to do the revert anyway, because clients who are listening to the global documentChange
// event from the Document module (rather than attaching to the document directly),
// such as the Find in Files panel, should get a change event. However, in that case,
// we want to ignore errors during the revert, since we don't want a failed revert
// to throw a dialog if the document isn't actually open in the UI.
var suppressError = !DocumentManager.getOpenDocumentForPath(file.fullPath);
_doRevert(doc, suppressError)
.then(result.resolve, result.reject);
}
}
});
result.always(function () {
MainViewManager.focusActivePane();
});
} else {
// File is not open, or IS open but Document not dirty: close immediately
doClose(file);
MainViewManager.focusActivePane();
result.resolve();
}
return promise;
} | [
"function",
"handleFileClose",
"(",
"commandData",
")",
"{",
"var",
"file",
",",
"promptOnly",
",",
"_forceClose",
",",
"_spawnedRequest",
",",
"paneId",
"=",
"MainViewManager",
".",
"ACTIVE_PANE",
";",
"if",
"(",
"commandData",
")",
"{",
"file",
"=",
"command... | Closes the specified file: removes it from the workingset, and closes the main editor if one
is open. Prompts user about saving changes first, if document is dirty.
@param {?{file: File, promptOnly:boolean}} commandData Optional bag of arguments:
file - File to close; assumes the current document if not specified.
promptOnly - If true, only displays the relevant confirmation UI and does NOT actually
close the document. This is useful when chaining file-close together with other user
prompts that may be cancelable.
_forceClose - If true, closes the document without prompting even if there are unsaved
changes. Only for use in unit tests.
@return {$.Promise} a promise that is resolved when the file is closed, or if no file is open.
FUTURE: should we reject the promise if no file is open? | [
"Closes",
"the",
"specified",
"file",
":",
"removes",
"it",
"from",
"the",
"workingset",
"and",
"closes",
"the",
"main",
"editor",
"if",
"one",
"is",
"open",
".",
"Prompts",
"user",
"about",
"saving",
"changes",
"first",
"if",
"document",
"is",
"dirty",
".... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentCommandHandlers.js#L1181-L1295 | train | Handle file close | [
30522,
3853,
5047,
8873,
2571,
20464,
9232,
1006,
3094,
2850,
2696,
1007,
1063,
13075,
5371,
1010,
25732,
2239,
2135,
1010,
1035,
2486,
20464,
9232,
1010,
1035,
18379,
2890,
15500,
1010,
6090,
7416,
2094,
1027,
2364,
8584,
24805,
4590,
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... |
eslint/eslint | tools/fuzzer-runner.js | run | function run({ amount = 300, fuzzBrokenAutofixes = true } = {}) {
const crashTestCount = amount * CRASH_AUTOFIX_TEST_COUNT_RATIO;
const autofixTestCount = fuzzBrokenAutofixes ? amount : 0;
/*
* To keep the progress bar moving at a roughly constant speed, apply a different weight for finishing
* a crash-only fuzzer run versus an autofix fuzzer run.
*/
const progressBar = new ProgressBar(
"Fuzzing rules [:bar] :percent, :elapseds elapsed, eta :etas, errors so far: :elapsedErrors",
{ width: 30, total: crashTestCount + autofixTestCount * ESTIMATED_CRASH_AUTOFIX_PERFORMANCE_RATIO }
);
// Start displaying the progress bar.
progressBar.tick(0, { elapsedErrors: 0 });
const crashTestResults = fuzz({
linter,
count: crashTestCount,
checkAutofixes: false,
progressCallback: elapsedErrors => {
progressBar.tick(1, { elapsedErrors });
progressBar.render();
}
});
const autofixTestResults = fuzz({
linter,
count: autofixTestCount,
checkAutofixes: true,
progressCallback: elapsedErrors => {
progressBar.tick(ESTIMATED_CRASH_AUTOFIX_PERFORMANCE_RATIO, { elapsedErrors: crashTestResults.length + elapsedErrors });
progressBar.render();
}
});
return crashTestResults.concat(autofixTestResults);
} | javascript | function run({ amount = 300, fuzzBrokenAutofixes = true } = {}) {
const crashTestCount = amount * CRASH_AUTOFIX_TEST_COUNT_RATIO;
const autofixTestCount = fuzzBrokenAutofixes ? amount : 0;
/*
* To keep the progress bar moving at a roughly constant speed, apply a different weight for finishing
* a crash-only fuzzer run versus an autofix fuzzer run.
*/
const progressBar = new ProgressBar(
"Fuzzing rules [:bar] :percent, :elapseds elapsed, eta :etas, errors so far: :elapsedErrors",
{ width: 30, total: crashTestCount + autofixTestCount * ESTIMATED_CRASH_AUTOFIX_PERFORMANCE_RATIO }
);
// Start displaying the progress bar.
progressBar.tick(0, { elapsedErrors: 0 });
const crashTestResults = fuzz({
linter,
count: crashTestCount,
checkAutofixes: false,
progressCallback: elapsedErrors => {
progressBar.tick(1, { elapsedErrors });
progressBar.render();
}
});
const autofixTestResults = fuzz({
linter,
count: autofixTestCount,
checkAutofixes: true,
progressCallback: elapsedErrors => {
progressBar.tick(ESTIMATED_CRASH_AUTOFIX_PERFORMANCE_RATIO, { elapsedErrors: crashTestResults.length + elapsedErrors });
progressBar.render();
}
});
return crashTestResults.concat(autofixTestResults);
} | [
"function",
"run",
"(",
"{",
"amount",
"=",
"300",
",",
"fuzzBrokenAutofixes",
"=",
"true",
"}",
"=",
"{",
"}",
")",
"{",
"const",
"crashTestCount",
"=",
"amount",
"*",
"CRASH_AUTOFIX_TEST_COUNT_RATIO",
";",
"const",
"autofixTestCount",
"=",
"fuzzBrokenAutofixes... | ------------------------------------------------------------------------------ Public API ------------------------------------------------------------------------------
Runs the fuzzer and outputs a progress bar
@param {Object} [options] Options for the fuzzer
@param {number} [options.amount=300] A positive integer indicating how much testing to do. Larger values result in a higher
chance of finding bugs, but cause the testing to take longer (linear increase). With the default value, the fuzzer
takes about 15 seconds to run.
@param {boolean} [options.fuzzBrokenAutofixes=true] true if the fuzzer should look for invalid autofixes in addition to rule crashes
@returns {Object[]} A list of objects, where each object represents a problem detected by the fuzzer. The objects have the same
schema as objects returned from eslint-fuzzer. | [
"------------------------------------------------------------------------------",
"Public",
"API",
"------------------------------------------------------------------------------",
"Runs",
"the",
"fuzzer",
"and",
"outputs",
"a",
"progress",
"bar"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/tools/fuzzer-runner.js#L41-L79 | train | Run the autofix - fuzzer | [
30522,
3853,
2448,
1006,
1063,
3815,
1027,
3998,
1010,
11865,
13213,
29162,
4887,
3406,
8873,
20156,
1027,
2995,
1065,
1027,
1063,
1065,
1007,
1063,
9530,
3367,
5823,
22199,
3597,
16671,
1027,
3815,
1008,
5823,
1035,
8285,
8873,
2595,
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... |
summernote/summernote | src/js/base/core/dom.js | isVisiblePoint | function isVisiblePoint(point) {
if (isText(point.node) || !hasChildren(point.node) || isEmpty(point.node)) {
return true;
}
const leftNode = point.node.childNodes[point.offset - 1];
const rightNode = point.node.childNodes[point.offset];
if ((!leftNode || isVoid(leftNode)) && (!rightNode || isVoid(rightNode))) {
return true;
}
return false;
} | javascript | function isVisiblePoint(point) {
if (isText(point.node) || !hasChildren(point.node) || isEmpty(point.node)) {
return true;
}
const leftNode = point.node.childNodes[point.offset - 1];
const rightNode = point.node.childNodes[point.offset];
if ((!leftNode || isVoid(leftNode)) && (!rightNode || isVoid(rightNode))) {
return true;
}
return false;
} | [
"function",
"isVisiblePoint",
"(",
"point",
")",
"{",
"if",
"(",
"isText",
"(",
"point",
".",
"node",
")",
"||",
"!",
"hasChildren",
"(",
"point",
".",
"node",
")",
"||",
"isEmpty",
"(",
"point",
".",
"node",
")",
")",
"{",
"return",
"true",
";",
"... | returns whether point is visible (can set cursor) or not.
@param {BoundaryPoint} point
@return {Boolean} | [
"returns",
"whether",
"point",
"is",
"visible",
"(",
"can",
"set",
"cursor",
")",
"or",
"not",
"."
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L602-L614 | train | Check if point is visible | [
30522,
3853,
2003,
11365,
7028,
8400,
1006,
2391,
1007,
1063,
2065,
1006,
21541,
10288,
2102,
1006,
2391,
1012,
13045,
1007,
1064,
1064,
999,
2038,
19339,
7389,
1006,
2391,
1012,
13045,
1007,
1064,
1064,
2003,
6633,
13876,
2100,
1006,
2391,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/FormattedTextView.js | function (aControls) {
if (this.hasControls()) {
this.removeAllAggregation("controls");
}
var bIsArray = Array.isArray(aControls);
if (bIsArray && aControls.length > 0) {
// iterate through the given array but suppress invalidate
for (var i = 0; i < aControls.length; i++) {
this.addAggregation("controls", aControls[i], true);
}
this.invalidate();
}
} | javascript | function (aControls) {
if (this.hasControls()) {
this.removeAllAggregation("controls");
}
var bIsArray = Array.isArray(aControls);
if (bIsArray && aControls.length > 0) {
// iterate through the given array but suppress invalidate
for (var i = 0; i < aControls.length; i++) {
this.addAggregation("controls", aControls[i], true);
}
this.invalidate();
}
} | [
"function",
"(",
"aControls",
")",
"{",
"if",
"(",
"this",
".",
"hasControls",
"(",
")",
")",
"{",
"this",
".",
"removeAllAggregation",
"(",
"\"controls\"",
")",
";",
"}",
"var",
"bIsArray",
"=",
"Array",
".",
"isArray",
"(",
"aControls",
")",
";",
"if... | Sets the controls to be rendered.
@param {array} aControls Controls should be rendered
@private | [
"Sets",
"the",
"controls",
"to",
"be",
"rendered",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/FormattedTextView.js#L227-L240 | train | Adds the given controls to the control collection. | [
30522,
3853,
1006,
9353,
12162,
13153,
2015,
1007,
1063,
2065,
1006,
2023,
1012,
2038,
8663,
13181,
4877,
1006,
1007,
1007,
1063,
2023,
1012,
6366,
25425,
13871,
2890,
12540,
1006,
1000,
7711,
1000,
1007,
1025,
1065,
13075,
20377,
2906,
944... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Context.js | fetchPrimitiveValue | function fetchPrimitiveValue(oContext, sPath, bExternalFormat, bCached) {
var oError,
aPromises = [oContext.fetchValue(sPath, null, bCached)],
sResolvedPath = oContext.getPath(sPath);
if (bExternalFormat) {
aPromises.push(
oContext.oModel.getMetaModel().fetchUI5Type(sResolvedPath));
}
return SyncPromise.all(aPromises).then(function (aResults) {
var oType = aResults[1],
vValue = aResults[0];
if (vValue && typeof vValue === "object") {
oError = new Error("Accessed value is not primitive: " + sResolvedPath);
oError.isNotPrimitive = true;
throw oError;
}
return bExternalFormat ? oType.formatValue(vValue, "string") : vValue;
});
} | javascript | function fetchPrimitiveValue(oContext, sPath, bExternalFormat, bCached) {
var oError,
aPromises = [oContext.fetchValue(sPath, null, bCached)],
sResolvedPath = oContext.getPath(sPath);
if (bExternalFormat) {
aPromises.push(
oContext.oModel.getMetaModel().fetchUI5Type(sResolvedPath));
}
return SyncPromise.all(aPromises).then(function (aResults) {
var oType = aResults[1],
vValue = aResults[0];
if (vValue && typeof vValue === "object") {
oError = new Error("Accessed value is not primitive: " + sResolvedPath);
oError.isNotPrimitive = true;
throw oError;
}
return bExternalFormat ? oType.formatValue(vValue, "string") : vValue;
});
} | [
"function",
"fetchPrimitiveValue",
"(",
"oContext",
",",
"sPath",
",",
"bExternalFormat",
",",
"bCached",
")",
"{",
"var",
"oError",
",",
"aPromises",
"=",
"[",
"oContext",
".",
"fetchValue",
"(",
"sPath",
",",
"null",
",",
"bCached",
")",
"]",
",",
"sReso... | /*
Fetches and formats the primitive value at the given path.
@param {sap.ui.model.odata.v4.Context} oContext The context
@param {string} sPath The requested path
@param {boolean} [bExternalFormat=false]
If <code>true</code>, the value is returned in external format using a UI5 type for the
given property path that formats corresponding to the property's EDM type and constraints.
@param {boolean} [bCached=false]
Whether to return cached values only and not trigger a request
@returns {sap.ui.base.SyncPromise} a promise on the formatted value | [
"/",
"*",
"Fetches",
"and",
"formats",
"the",
"primitive",
"value",
"at",
"the",
"given",
"path",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/Context.js#L34-L54 | train | Fetch a primitive value from the given context | [
30522,
3853,
18584,
18098,
27605,
6024,
10175,
5657,
1006,
1051,
8663,
18209,
1010,
14690,
2232,
1010,
2022,
18413,
11795,
2389,
14192,
4017,
1010,
4647,
15395,
2094,
1007,
1063,
13075,
1051,
2121,
29165,
1010,
19804,
20936,
8583,
1027,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/utils/fs.js | writeStream | function writeStream(filename, st) {
var d = Promise.defer();
var wstream = fs.createWriteStream(filename);
var cleanup = function() {
destroy(wstream);
wstream.removeAllListeners();
};
wstream.on('finish', function () {
cleanup();
d.resolve();
});
wstream.on('error', function (err) {
cleanup();
d.reject(err);
});
st.on('error', function(err) {
cleanup();
d.reject(err);
});
st.pipe(wstream);
return d.promise;
} | javascript | function writeStream(filename, st) {
var d = Promise.defer();
var wstream = fs.createWriteStream(filename);
var cleanup = function() {
destroy(wstream);
wstream.removeAllListeners();
};
wstream.on('finish', function () {
cleanup();
d.resolve();
});
wstream.on('error', function (err) {
cleanup();
d.reject(err);
});
st.on('error', function(err) {
cleanup();
d.reject(err);
});
st.pipe(wstream);
return d.promise;
} | [
"function",
"writeStream",
"(",
"filename",
",",
"st",
")",
"{",
"var",
"d",
"=",
"Promise",
".",
"defer",
"(",
")",
";",
"var",
"wstream",
"=",
"fs",
".",
"createWriteStream",
"(",
"filename",
")",
";",
"var",
"cleanup",
"=",
"function",
"(",
")",
"... | Write a stream to a file | [
"Write",
"a",
"stream",
"to",
"a",
"file"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L14-L40 | train | Write a stream to a file | [
30522,
3853,
7009,
25379,
1006,
5371,
18442,
1010,
2358,
1007,
1063,
13075,
1040,
1027,
4872,
1012,
13366,
2121,
1006,
1007,
1025,
13075,
1059,
21422,
1027,
1042,
2015,
1012,
3443,
26373,
21422,
1006,
5371,
18442,
1007,
1025,
13075,
27686,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/update.js | buildUpdate | function buildUpdate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request
*
* @param {string} id - Document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {string} lang - The script language (default: painless)
* @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0)
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {number} if_seq_no - only perform the update operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the update operation if the last operation that has changed the document has the specified primary term
* @param {object} body - The request definition requires either `script` or partial `doc`
*/
const acceptedQuerystring = [
'wait_for_active_shards',
'_source',
'_source_excludes',
'_source_includes',
'lang',
'parent',
'refresh',
'retry_on_conflict',
'routing',
'timeout',
'if_seq_no',
'if_primary_term',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
retryOnConflict: 'retry_on_conflict',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function update (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['id'] == null) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
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, id, index, type, ...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 = ''
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id)
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildUpdate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request
*
* @param {string} id - Document ID
* @param {string} index - The name of the index
* @param {string} type - The type of the document
* @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
* @param {list} _source - True or false to return the _source field or not, or a list of fields to return
* @param {list} _source_excludes - A list of fields to exclude from the returned _source field
* @param {list} _source_includes - A list of fields to extract and return from the _source field
* @param {string} lang - The script language (default: painless)
* @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request
* @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
* @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0)
* @param {string} routing - Specific routing value
* @param {time} timeout - Explicit operation timeout
* @param {number} if_seq_no - only perform the update operation if the last operation that has changed the document has the specified sequence number
* @param {number} if_primary_term - only perform the update operation if the last operation that has changed the document has the specified primary term
* @param {object} body - The request definition requires either `script` or partial `doc`
*/
const acceptedQuerystring = [
'wait_for_active_shards',
'_source',
'_source_excludes',
'_source_includes',
'lang',
'parent',
'refresh',
'retry_on_conflict',
'routing',
'timeout',
'if_seq_no',
'if_primary_term',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
waitForActiveShards: 'wait_for_active_shards',
_sourceExcludes: '_source_excludes',
_sourceIncludes: '_source_includes',
retryOnConflict: 'retry_on_conflict',
ifSeqNo: 'if_seq_no',
ifPrimaryTerm: 'if_primary_term',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function update (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['id'] == null) {
const err = new ConfigurationError('Missing required parameter: id')
return handleError(err, callback)
}
if (params['index'] == null) {
const err = new ConfigurationError('Missing required parameter: index')
return handleError(err, callback)
}
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, id, index, type, ...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 = ''
if ((index) != null && (type) != null && (id) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update'
} else {
path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id)
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildUpdate",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [update](http://www.elastic.co/guide/en/elast... | /* 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/update.js#L25-L144 | train | Build an update operation. | [
30522,
3853,
3857,
6279,
13701,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
30524,
1033,
1006,
8299,
1024,
1013,
1013,
7479,
1012,
21274,
1012,
2522,
1013,
5009,
1013,
4372,
1013,
21274,
17310,
1114... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
electron/electron | script/release-notes/notes.js | runRetryable | async function runRetryable (fn, maxRetries) {
let lastError
for (let i = 0; i < maxRetries; i++) {
try {
return await fn()
} catch (error) {
await new Promise((resolve, reject) => setTimeout(resolve, CHECK_INTERVAL))
lastError = error
}
}
// Silently eat 404s.
if (lastError.status !== 404) throw lastError
} | javascript | async function runRetryable (fn, maxRetries) {
let lastError
for (let i = 0; i < maxRetries; i++) {
try {
return await fn()
} catch (error) {
await new Promise((resolve, reject) => setTimeout(resolve, CHECK_INTERVAL))
lastError = error
}
}
// Silently eat 404s.
if (lastError.status !== 404) throw lastError
} | [
"async",
"function",
"runRetryable",
"(",
"fn",
",",
"maxRetries",
")",
"{",
"let",
"lastError",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"maxRetries",
";",
"i",
"++",
")",
"{",
"try",
"{",
"return",
"await",
"fn",
"(",
")",
"}",
"catch",
... | helper function to add some resiliency to volatile GH api endpoints | [
"helper",
"function",
"to",
"add",
"some",
"resiliency",
"to",
"volatile",
"GH",
"api",
"endpoints"
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/script/release-notes/notes.js#L305-L317 | train | Run a function in a retryable manner | [
30522,
2004,
6038,
2278,
3853,
2448,
13465,
20444,
3468,
1006,
1042,
2078,
1010,
4098,
13465,
5134,
1007,
1063,
2292,
2197,
2121,
29165,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
4098,
13465,
5134,
1025,
1045,
1009,
1009,
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... |
adobe/brackets | src/search/FindUtils.js | parseQueryInfo | function parseQueryInfo(queryInfo) {
var queryExpr;
if (!queryInfo || !queryInfo.query) {
return {empty: true};
}
// For now, treat all matches as multiline (i.e. ^/$ match on every line, not the whole
// document). This is consistent with how single-file find works. Eventually we should add
// an option for this.
var flags = "gm";
if (!queryInfo.isCaseSensitive) {
flags += "i";
}
// Is it a (non-blank) regex?
if (queryInfo.isRegexp) {
try {
queryExpr = new RegExp(queryInfo.query, flags);
} catch (e) {
return {valid: false, error: e.message};
}
} else {
// Query is a plain string. Turn it into a regexp
queryExpr = new RegExp(StringUtils.regexEscape(queryInfo.query), flags);
}
return {valid: true, queryExpr: queryExpr};
} | javascript | function parseQueryInfo(queryInfo) {
var queryExpr;
if (!queryInfo || !queryInfo.query) {
return {empty: true};
}
// For now, treat all matches as multiline (i.e. ^/$ match on every line, not the whole
// document). This is consistent with how single-file find works. Eventually we should add
// an option for this.
var flags = "gm";
if (!queryInfo.isCaseSensitive) {
flags += "i";
}
// Is it a (non-blank) regex?
if (queryInfo.isRegexp) {
try {
queryExpr = new RegExp(queryInfo.query, flags);
} catch (e) {
return {valid: false, error: e.message};
}
} else {
// Query is a plain string. Turn it into a regexp
queryExpr = new RegExp(StringUtils.regexEscape(queryInfo.query), flags);
}
return {valid: true, queryExpr: queryExpr};
} | [
"function",
"parseQueryInfo",
"(",
"queryInfo",
")",
"{",
"var",
"queryExpr",
";",
"if",
"(",
"!",
"queryInfo",
"||",
"!",
"queryInfo",
".",
"query",
")",
"{",
"return",
"{",
"empty",
":",
"true",
"}",
";",
"}",
"// For now, treat all matches as multiline (i.e... | Parses the given query into a regexp, and returns whether it was valid or not.
@param {{query: string, caseSensitive: boolean, isRegexp: boolean}} queryInfo
@return {{queryExpr: RegExp, valid: boolean, empty: boolean, error: string}}
queryExpr - the regexp representing the query
valid - set to true if query is a nonempty string or a valid regexp.
empty - set to true if query was empty.
error - set to an error string if valid is false and query is nonempty. | [
"Parses",
"the",
"given",
"query",
"into",
"a",
"regexp",
"and",
"returns",
"whether",
"it",
"was",
"valid",
"or",
"not",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FindUtils.js#L308-L335 | train | Parse a query string into a regexp or empty string | [
30522,
3853,
11968,
3366,
4226,
2854,
2378,
14876,
1006,
23032,
2378,
14876,
1007,
1063,
13075,
23032,
10288,
18098,
1025,
2065,
1006,
999,
23032,
2378,
14876,
1064,
1064,
999,
23032,
2378,
14876,
1012,
23032,
1007,
1063,
2709,
1063,
4064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | mark | function mark (instance) {
if (!instanceMap.has(instance.__VUE_DEVTOOLS_UID__)) {
instanceMap.set(instance.__VUE_DEVTOOLS_UID__, instance)
instance.$on('hook:beforeDestroy', function () {
instanceMap.delete(instance.__VUE_DEVTOOLS_UID__)
})
}
} | javascript | function mark (instance) {
if (!instanceMap.has(instance.__VUE_DEVTOOLS_UID__)) {
instanceMap.set(instance.__VUE_DEVTOOLS_UID__, instance)
instance.$on('hook:beforeDestroy', function () {
instanceMap.delete(instance.__VUE_DEVTOOLS_UID__)
})
}
} | [
"function",
"mark",
"(",
"instance",
")",
"{",
"if",
"(",
"!",
"instanceMap",
".",
"has",
"(",
"instance",
".",
"__VUE_DEVTOOLS_UID__",
")",
")",
"{",
"instanceMap",
".",
"set",
"(",
"instance",
".",
"__VUE_DEVTOOLS_UID__",
",",
"instance",
")",
"instance",
... | Mark an instance as captured and store it in the instance map.
@param {Vue} instance | [
"Mark",
"an",
"instance",
"as",
"captured",
"and",
"store",
"it",
"in",
"the",
"instance",
"map",
"."
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/src/backend/index.js#L479-L486 | train | Mark an instance as unused | [
30522,
3853,
2928,
1006,
6013,
1007,
1063,
2065,
1006,
999,
6013,
2863,
2361,
1012,
2038,
1006,
6013,
1012,
1035,
1035,
24728,
2063,
1035,
16475,
3406,
27896,
1035,
21318,
2094,
1035,
1035,
1007,
1007,
1063,
6013,
2863,
2361,
1012,
2275,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/obj-model.js | function () {
var material = this.el.components.material;
if (!material) { return; }
this.model.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material = material.material;
}
});
} | javascript | function () {
var material = this.el.components.material;
if (!material) { return; }
this.model.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.material = material.material;
}
});
} | [
"function",
"(",
")",
"{",
"var",
"material",
"=",
"this",
".",
"el",
".",
"components",
".",
"material",
";",
"if",
"(",
"!",
"material",
")",
"{",
"return",
";",
"}",
"this",
".",
"model",
".",
"traverse",
"(",
"function",
"(",
"child",
")",
"{",... | Apply material from material component recursively. | [
"Apply",
"material",
"from",
"material",
"component",
"recursively",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/obj-model.js#L92-L100 | train | set material to the component | [
30522,
3853,
1006,
1007,
1063,
13075,
3430,
1027,
2023,
1012,
3449,
1012,
6177,
1012,
3430,
1025,
2065,
1006,
999,
3430,
1007,
1063,
2709,
1025,
1065,
2023,
1012,
2944,
1012,
20811,
1006,
3853,
1006,
2775,
1007,
1063,
2065,
1006,
2775,
60... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/NotificationBarRenderer.js | function (oRm, sUri, bMessageNotifier) {
if (sUri == null || sUri == "") {
var icon = new Icon({
useIconTooltip: false
});
icon.addStyleClass("sapUiNotifierIcon");
if (bMessageNotifier) {
icon.setSrc("sap-icon://alert");
} else {
icon.setSrc("sap-icon://notification-2");
}
oRm.renderControl(icon);
return;
}
oRm.write("<img alt=\"\"");
oRm.addClass("sapUiNotifierIcon");
oRm.writeClasses();
oRm.writeAttributeEscaped("src", sUri);
oRm.write("/>");
} | javascript | function (oRm, sUri, bMessageNotifier) {
if (sUri == null || sUri == "") {
var icon = new Icon({
useIconTooltip: false
});
icon.addStyleClass("sapUiNotifierIcon");
if (bMessageNotifier) {
icon.setSrc("sap-icon://alert");
} else {
icon.setSrc("sap-icon://notification-2");
}
oRm.renderControl(icon);
return;
}
oRm.write("<img alt=\"\"");
oRm.addClass("sapUiNotifierIcon");
oRm.writeClasses();
oRm.writeAttributeEscaped("src", sUri);
oRm.write("/>");
} | [
"function",
"(",
"oRm",
",",
"sUri",
",",
"bMessageNotifier",
")",
"{",
"if",
"(",
"sUri",
"==",
"null",
"||",
"sUri",
"==",
"\"\"",
")",
"{",
"var",
"icon",
"=",
"new",
"Icon",
"(",
"{",
"useIconTooltip",
":",
"false",
"}",
")",
";",
"icon",
".",
... | Renders the notifier's icon. If there is no icon set a default icon is
used | [
"Renders",
"the",
"notifier",
"s",
"icon",
".",
"If",
"there",
"is",
"no",
"icon",
"set",
"a",
"default",
"icon",
"is",
"used"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/NotificationBarRenderer.js#L430-L452 | train | Renders the notification icon | [
30522,
3853,
1006,
2030,
2213,
1010,
7505,
2072,
1010,
1038,
7834,
3736,
6914,
4140,
18095,
1007,
1063,
2065,
1006,
7505,
2072,
1027,
1027,
19701,
1064,
1064,
7505,
2072,
1027,
1027,
1000,
1000,
1007,
1063,
13075,
12696,
1027,
2047,
12696,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | createMetadataProxy | function createMetadataProxy(oMetadata, oManifest) {
// create a proxy for the metadata object and simulate to be an
// instance of the original metadata object of the Component
// => retrieving the prototype from the original metadata to
// support to proxy sub-classes of ComponentMetadata
var oMetadataProxy = Object.create(Object.getPrototypeOf(oMetadata));
// provide internal access to the static metadata object
oMetadataProxy._oMetadata = oMetadata;
oMetadataProxy._oManifest = oManifest;
// copy all functions from the metadata object except of the
// manifest related functions which will be instance specific now
for (var m in oMetadata) {
if (!/^(getManifest|getManifestObject|getManifestEntry|getMetadataVersion)$/.test(m) && typeof oMetadata[m] === "function") {
oMetadataProxy[m] = oMetadata[m].bind(oMetadata);
}
}
// return the content of the manifest instead of the static metadata
oMetadataProxy.getManifest = function() {
return oManifest && oManifest.getJson();
};
oMetadataProxy.getManifestObject = function() {
return oManifest;
};
oMetadataProxy.getManifestEntry = function(sKey, bMerged) {
return getManifestEntry(oMetadata, oManifest, sKey, bMerged);
};
oMetadataProxy.getMetadataVersion = function() {
return 2; // instance specific manifest => metadata version 2!
};
return oMetadataProxy;
} | javascript | function createMetadataProxy(oMetadata, oManifest) {
// create a proxy for the metadata object and simulate to be an
// instance of the original metadata object of the Component
// => retrieving the prototype from the original metadata to
// support to proxy sub-classes of ComponentMetadata
var oMetadataProxy = Object.create(Object.getPrototypeOf(oMetadata));
// provide internal access to the static metadata object
oMetadataProxy._oMetadata = oMetadata;
oMetadataProxy._oManifest = oManifest;
// copy all functions from the metadata object except of the
// manifest related functions which will be instance specific now
for (var m in oMetadata) {
if (!/^(getManifest|getManifestObject|getManifestEntry|getMetadataVersion)$/.test(m) && typeof oMetadata[m] === "function") {
oMetadataProxy[m] = oMetadata[m].bind(oMetadata);
}
}
// return the content of the manifest instead of the static metadata
oMetadataProxy.getManifest = function() {
return oManifest && oManifest.getJson();
};
oMetadataProxy.getManifestObject = function() {
return oManifest;
};
oMetadataProxy.getManifestEntry = function(sKey, bMerged) {
return getManifestEntry(oMetadata, oManifest, sKey, bMerged);
};
oMetadataProxy.getMetadataVersion = function() {
return 2; // instance specific manifest => metadata version 2!
};
return oMetadataProxy;
} | [
"function",
"createMetadataProxy",
"(",
"oMetadata",
",",
"oManifest",
")",
"{",
"// create a proxy for the metadata object and simulate to be an",
"// instance of the original metadata object of the Component",
"// => retrieving the prototype from the original metadata to",
"// support to ... | Utility function which creates a metadata proxy object for the given
metadata object
@param {sap.ui.core.ComponentMetadata} oMetadata the Component metadata
@param {sap.ui.core.Manifest} oManifest the manifest
@return {sap.ui.core.ComponentMetadata} a metadata proxy object | [
"Utility",
"function",
"which",
"creates",
"a",
"metadata",
"proxy",
"object",
"for",
"the",
"given",
"metadata",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L134-L170 | train | Creates a proxy for the metadata object. | [
30522,
3853,
3443,
11368,
8447,
2696,
21572,
18037,
1006,
18168,
12928,
2850,
2696,
1010,
16640,
29323,
3367,
1007,
1063,
1013,
1013,
3443,
1037,
24540,
2005,
1996,
27425,
4874,
1998,
26633,
2000,
2022,
2019,
1013,
1013,
6013,
1997,
1996,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/LiveDevServerManager.js | removeServer | function removeServer(provider) {
var i;
for (i = 0; i < _serverProviders.length; i++) {
if (provider === _serverProviders[i]) {
_serverProviders.splice(i, 1);
}
}
} | javascript | function removeServer(provider) {
var i;
for (i = 0; i < _serverProviders.length; i++) {
if (provider === _serverProviders[i]) {
_serverProviders.splice(i, 1);
}
}
} | [
"function",
"removeServer",
"(",
"provider",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"_serverProviders",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"provider",
"===",
"_serverProviders",
"[",
"i",
"]",
")",
"{"... | Remove a server from the list of the registered providers.
@param {{object}} provider The provider to be removed. | [
"Remove",
"a",
"server",
"from",
"the",
"list",
"of",
"the",
"registered",
"providers",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevServerManager.js#L113-L120 | train | Remove a server from the list of server providers | [
30522,
3853,
20362,
2121,
6299,
1006,
10802,
1007,
1063,
13075,
1045,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
1035,
8241,
21572,
17258,
2545,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2065,
1006,
10802,
1027,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | setupShapeColor | function setupShapeColor() {
var bgOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bgOpacity;
r.eleFillStyle(context, node, bgOpy);
} | javascript | function setupShapeColor() {
var bgOpy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : bgOpacity;
r.eleFillStyle(context, node, bgOpy);
} | [
"function",
"setupShapeColor",
"(",
")",
"{",
"var",
"bgOpy",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"bgOpacity",
";",
"r",
".",
"eleFillStyle",
"(",
"conte... | so borders are square with the node shape | [
"so",
"borders",
"are",
"square",
"with",
"the",
"node",
"shape"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L28500-L28503 | train | Setup shape color | [
30522,
3853,
16437,
7377,
5051,
18717,
1006,
1007,
1063,
13075,
1038,
3995,
7685,
1027,
9918,
1012,
3091,
1028,
1014,
1004,
1004,
9918,
1031,
1014,
1033,
999,
1027,
1027,
6151,
28344,
1029,
9918,
1031,
1014,
1033,
1024,
1038,
3995,
19498,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObject.js | becameInvalid | function becameInvalid(oBindingInfo) {
var aParts = oBindingInfo.parts,
i;
if (aParts) {
if (aParts.length == 1) {
// simple property binding: invalid when the model has the same name (or updateall) and when the model instance differs
return (bUpdateAll || aParts[0].model == sModelName) && !oBindingInfo.binding.updateRequired(that.getModel(aParts[0].model));
} else {
// simple or composite binding: invalid when for any part the model has the same name (or updateall) and when the model instance for that part differs
for (i = 0; i < aParts.length; i++) {
if ( (bUpdateAll || aParts[i].model == sModelName) && !oBindingInfo.binding.aBindings[i].updateRequired(that.getModel(aParts[i].model)) ) {
return true;
}
}
}
} else {
// list or object binding: invalid when the model has the same name (or updateall) and when the model instance differs
return (bUpdateAll || oBindingInfo.model == sModelName) && !oBindingInfo.binding.updateRequired(that.getModel(oBindingInfo.model));
}
} | javascript | function becameInvalid(oBindingInfo) {
var aParts = oBindingInfo.parts,
i;
if (aParts) {
if (aParts.length == 1) {
// simple property binding: invalid when the model has the same name (or updateall) and when the model instance differs
return (bUpdateAll || aParts[0].model == sModelName) && !oBindingInfo.binding.updateRequired(that.getModel(aParts[0].model));
} else {
// simple or composite binding: invalid when for any part the model has the same name (or updateall) and when the model instance for that part differs
for (i = 0; i < aParts.length; i++) {
if ( (bUpdateAll || aParts[i].model == sModelName) && !oBindingInfo.binding.aBindings[i].updateRequired(that.getModel(aParts[i].model)) ) {
return true;
}
}
}
} else {
// list or object binding: invalid when the model has the same name (or updateall) and when the model instance differs
return (bUpdateAll || oBindingInfo.model == sModelName) && !oBindingInfo.binding.updateRequired(that.getModel(oBindingInfo.model));
}
} | [
"function",
"becameInvalid",
"(",
"oBindingInfo",
")",
"{",
"var",
"aParts",
"=",
"oBindingInfo",
".",
"parts",
",",
"i",
";",
"if",
"(",
"aParts",
")",
"{",
"if",
"(",
"aParts",
".",
"length",
"==",
"1",
")",
"{",
"// simple property binding: invalid when t... | /*
Checks whether the binding for the given oBindingInfo became invalid because
of the current model change (as identified by bUpdateAll and sModelName).
Precondition: oBindingInfo contains a 'binding' object
@param oBindingInfo
@returns {boolean} | [
"/",
"*",
"Checks",
"whether",
"the",
"binding",
"for",
"the",
"given",
"oBindingInfo",
"became",
"invalid",
"because",
"of",
"the",
"current",
"model",
"change",
"(",
"as",
"identified",
"by",
"bUpdateAll",
"and",
"sModelName",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObject.js#L4161-L4181 | train | Checks if the binding is invalid | [
30522,
3853,
2150,
2378,
10175,
3593,
1006,
27885,
22254,
2075,
2378,
14876,
1007,
1063,
13075,
4237,
2015,
1027,
27885,
22254,
2075,
2378,
14876,
1012,
3033,
1010,
1045,
1025,
2065,
1006,
4237,
2015,
1007,
1063,
2065,
1006,
4237,
2015,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js | function (vRawValue, oDetails) {
var sPath = typeof vRawValue === "string"
? "/" + oDetails.schemaChildName + "/" + vRawValue
: oDetails.context.getPath();
return oDetails.$$valueAsPromise
? oDetails.context.getModel().fetchValueListType(sPath).unwrap()
: oDetails.context.getModel().getValueListType(sPath);
} | javascript | function (vRawValue, oDetails) {
var sPath = typeof vRawValue === "string"
? "/" + oDetails.schemaChildName + "/" + vRawValue
: oDetails.context.getPath();
return oDetails.$$valueAsPromise
? oDetails.context.getModel().fetchValueListType(sPath).unwrap()
: oDetails.context.getModel().getValueListType(sPath);
} | [
"function",
"(",
"vRawValue",
",",
"oDetails",
")",
"{",
"var",
"sPath",
"=",
"typeof",
"vRawValue",
"===",
"\"string\"",
"?",
"\"/\"",
"+",
"oDetails",
".",
"schemaChildName",
"+",
"\"/\"",
"+",
"vRawValue",
":",
"oDetails",
".",
"context",
".",
"getPath",
... | Determines which type of value list exists for the given property.
@param {any} vRawValue
The raw value from the meta model; must be either a property or a path pointing to
a property (relative to <code>oDetails.schemaChildName</code>)
@param {object} oDetails
The details object
@param {boolean} [oDetails.$$valueAsPromise]
Whether a <code>Promise</code> may be returned if the needed metadata is not yet
loaded (since 1.57.0)
@param {sap.ui.model.Context} oDetails.context
Points to the given path, that is
<code>oDetails.context.getProperty("") === vRawValue</code>
@param {string} oDetails.schemaChildName
The qualified name of the schema child where the computed annotation has been
found, for example "name.space.EntityType"
@returns {sap.ui.model.odata.v4.ValueListType|Promise}
The type of the value list or a <code>Promise</code> resolving with the type of the
value list or rejected, if the property cannot be found in the metadata
@throws {Error}
If the property cannot be found in the metadata, or if
<code>$$valueAsPromise</code> is not set to <code>true</code> and the metadata is
not yet loaded
@public
@since 1.47.0 | [
"Determines",
"which",
"type",
"of",
"value",
"list",
"exists",
"for",
"the",
"given",
"property",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js#L331-L339 | train | Returns the value type of the given value. | [
30522,
3853,
1006,
27830,
10376,
10175,
5657,
1010,
24040,
22081,
1007,
1063,
13075,
14690,
2232,
1027,
2828,
11253,
27830,
10376,
10175,
5657,
1027,
1027,
1027,
1000,
5164,
1000,
1029,
1000,
1013,
1000,
1009,
24040,
22081,
1012,
8040,
28433,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/padding-line-between-statements.js | isBlockLikeStatement | function isBlockLikeStatement(sourceCode, node) {
// do-while with a block is a block-like statement.
if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
return true;
}
/*
* IIFE is a block-like statement specially from
* JSCS#disallowPaddingNewLinesAfterBlocks.
*/
if (isIIFEStatement(node)) {
return true;
}
// Checks the last token is a closing brace of blocks.
const lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
const belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken)
? sourceCode.getNodeByRangeIndex(lastToken.range[0])
: null;
return Boolean(belongingNode) && (
belongingNode.type === "BlockStatement" ||
belongingNode.type === "SwitchStatement"
);
} | javascript | function isBlockLikeStatement(sourceCode, node) {
// do-while with a block is a block-like statement.
if (node.type === "DoWhileStatement" && node.body.type === "BlockStatement") {
return true;
}
/*
* IIFE is a block-like statement specially from
* JSCS#disallowPaddingNewLinesAfterBlocks.
*/
if (isIIFEStatement(node)) {
return true;
}
// Checks the last token is a closing brace of blocks.
const lastToken = sourceCode.getLastToken(node, astUtils.isNotSemicolonToken);
const belongingNode = lastToken && astUtils.isClosingBraceToken(lastToken)
? sourceCode.getNodeByRangeIndex(lastToken.range[0])
: null;
return Boolean(belongingNode) && (
belongingNode.type === "BlockStatement" ||
belongingNode.type === "SwitchStatement"
);
} | [
"function",
"isBlockLikeStatement",
"(",
"sourceCode",
",",
"node",
")",
"{",
"// do-while with a block is a block-like statement.",
"if",
"(",
"node",
".",
"type",
"===",
"\"DoWhileStatement\"",
"&&",
"node",
".",
"body",
".",
"type",
"===",
"\"BlockStatement\"",
")"... | Checks whether the given node is a block-like statement.
This checks the last token of the node is the closing brace of a block.
@param {SourceCode} sourceCode The source code to get tokens.
@param {ASTNode} node The node to check.
@returns {boolean} `true` if the node is a block-like statement.
@private | [
"Checks",
"whether",
"the",
"given",
"node",
"is",
"a",
"block",
"-",
"like",
"statement",
".",
"This",
"checks",
"the",
"last",
"token",
"of",
"the",
"node",
"is",
"the",
"closing",
"brace",
"of",
"a",
"block",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/padding-line-between-statements.js#L112-L137 | train | Checks whether a given node is a block - like statement. | [
30522,
3853,
2003,
23467,
10359,
9153,
18532,
30524,
1000,
1004,
1004,
13045,
1012,
2303,
1012,
2828,
1027,
1027,
1027,
1000,
5991,
12259,
3672,
1000,
1007,
1063,
2709,
2995,
1025,
1065,
1013,
1008,
1008,
2462,
7959,
2003,
1037,
3796,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FileFilters.js | _doPopulate | function _doPopulate() {
var dropdownItems = [Strings.NEW_FILE_FILTER, Strings.CLEAR_FILE_FILTER],
filterSets = PreferencesManager.get("fileFilters") || [];
if (filterSets.length) {
dropdownItems.push("---");
// Remove all the empty exclusion sets before concatenating to the dropdownItems.
filterSets = filterSets.filter(function (filter) {
return (_getCondensedForm(filter.patterns) !== "");
});
// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)
// ie. the number of items populated so far before we concatenate with the actual filter sets.
dropdownItems = dropdownItems.concat(filterSets);
}
_picker.items = dropdownItems;
} | javascript | function _doPopulate() {
var dropdownItems = [Strings.NEW_FILE_FILTER, Strings.CLEAR_FILE_FILTER],
filterSets = PreferencesManager.get("fileFilters") || [];
if (filterSets.length) {
dropdownItems.push("---");
// Remove all the empty exclusion sets before concatenating to the dropdownItems.
filterSets = filterSets.filter(function (filter) {
return (_getCondensedForm(filter.patterns) !== "");
});
// FIRST_FILTER_INDEX needs to stay in sync with the number of static items (plus separator)
// ie. the number of items populated so far before we concatenate with the actual filter sets.
dropdownItems = dropdownItems.concat(filterSets);
}
_picker.items = dropdownItems;
} | [
"function",
"_doPopulate",
"(",
")",
"{",
"var",
"dropdownItems",
"=",
"[",
"Strings",
".",
"NEW_FILE_FILTER",
",",
"Strings",
".",
"CLEAR_FILE_FILTER",
"]",
",",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",... | Populate the list of dropdown menu with two filter commands and
the list of saved filter sets. | [
"Populate",
"the",
"list",
"of",
"dropdown",
"menu",
"with",
"two",
"filter",
"commands",
"and",
"the",
"list",
"of",
"saved",
"filter",
"sets",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L91-L108 | train | Populate the file filter dropdown | [
30522,
3853,
1035,
2079,
16340,
9869,
1006,
1007,
1063,
13075,
4530,
7698,
4221,
5244,
1027,
1031,
7817,
1012,
2047,
1035,
5371,
1035,
11307,
1010,
7817,
1012,
3154,
1035,
5371,
1035,
11307,
1033,
1010,
17736,
8454,
1027,
18394,
24805,
4590... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
markdown-it/markdown-it | lib/common/utils.js | assign | function assign(obj /*from1, from2, from3, ...*/) {
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function (source) {
if (!source) { return; }
if (typeof source !== 'object') {
throw new TypeError(source + 'must be object');
}
Object.keys(source).forEach(function (key) {
obj[key] = source[key];
});
});
return obj;
} | javascript | function assign(obj /*from1, from2, from3, ...*/) {
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function (source) {
if (!source) { return; }
if (typeof source !== 'object') {
throw new TypeError(source + 'must be object');
}
Object.keys(source).forEach(function (key) {
obj[key] = source[key];
});
});
return obj;
} | [
"function",
"assign",
"(",
"obj",
"/*from1, from2, from3, ...*/",
")",
"{",
"var",
"sources",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"sources",
".",
"forEach",
"(",
"function",
"(",
"source",
")",
... | Merge objects | [
"Merge",
"objects"
] | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/lib/common/utils.js#L18-L34 | train | Assign all the specified objects to obj. | [
30522,
3853,
23911,
1006,
27885,
3501,
1013,
1008,
2013,
2487,
1010,
2013,
30524,
18921,
6776,
1006,
3853,
1006,
3120,
1007,
1063,
2065,
1006,
999,
3120,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
2828,
11253,
3120,
999,
1027,
1027,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (oData, aPath) {
return aPath.reduce(function (oData, sSegment) {
return (oData && sSegment in oData) ? oData[sSegment] : undefined;
}, oData);
} | javascript | function (oData, aPath) {
return aPath.reduce(function (oData, sSegment) {
return (oData && sSegment in oData) ? oData[sSegment] : undefined;
}, oData);
} | [
"function",
"(",
"oData",
",",
"aPath",
")",
"{",
"return",
"aPath",
".",
"reduce",
"(",
"function",
"(",
"oData",
",",
"sSegment",
")",
"{",
"return",
"(",
"oData",
"&&",
"sSegment",
"in",
"oData",
")",
"?",
"oData",
"[",
"sSegment",
"]",
":",
"unde... | Drills down into the given object according to <code>aPath</code>.
@param {object} oData
The object to start at
@param {string[]} aPath
Relative path to drill-down into, as array of segments
@returns {*}
The result matching to <code>aPath</code> or <code>undefined</code> if the path leads
into void | [
"Drills",
"down",
"into",
"the",
"given",
"object",
"according",
"to",
"<code",
">",
"aPath<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L347-L351 | train | Returns the value of the key in the given path | [
30522,
3853,
1006,
1051,
2850,
2696,
1010,
9706,
8988,
1007,
1063,
2709,
9706,
8988,
1012,
5547,
1006,
3853,
1006,
1051,
2850,
2696,
1010,
7020,
13910,
3672,
1007,
1063,
2709,
1006,
1051,
2850,
2696,
1004,
1004,
7020,
13910,
3672,
1999,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
ColorlibHQ/AdminLTE | plugins/timepicker/bootstrap-timepicker.js | function (segment, step) {
if (segment % step === 0) {
return segment;
}
if (Math.round((segment % step) / step)) {
return (segment + (step - segment % step)) % 60;
} else {
return segment - segment % step;
}
} | javascript | function (segment, step) {
if (segment % step === 0) {
return segment;
}
if (Math.round((segment % step) / step)) {
return (segment + (step - segment % step)) % 60;
} else {
return segment - segment % step;
}
} | [
"function",
"(",
"segment",
",",
"step",
")",
"{",
"if",
"(",
"segment",
"%",
"step",
"===",
"0",
")",
"{",
"return",
"segment",
";",
"}",
"if",
"(",
"Math",
".",
"round",
"(",
"(",
"segment",
"%",
"step",
")",
"/",
"step",
")",
")",
"{",
"retu... | Given a segment value like 43, will round and snap the segment
to the nearest "step", like 45 if step is 15. Segment will
"overflow" to 0 if it's larger than 59 or would otherwise
round up to 60. | [
"Given",
"a",
"segment",
"value",
"like",
"43",
"will",
"round",
"and",
"snap",
"the",
"segment",
"to",
"the",
"nearest",
"step",
"like",
"45",
"if",
"step",
"is",
"15",
".",
"Segment",
"will",
"overflow",
"to",
"0",
"if",
"it",
"s",
"larger",
"than",
... | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/timepicker/bootstrap-timepicker.js#L647-L656 | train | Calculate the next segment | [
30522,
3853,
1006,
6903,
1010,
3357,
1007,
1063,
2065,
1006,
6903,
1003,
3357,
1027,
1027,
1027,
1014,
1007,
1063,
2709,
6903,
1025,
1065,
2065,
30524,
1006,
3357,
1011,
6903,
1003,
3357,
1007,
1007,
1003,
3438,
1025,
1065,
2842,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/search/SearchResultsView.js | SearchResultsView | function SearchResultsView(model, panelID, panelName, type) {
var panelHtml = Mustache.render(searchPanelTemplate, {panelID: panelID});
this._panel = WorkspaceManager.createBottomPanel(panelName, $(panelHtml), 100);
this._$summary = this._panel.$panel.find(".title");
this._$table = this._panel.$panel.find(".table-container");
this._model = model;
this._searchResultsType = type;
} | javascript | function SearchResultsView(model, panelID, panelName, type) {
var panelHtml = Mustache.render(searchPanelTemplate, {panelID: panelID});
this._panel = WorkspaceManager.createBottomPanel(panelName, $(panelHtml), 100);
this._$summary = this._panel.$panel.find(".title");
this._$table = this._panel.$panel.find(".table-container");
this._model = model;
this._searchResultsType = type;
} | [
"function",
"SearchResultsView",
"(",
"model",
",",
"panelID",
",",
"panelName",
",",
"type",
")",
"{",
"var",
"panelHtml",
"=",
"Mustache",
".",
"render",
"(",
"searchPanelTemplate",
",",
"{",
"panelID",
":",
"panelID",
"}",
")",
";",
"this",
".",
"_panel... | @constructor
Handles the search results panel.
Dispatches the following events:
replaceBatch - when the "Replace" button is clicked.
close - when the panel is closed.
@param {SearchModel} model The model that this view is showing.
@param {string} panelID The CSS ID to use for the panel.
@param {string} panelName The name to use for the panel, as passed to WorkspaceManager.createBottomPanel().
@param {string} type type to identify if it is reference search or string match serach | [
"@constructor",
"Handles",
"the",
"search",
"results",
"panel",
".",
"Dispatches",
"the",
"following",
"events",
":",
"replaceBatch",
"-",
"when",
"the",
"Replace",
"button",
"is",
"clicked",
".",
"close",
"-",
"when",
"the",
"panel",
"is",
"closed",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/SearchResultsView.js#L77-L85 | train | Search results view | [
30522,
3853,
3945,
6072,
11314,
2015,
8584,
1006,
2944,
1010,
5997,
3593,
1010,
5997,
18442,
1010,
2828,
1007,
1063,
13075,
5997,
11039,
19968,
1027,
28786,
1012,
17552,
1006,
3945,
9739,
20042,
6633,
15725,
1010,
1063,
5997,
3593,
1024,
59... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/adapters/storage/index.js | getStorage | function getStorage() {
const storageChoice = config.get('storage:active');
let storageConfig,
CustomStorage,
customStorage;
storageConfig = config.get('storage')[storageChoice];
// CASE: type does not exist
if (!storageChoice) {
throw new common.errors.IncorrectUsageError({
message: 'No adapter found'
});
}
// CASE: cached
if (storage[storageChoice]) {
return storage[storageChoice];
}
// CASE: load adapter from custom path (.../content/storage)
try {
CustomStorage = require(`${config.getContentPath('storage')}${storageChoice}`);
} catch (err) {
if (err.message.match(/strict mode/gi)) {
throw new common.errors.IncorrectUsageError({
message: 'Your custom storage adapter must use strict mode.',
help: 'Add \'use strict\'; on top of your adapter.',
err: err
});
// CASE: if module not found it can be an error within the adapter (cannot find bluebird for example)
} else if (err.code === 'MODULE_NOT_FOUND' && err.message.indexOf(`${config.getContentPath('storage')}${storageChoice}`) === -1) {
throw new common.errors.IncorrectUsageError({
message: 'We have detected an error in your custom storage adapter.',
err
});
// CASE: only throw error if module does exist
} else if (err.code !== 'MODULE_NOT_FOUND') {
throw new common.errors.IncorrectUsageError({
message: 'We have detected an unknown error in your custom storage adapter.',
err
});
}
}
// CASE: check in the default storage path
try {
CustomStorage = CustomStorage || require(`${config.get('paths').internalStoragePath}${storageChoice}`);
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new common.errors.IncorrectUsageError({
err,
context: `We cannot find your adapter in: ${config.getContentPath('storage')} or: ${config.get('paths').internalStoragePath}`
});
} else {
throw new common.errors.IncorrectUsageError({
message: 'We have detected an error in your custom storage adapter.',
err
});
}
}
customStorage = new CustomStorage(storageConfig);
// CASE: if multiple StorageBase modules are installed, instanceof could return false
if (Object.getPrototypeOf(CustomStorage).name !== StorageBase.name) {
throw new common.errors.IncorrectUsageError({
message: 'Your storage adapter does not inherit from the Storage Base.'
});
}
if (!customStorage.requiredFns) {
throw new common.errors.IncorrectUsageError({
message: 'Your storage adapter does not provide the minimum required functions.'
});
}
if (_.xor(customStorage.requiredFns, Object.keys(_.pick(Object.getPrototypeOf(customStorage), customStorage.requiredFns))).length) {
throw new common.errors.IncorrectUsageError({
message: 'Your storage adapter does not provide the minimum required functions.'
});
}
storage[storageChoice] = customStorage;
return storage[storageChoice];
} | javascript | function getStorage() {
const storageChoice = config.get('storage:active');
let storageConfig,
CustomStorage,
customStorage;
storageConfig = config.get('storage')[storageChoice];
// CASE: type does not exist
if (!storageChoice) {
throw new common.errors.IncorrectUsageError({
message: 'No adapter found'
});
}
// CASE: cached
if (storage[storageChoice]) {
return storage[storageChoice];
}
// CASE: load adapter from custom path (.../content/storage)
try {
CustomStorage = require(`${config.getContentPath('storage')}${storageChoice}`);
} catch (err) {
if (err.message.match(/strict mode/gi)) {
throw new common.errors.IncorrectUsageError({
message: 'Your custom storage adapter must use strict mode.',
help: 'Add \'use strict\'; on top of your adapter.',
err: err
});
// CASE: if module not found it can be an error within the adapter (cannot find bluebird for example)
} else if (err.code === 'MODULE_NOT_FOUND' && err.message.indexOf(`${config.getContentPath('storage')}${storageChoice}`) === -1) {
throw new common.errors.IncorrectUsageError({
message: 'We have detected an error in your custom storage adapter.',
err
});
// CASE: only throw error if module does exist
} else if (err.code !== 'MODULE_NOT_FOUND') {
throw new common.errors.IncorrectUsageError({
message: 'We have detected an unknown error in your custom storage adapter.',
err
});
}
}
// CASE: check in the default storage path
try {
CustomStorage = CustomStorage || require(`${config.get('paths').internalStoragePath}${storageChoice}`);
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
throw new common.errors.IncorrectUsageError({
err,
context: `We cannot find your adapter in: ${config.getContentPath('storage')} or: ${config.get('paths').internalStoragePath}`
});
} else {
throw new common.errors.IncorrectUsageError({
message: 'We have detected an error in your custom storage adapter.',
err
});
}
}
customStorage = new CustomStorage(storageConfig);
// CASE: if multiple StorageBase modules are installed, instanceof could return false
if (Object.getPrototypeOf(CustomStorage).name !== StorageBase.name) {
throw new common.errors.IncorrectUsageError({
message: 'Your storage adapter does not inherit from the Storage Base.'
});
}
if (!customStorage.requiredFns) {
throw new common.errors.IncorrectUsageError({
message: 'Your storage adapter does not provide the minimum required functions.'
});
}
if (_.xor(customStorage.requiredFns, Object.keys(_.pick(Object.getPrototypeOf(customStorage), customStorage.requiredFns))).length) {
throw new common.errors.IncorrectUsageError({
message: 'Your storage adapter does not provide the minimum required functions.'
});
}
storage[storageChoice] = customStorage;
return storage[storageChoice];
} | [
"function",
"getStorage",
"(",
")",
"{",
"const",
"storageChoice",
"=",
"config",
".",
"get",
"(",
"'storage:active'",
")",
";",
"let",
"storageConfig",
",",
"CustomStorage",
",",
"customStorage",
";",
"storageConfig",
"=",
"config",
".",
"get",
"(",
"'storage... | type: images | [
"type",
":",
"images"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/adapters/storage/index.js#L10-L95 | train | Get the storage adapter | [
30522,
3853,
4152,
4263,
4270,
1006,
1007,
1063,
9530,
3367,
5527,
9905,
6610,
1027,
30524,
1031,
5527,
9905,
6610,
1033,
1025,
1013,
1013,
2553,
1024,
2828,
2515,
2025,
4839,
2065,
1006,
999,
5527,
9905,
6610,
1007,
1063,
5466,
2047,
269... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Agents/RemoteAgent.js | load | function load() {
_load = new $.Deferred();
Inspector.Page.on("frameNavigated.RemoteAgent", _onFrameNavigated);
Inspector.Page.on("frameStartedLoading.RemoteAgent", _stopKeepAliveInterval);
Inspector.DOM.on("attributeModified.RemoteAgent", _onAttributeModified);
return _load.promise();
} | javascript | function load() {
_load = new $.Deferred();
Inspector.Page.on("frameNavigated.RemoteAgent", _onFrameNavigated);
Inspector.Page.on("frameStartedLoading.RemoteAgent", _stopKeepAliveInterval);
Inspector.DOM.on("attributeModified.RemoteAgent", _onAttributeModified);
return _load.promise();
} | [
"function",
"load",
"(",
")",
"{",
"_load",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"Inspector",
".",
"Page",
".",
"on",
"(",
"\"frameNavigated.RemoteAgent\"",
",",
"_onFrameNavigated",
")",
";",
"Inspector",
".",
"Page",
".",
"on",
"(",
"\"fram... | Initialize the agent | [
"Initialize",
"the",
"agent"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/RemoteAgent.js#L149-L156 | train | Load the language code | [
30522,
3853,
7170,
1006,
1007,
1063,
1035,
7170,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
7742,
1012,
3931,
1012,
2006,
1006,
1000,
4853,
2532,
5737,
11644,
1012,
6556,
4270,
3372,
1000,
1010,
1035,
2006,
15643,
2532,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | examples/radio/radio.js | function(stations) {
var self = this;
self.stations = stations;
self.index = 0;
// Setup the display for each station.
for (var i=0; i<self.stations.length; i++) {
window['title' + i].innerHTML = '<b>' + self.stations[i].freq + '</b> ' + self.stations[i].title;
window['station' + i].addEventListener('click', function(index) {
var isNotPlaying = (self.stations[index].howl && !self.stations[index].howl.playing());
// Stop other sounds or the current one.
radio.stop();
// If the station isn't already playing or it doesn't exist, play it.
if (isNotPlaying || !self.stations[index].howl) {
radio.play(index);
}
}.bind(self, i));
}
} | javascript | function(stations) {
var self = this;
self.stations = stations;
self.index = 0;
// Setup the display for each station.
for (var i=0; i<self.stations.length; i++) {
window['title' + i].innerHTML = '<b>' + self.stations[i].freq + '</b> ' + self.stations[i].title;
window['station' + i].addEventListener('click', function(index) {
var isNotPlaying = (self.stations[index].howl && !self.stations[index].howl.playing());
// Stop other sounds or the current one.
radio.stop();
// If the station isn't already playing or it doesn't exist, play it.
if (isNotPlaying || !self.stations[index].howl) {
radio.play(index);
}
}.bind(self, i));
}
} | [
"function",
"(",
"stations",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"stations",
"=",
"stations",
";",
"self",
".",
"index",
"=",
"0",
";",
"// Setup the display for each station.",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"self... | Radio class containing the state of our stations.
Includes all methods for playing, stopping, etc.
@param {Array} stations Array of objects with station details ({title, src, howl, ...}). | [
"Radio",
"class",
"containing",
"the",
"state",
"of",
"our",
"stations",
".",
"Includes",
"all",
"methods",
"for",
"playing",
"stopping",
"etc",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/radio/radio.js#L22-L43 | train | This function is called by the station class to display the station s sounds. | [
30522,
3853,
1006,
3703,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2969,
1012,
3703,
1027,
3703,
1025,
2969,
1012,
5950,
1027,
1014,
1025,
1013,
1013,
16437,
1996,
4653,
2005,
2169,
2276,
1012,
2005,
1006,
13075,
1045,
1027,
1014,
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/project/FileTreeView.js | function (event) {
if (this.props.entry.get("rename")) {
event.stopPropagation();
return;
}
if (event.button !== LEFT_MOUSE_BUTTON) {
return;
}
var isOpen = this.props.entry.get("open"),
setOpen = isOpen ? false : true;
if (event.metaKey || event.ctrlKey) {
// ctrl-alt-click toggles this directory and its children
if (event.altKey) {
if (setOpen) {
// when opening, we only open the immediate children because
// opening a whole subtree could be really slow (consider
// a `node_modules` directory, for example).
this.props.actions.toggleSubdirectories(this.myPath(), setOpen);
this.props.actions.setDirectoryOpen(this.myPath(), setOpen);
} else {
// When closing, we recursively close the whole subtree.
this.props.actions.closeSubtree(this.myPath());
}
} else {
// ctrl-click toggles the sibling directories
this.props.actions.toggleSubdirectories(this.props.parentPath, setOpen);
}
} else {
// directory toggle with no modifier
this.props.actions.setDirectoryOpen(this.myPath(), setOpen);
}
event.stopPropagation();
event.preventDefault();
} | javascript | function (event) {
if (this.props.entry.get("rename")) {
event.stopPropagation();
return;
}
if (event.button !== LEFT_MOUSE_BUTTON) {
return;
}
var isOpen = this.props.entry.get("open"),
setOpen = isOpen ? false : true;
if (event.metaKey || event.ctrlKey) {
// ctrl-alt-click toggles this directory and its children
if (event.altKey) {
if (setOpen) {
// when opening, we only open the immediate children because
// opening a whole subtree could be really slow (consider
// a `node_modules` directory, for example).
this.props.actions.toggleSubdirectories(this.myPath(), setOpen);
this.props.actions.setDirectoryOpen(this.myPath(), setOpen);
} else {
// When closing, we recursively close the whole subtree.
this.props.actions.closeSubtree(this.myPath());
}
} else {
// ctrl-click toggles the sibling directories
this.props.actions.toggleSubdirectories(this.props.parentPath, setOpen);
}
} else {
// directory toggle with no modifier
this.props.actions.setDirectoryOpen(this.myPath(), setOpen);
}
event.stopPropagation();
event.preventDefault();
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"this",
".",
"props",
".",
"entry",
".",
"get",
"(",
"\"rename\"",
")",
")",
"{",
"event",
".",
"stopPropagation",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"event",
".",
"button",
"!==",
"LEFT_MOU... | If you click on a directory, it will toggle between open and closed. | [
"If",
"you",
"click",
"on",
"a",
"directory",
"it",
"will",
"toggle",
"between",
"open",
"and",
"closed",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L785-L821 | train | on keydown | [
30522,
3853,
1006,
2724,
1007,
1063,
2065,
1006,
2023,
1012,
24387,
1012,
4443,
1012,
2131,
1006,
1000,
14916,
14074,
1000,
1007,
1007,
1063,
2724,
1012,
2644,
21572,
4502,
12540,
1006,
1007,
1025,
2709,
1025,
1065,
2065,
1006,
2724,
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... | |
Freeboard/freeboard | examples/plugin_example.js | function(settings)
{
var self = this;
var currentSettings = settings;
// Here we create an element to hold the text we're going to display. We're going to set the value displayed in it below.
var myTextElement = $("<span></span>");
// **render(containerElement)** (required) : A public function we must implement that will be called when freeboard wants us to render the contents of our widget. The container element is the DIV that will surround the widget.
self.render = function(containerElement)
{
// Here we append our text element to the widget container element.
$(containerElement).append(myTextElement);
}
// **getHeight()** (required) : A public function we must implement that will be called when freeboard wants to know how big we expect to be when we render, and returns a height. This function will be called any time a user updates their settings (including the first time they create the widget).
//
// Note here that the height is not in pixels, but in blocks. A block in freeboard is currently defined as a rectangle that is fixed at 300 pixels wide and around 45 pixels multiplied by the value you return here.
//
// Blocks of different sizes may be supported in the future.
self.getHeight = function()
{
if(currentSettings.size == "big")
{
return 2;
}
else
{
return 1;
}
}
// **onSettingsChanged(newSettings)** (required) : A public function we must implement that will be called when a user makes a change to the settings.
self.onSettingsChanged = function(newSettings)
{
// Normally we'd update our text element with the value we defined in the user settings above (the_text), but there is a special case for settings that are of type **"calculated"** -- see below.
currentSettings = newSettings;
}
// **onCalculatedValueChanged(settingName, newValue)** (required) : A public function we must implement that will be called when a calculated value changes. Since calculated values can change at any time (like when a datasource is updated) we handle them in a special callback function here.
self.onCalculatedValueChanged = function(settingName, newValue)
{
// Remember we defined "the_text" up above in our settings.
if(settingName == "the_text")
{
// Here we do the actual update of the value that's displayed in on the screen.
$(myTextElement).html(newValue);
}
}
// **onDispose()** (required) : Same as with datasource plugins.
self.onDispose = function()
{
}
} | javascript | function(settings)
{
var self = this;
var currentSettings = settings;
// Here we create an element to hold the text we're going to display. We're going to set the value displayed in it below.
var myTextElement = $("<span></span>");
// **render(containerElement)** (required) : A public function we must implement that will be called when freeboard wants us to render the contents of our widget. The container element is the DIV that will surround the widget.
self.render = function(containerElement)
{
// Here we append our text element to the widget container element.
$(containerElement).append(myTextElement);
}
// **getHeight()** (required) : A public function we must implement that will be called when freeboard wants to know how big we expect to be when we render, and returns a height. This function will be called any time a user updates their settings (including the first time they create the widget).
//
// Note here that the height is not in pixels, but in blocks. A block in freeboard is currently defined as a rectangle that is fixed at 300 pixels wide and around 45 pixels multiplied by the value you return here.
//
// Blocks of different sizes may be supported in the future.
self.getHeight = function()
{
if(currentSettings.size == "big")
{
return 2;
}
else
{
return 1;
}
}
// **onSettingsChanged(newSettings)** (required) : A public function we must implement that will be called when a user makes a change to the settings.
self.onSettingsChanged = function(newSettings)
{
// Normally we'd update our text element with the value we defined in the user settings above (the_text), but there is a special case for settings that are of type **"calculated"** -- see below.
currentSettings = newSettings;
}
// **onCalculatedValueChanged(settingName, newValue)** (required) : A public function we must implement that will be called when a calculated value changes. Since calculated values can change at any time (like when a datasource is updated) we handle them in a special callback function here.
self.onCalculatedValueChanged = function(settingName, newValue)
{
// Remember we defined "the_text" up above in our settings.
if(settingName == "the_text")
{
// Here we do the actual update of the value that's displayed in on the screen.
$(myTextElement).html(newValue);
}
}
// **onDispose()** (required) : Same as with datasource plugins.
self.onDispose = function()
{
}
} | [
"function",
"(",
"settings",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"currentSettings",
"=",
"settings",
";",
"// Here we create an element to hold the text we're going to display. We're going to set the value displayed in it below.",
"var",
"myTextElement",
"=",
"$",... | ### Widget Implementation ------------------- Here we implement the actual widget plugin. We pass in the settings; | [
"###",
"Widget",
"Implementation",
"-------------------",
"Here",
"we",
"implement",
"the",
"actual",
"widget",
"plugin",
".",
"We",
"pass",
"in",
"the",
"settings",
";"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/examples/plugin_example.js#L243-L297 | train | This is the main function that will be called when the user sets the value of the widget. | [
30522,
3853,
1006,
10906,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
14731,
18319,
3070,
2015,
1027,
10906,
1025,
1013,
1013,
2182,
2057,
3443,
2019,
5783,
2000,
2907,
1996,
3793,
2057,
1005,
2128,
2183,
2000,
4653,
1012,
2057,
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... | |
angular/material | src/components/tabs/js/tabsController.js | handleSelectedIndexChange | function handleSelectedIndexChange (newValue, oldValue) {
if (newValue === oldValue) return;
ctrl.selectedIndex = getNearestSafeIndex(newValue);
ctrl.lastSelectedIndex = oldValue;
ctrl.updateInkBarStyles();
updateHeightFromContent();
adjustOffset(newValue);
$scope.$broadcast('$mdTabsChanged');
ctrl.tabs[ oldValue ] && ctrl.tabs[ oldValue ].scope.deselect();
ctrl.tabs[ newValue ] && ctrl.tabs[ newValue ].scope.select();
} | javascript | function handleSelectedIndexChange (newValue, oldValue) {
if (newValue === oldValue) return;
ctrl.selectedIndex = getNearestSafeIndex(newValue);
ctrl.lastSelectedIndex = oldValue;
ctrl.updateInkBarStyles();
updateHeightFromContent();
adjustOffset(newValue);
$scope.$broadcast('$mdTabsChanged');
ctrl.tabs[ oldValue ] && ctrl.tabs[ oldValue ].scope.deselect();
ctrl.tabs[ newValue ] && ctrl.tabs[ newValue ].scope.select();
} | [
"function",
"handleSelectedIndexChange",
"(",
"newValue",
",",
"oldValue",
")",
"{",
"if",
"(",
"newValue",
"===",
"oldValue",
")",
"return",
";",
"ctrl",
".",
"selectedIndex",
"=",
"getNearestSafeIndex",
"(",
"newValue",
")",
";",
"ctrl",
".",
"lastSelectedInde... | Update the UI whenever the selected index changes. Calls user-defined select/deselect methods.
@param {number} newValue selected index's new value
@param {number} oldValue selected index's previous value | [
"Update",
"the",
"UI",
"whenever",
"the",
"selected",
"index",
"changes",
".",
"Calls",
"user",
"-",
"defined",
"select",
"/",
"deselect",
"methods",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L260-L271 | train | Handle the selection of a tab. | [
30522,
3853,
16024,
12260,
10985,
22254,
10288,
22305,
2063,
1006,
2047,
10175,
5657,
1010,
2214,
10175,
5657,
1007,
1063,
2065,
1006,
2047,
10175,
5657,
1027,
1027,
1027,
2214,
10175,
5657,
1007,
2709,
1025,
14931,
12190,
1012,
3479,
22254,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js | function(oTable, oEvent) {
var $Body = jQuery(document.body),
$Splitter = oTable.$("sb"),
$Document = jQuery(document),
offset = $Splitter.offset(),
height = $Splitter.height(),
width = $Splitter.width(),
bTouch = oTable._isTouchEvent(oEvent);
// Fix for IE text selection while dragging
$Body.bind("selectstart", InteractiveResizeHelper.onSelectStartWhileInteractiveResizing);
$Body.append(
"<div id=\"" + oTable.getId() + "-ghost\" class=\"sapUiTableInteractiveResizerGhost\" style =\" height:" + height + "px; width:"
+ width + "px; left:" + offset.left + "px; top:" + offset.top + "px\" ></div>");
// Append overlay over splitter to enable correct functionality of moving the splitter
$Splitter.append(
"<div id=\"" + oTable.getId() + "-rzoverlay\" style =\"left: 0px; right: 0px; bottom: 0px; top: 0px; position:absolute\" ></div>");
$Document.bind((bTouch ? "touchend" : "mouseup") + ".sapUiTableInteractiveResize",
InteractiveResizeHelper.exitInteractiveResizing.bind(oTable));
$Document.bind((bTouch ? "touchmove" : "mousemove") + ".sapUiTableInteractiveResize",
InteractiveResizeHelper.onMouseMoveWhileInteractiveResizing.bind(oTable)
);
oTable._disableTextSelection();
} | javascript | function(oTable, oEvent) {
var $Body = jQuery(document.body),
$Splitter = oTable.$("sb"),
$Document = jQuery(document),
offset = $Splitter.offset(),
height = $Splitter.height(),
width = $Splitter.width(),
bTouch = oTable._isTouchEvent(oEvent);
// Fix for IE text selection while dragging
$Body.bind("selectstart", InteractiveResizeHelper.onSelectStartWhileInteractiveResizing);
$Body.append(
"<div id=\"" + oTable.getId() + "-ghost\" class=\"sapUiTableInteractiveResizerGhost\" style =\" height:" + height + "px; width:"
+ width + "px; left:" + offset.left + "px; top:" + offset.top + "px\" ></div>");
// Append overlay over splitter to enable correct functionality of moving the splitter
$Splitter.append(
"<div id=\"" + oTable.getId() + "-rzoverlay\" style =\"left: 0px; right: 0px; bottom: 0px; top: 0px; position:absolute\" ></div>");
$Document.bind((bTouch ? "touchend" : "mouseup") + ".sapUiTableInteractiveResize",
InteractiveResizeHelper.exitInteractiveResizing.bind(oTable));
$Document.bind((bTouch ? "touchmove" : "mousemove") + ".sapUiTableInteractiveResize",
InteractiveResizeHelper.onMouseMoveWhileInteractiveResizing.bind(oTable)
);
oTable._disableTextSelection();
} | [
"function",
"(",
"oTable",
",",
"oEvent",
")",
"{",
"var",
"$Body",
"=",
"jQuery",
"(",
"document",
".",
"body",
")",
",",
"$Splitter",
"=",
"oTable",
".",
"$",
"(",
"\"sb\"",
")",
",",
"$Document",
"=",
"jQuery",
"(",
"document",
")",
",",
"offset",... | /*
Initializes the drag&drop for resizing | [
"/",
"*",
"Initializes",
"the",
"drag&drop",
"for",
"resizing"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TablePointerExtension.js#L367-L394 | train | Handles mouseup and touchend events on the table | [
30522,
3853,
1006,
27178,
3085,
1010,
1051,
18697,
3372,
1007,
1063,
13075,
1002,
2303,
1027,
1046,
4226,
2854,
1006,
6254,
1012,
2303,
1007,
1010,
1002,
3975,
3334,
1027,
27178,
3085,
1012,
1002,
1006,
1000,
30524,
1027,
27178,
3085,
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... | |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(method, restoreScrollPosition) {
var win = this.doc.defaultView || this.doc.parentWindow,
sel = rangy.saveSelection(win);
if (!sel) {
method();
} else {
try {
method();
} catch(e) {
setTimeout(function() { throw e; }, 0);
}
}
rangy.restoreSelection(sel);
} | javascript | function(method, restoreScrollPosition) {
var win = this.doc.defaultView || this.doc.parentWindow,
sel = rangy.saveSelection(win);
if (!sel) {
method();
} else {
try {
method();
} catch(e) {
setTimeout(function() { throw e; }, 0);
}
}
rangy.restoreSelection(sel);
} | [
"function",
"(",
"method",
",",
"restoreScrollPosition",
")",
"{",
"var",
"win",
"=",
"this",
".",
"doc",
".",
"defaultView",
"||",
"this",
".",
"doc",
".",
"parentWindow",
",",
"sel",
"=",
"rangy",
".",
"saveSelection",
"(",
"win",
")",
";",
"if",
"("... | TODO: Figure out a method from following 2 that would work universally | [
"TODO",
":",
"Figure",
"out",
"a",
"method",
"from",
"following",
"2",
"that",
"would",
"work",
"universally"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L9051-L9065 | train | This method is a helper function that will call the method with the current selection and the scroll position of the document. | [
30522,
3853,
1006,
4118,
1010,
9239,
11020,
28402,
26994,
1007,
1063,
13075,
2663,
1027,
2023,
1012,
9986,
1012,
12398,
8584,
1064,
1064,
2023,
1012,
9986,
1012,
6687,
11101,
5004,
1010,
7367,
2140,
1027,
8369,
2100,
1012,
13169,
12260,
754... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/util/traverser.js | getVisitorKeys | function getVisitorKeys(visitorKeys, node) {
let keys = visitorKeys[node.type];
if (!keys) {
keys = vk.getKeys(node);
debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
}
return keys;
} | javascript | function getVisitorKeys(visitorKeys, node) {
let keys = visitorKeys[node.type];
if (!keys) {
keys = vk.getKeys(node);
debug("Unknown node type \"%s\": Estimated visitor keys %j", node.type, keys);
}
return keys;
} | [
"function",
"getVisitorKeys",
"(",
"visitorKeys",
",",
"node",
")",
"{",
"let",
"keys",
"=",
"visitorKeys",
"[",
"node",
".",
"type",
"]",
";",
"if",
"(",
"!",
"keys",
")",
"{",
"keys",
"=",
"vk",
".",
"getKeys",
"(",
"node",
")",
";",
"debug",
"("... | Get the visitor keys of a given node.
@param {Object} visitorKeys The map of visitor keys.
@param {ASTNode} node The node to get their visitor keys.
@returns {string[]} The visitor keys of the node. | [
"Get",
"the",
"visitor",
"keys",
"of",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/traverser.js#L43-L52 | train | Get the visitor keys for a node | [
30522,
3853,
2131,
11365,
15660,
14839,
2015,
1006,
10367,
14839,
2015,
1010,
13045,
1007,
1063,
2292,
6309,
1027,
10367,
14839,
2015,
1031,
13045,
1012,
2828,
1033,
1025,
2065,
1006,
999,
6309,
1007,
1063,
6309,
1027,
1058,
2243,
1012,
213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/StaticServer/node/StaticServerDomain.js | _cmdWriteFilteredResponse | function _cmdWriteFilteredResponse(root, path, resData) {
var pathKey = getPathKey(root),
callback = _requests[pathKey][resData.id];
if (callback) {
callback(resData);
} else {
console.warn("writeFilteredResponse: Missing callback for %s. This command must only be called after a requestFilter event has fired for a path.", pathJoin(root, path));
}
} | javascript | function _cmdWriteFilteredResponse(root, path, resData) {
var pathKey = getPathKey(root),
callback = _requests[pathKey][resData.id];
if (callback) {
callback(resData);
} else {
console.warn("writeFilteredResponse: Missing callback for %s. This command must only be called after a requestFilter event has fired for a path.", pathJoin(root, path));
}
} | [
"function",
"_cmdWriteFilteredResponse",
"(",
"root",
",",
"path",
",",
"resData",
")",
"{",
"var",
"pathKey",
"=",
"getPathKey",
"(",
"root",
")",
",",
"callback",
"=",
"_requests",
"[",
"pathKey",
"]",
"[",
"resData",
".",
"id",
"]",
";",
"if",
"(",
... | @private
Overrides the server response from static middleware with the provided
response data. This should be called only in response to a filtered request.
@param {string} path The absolute path of the server
@param {string} root The relative path of the file beginning with a forward slash "/"
@param {!Object} resData Response data to use | [
"@private",
"Overrides",
"the",
"server",
"response",
"from",
"static",
"middleware",
"with",
"the",
"provided",
"response",
"data",
".",
"This",
"should",
"be",
"called",
"only",
"in",
"response",
"to",
"a",
"filtered",
"request",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/StaticServer/node/StaticServerDomain.js#L334-L343 | train | Called when a requestFilter event is fired for a path. | [
30522,
3853,
1035,
4642,
2094,
26373,
8873,
21928,
2098,
6072,
26029,
3366,
1006,
7117,
1010,
4130,
1010,
24501,
2850,
2696,
1007,
1063,
13075,
4130,
14839,
1027,
2131,
15069,
14839,
1006,
7117,
1007,
1010,
2655,
5963,
1027,
1035,
11186,
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/systems/geometry.js | createGeometry | function createGeometry (data) {
var geometryType = data.primitive;
var GeometryClass = geometries[geometryType] && geometries[geometryType].Geometry;
var geometryInstance = new GeometryClass();
if (!GeometryClass) { throw new Error('Unknown geometry `' + geometryType + '`'); }
geometryInstance.init(data);
return toBufferGeometry(geometryInstance.geometry, data.buffer);
} | javascript | function createGeometry (data) {
var geometryType = data.primitive;
var GeometryClass = geometries[geometryType] && geometries[geometryType].Geometry;
var geometryInstance = new GeometryClass();
if (!GeometryClass) { throw new Error('Unknown geometry `' + geometryType + '`'); }
geometryInstance.init(data);
return toBufferGeometry(geometryInstance.geometry, data.buffer);
} | [
"function",
"createGeometry",
"(",
"data",
")",
"{",
"var",
"geometryType",
"=",
"data",
".",
"primitive",
";",
"var",
"GeometryClass",
"=",
"geometries",
"[",
"geometryType",
"]",
"&&",
"geometries",
"[",
"geometryType",
"]",
".",
"Geometry",
";",
"var",
"g... | Create geometry using component data.
@param {object} data - Component data.
@returns {object} Geometry. | [
"Create",
"geometry",
"using",
"component",
"data",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/geometry.js#L98-L107 | train | Create geometry from data | [
30522,
3853,
3443,
3351,
8462,
11129,
1006,
2951,
1007,
1063,
13075,
10988,
13874,
1027,
2951,
1012,
10968,
1025,
13075,
10988,
26266,
1027,
20248,
11368,
5134,
1031,
10988,
13874,
1033,
1004,
1004,
20248,
11368,
5134,
1031,
10988,
13874,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_AggregationHelper.js | function (mAggregate) {
return !!mAggregate && Object.keys(mAggregate).some(function (sAlias) {
var oDetails = mAggregate[sAlias];
return oDetails.min || oDetails.max;
});
} | javascript | function (mAggregate) {
return !!mAggregate && Object.keys(mAggregate).some(function (sAlias) {
var oDetails = mAggregate[sAlias];
return oDetails.min || oDetails.max;
});
} | [
"function",
"(",
"mAggregate",
")",
"{",
"return",
"!",
"!",
"mAggregate",
"&&",
"Object",
".",
"keys",
"(",
"mAggregate",
")",
".",
"some",
"(",
"function",
"(",
"sAlias",
")",
"{",
"var",
"oDetails",
"=",
"mAggregate",
"[",
"sAlias",
"]",
";",
"retur... | Tells whether minimum or maximum values are needed for at least one aggregatable
property.
@param {object} [mAggregate]
A map from aggregatable property names or aliases to details objects
@returns {boolean}
Whether minimum or maximum values are needed for at least one aggregatable
property.
@public | [
"Tells",
"whether",
"minimum",
"or",
"maximum",
"values",
"are",
"needed",
"for",
"at",
"least",
"one",
"aggregatable",
"property",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_AggregationHelper.js#L369-L375 | train | Returns true if the aggregate has a min or max property | [
30522,
3853,
1006,
23848,
17603,
5867,
1007,
1063,
2709,
999,
999,
23848,
17603,
5867,
1004,
1004,
4874,
1012,
6309,
1006,
23848,
17603,
5867,
1007,
1012,
2070,
1006,
3853,
1006,
16183,
7951,
1007,
1063,
13075,
24040,
22081,
1027,
23848,
17... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js | function(filename, options) {
_private.oLog.info(sModuleName + " - Record");
if (window.XMLHttpRequest.name === 'FakeXMLHttpRequest') {
_private.oLog.warning(sModuleName + " - Sinon FakeXMLHttpRequest is enabled by another application, recording could be defective");
}
if (_private.isRecordStarted()) {
_private.oLog.error(sModuleName + " - RequestRecorder is already recording, please stop first...");
return;
}
_private.init(options);
_private.sFilename = filename;
_private.bIsRecording = true;
// Overwrite the open method to get the required request parameters (method, URL, headers) and assign
// a group name if provided.
_private.mXhrNativeFunctions.open = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function() {
this._requestParams = this._requestParams || {};
this._requestParams.method = arguments[0];
this._requestParams.url = arguments[1];
this._requestParams.customGroupName = _private.fnCustomGroupNameCallback();
this._requestParams.headers = this._requestParams.headers || [];
_private.mXhrNativeFunctions.open.apply(this, arguments);
};
// Overwrite the setRequestHeader method to record the request headers.
_private.mXhrNativeFunctions.setRequestHeader = window.XMLHttpRequest.prototype.setRequestHeader;
window.XMLHttpRequest.prototype.setRequestHeader = function(sHeaderName, sHeaderValue) {
this._requestParams = this._requestParams || { headers: [] };
this._requestParams.headers.push({
name: sHeaderName,
value: sHeaderValue
});
_private.mXhrNativeFunctions.setRequestHeader.apply(this, arguments);
};
// Overwrite the send method to get the response and the collected data from the XMLHttpRequest
_private.mXhrNativeFunctions.send = window.XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send = function() {
if (!_private.isUrlFiltered(this._requestParams.url, _private.aEntriesUrlFilter)) {
var fTimestamp = _private.preciseDateNow();
// If the onreadystatechange is already specified by another application, it is called, too.
var fnOldStateChanged = this.onreadystatechange;
this.onreadystatechange = function() {
if (this.readyState === 4) {
_private.aRequests.push(_private.prepareRequestForHar(this, fTimestamp));
_private.oLog.info(
sModuleName + " - Record XMLHttpRequest. Method: " + this._requestParams.method + ", URL: " + this._requestParams.url
);
}
if (fnOldStateChanged) {
fnOldStateChanged.apply(this, arguments);
}
};
}
_private.mXhrNativeFunctions.send.apply(this, arguments);
};
} | javascript | function(filename, options) {
_private.oLog.info(sModuleName + " - Record");
if (window.XMLHttpRequest.name === 'FakeXMLHttpRequest') {
_private.oLog.warning(sModuleName + " - Sinon FakeXMLHttpRequest is enabled by another application, recording could be defective");
}
if (_private.isRecordStarted()) {
_private.oLog.error(sModuleName + " - RequestRecorder is already recording, please stop first...");
return;
}
_private.init(options);
_private.sFilename = filename;
_private.bIsRecording = true;
// Overwrite the open method to get the required request parameters (method, URL, headers) and assign
// a group name if provided.
_private.mXhrNativeFunctions.open = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function() {
this._requestParams = this._requestParams || {};
this._requestParams.method = arguments[0];
this._requestParams.url = arguments[1];
this._requestParams.customGroupName = _private.fnCustomGroupNameCallback();
this._requestParams.headers = this._requestParams.headers || [];
_private.mXhrNativeFunctions.open.apply(this, arguments);
};
// Overwrite the setRequestHeader method to record the request headers.
_private.mXhrNativeFunctions.setRequestHeader = window.XMLHttpRequest.prototype.setRequestHeader;
window.XMLHttpRequest.prototype.setRequestHeader = function(sHeaderName, sHeaderValue) {
this._requestParams = this._requestParams || { headers: [] };
this._requestParams.headers.push({
name: sHeaderName,
value: sHeaderValue
});
_private.mXhrNativeFunctions.setRequestHeader.apply(this, arguments);
};
// Overwrite the send method to get the response and the collected data from the XMLHttpRequest
_private.mXhrNativeFunctions.send = window.XMLHttpRequest.prototype.send;
window.XMLHttpRequest.prototype.send = function() {
if (!_private.isUrlFiltered(this._requestParams.url, _private.aEntriesUrlFilter)) {
var fTimestamp = _private.preciseDateNow();
// If the onreadystatechange is already specified by another application, it is called, too.
var fnOldStateChanged = this.onreadystatechange;
this.onreadystatechange = function() {
if (this.readyState === 4) {
_private.aRequests.push(_private.prepareRequestForHar(this, fTimestamp));
_private.oLog.info(
sModuleName + " - Record XMLHttpRequest. Method: " + this._requestParams.method + ", URL: " + this._requestParams.url
);
}
if (fnOldStateChanged) {
fnOldStateChanged.apply(this, arguments);
}
};
}
_private.mXhrNativeFunctions.send.apply(this, arguments);
};
} | [
"function",
"(",
"filename",
",",
"options",
")",
"{",
"_private",
".",
"oLog",
".",
"info",
"(",
"sModuleName",
"+",
"\" - Record\"",
")",
";",
"if",
"(",
"window",
".",
"XMLHttpRequest",
".",
"name",
"===",
"'FakeXMLHttpRequest'",
")",
"{",
"_private",
"... | Start recording with a desired filename and the required options.
@param {string|object} filename The name of the har file to be recorded.
@param {object} [options] Contains optional parameters to config the RequestRecorder:
{function} [options.customGroupNameCallback] A callback is used to determine the custom groupname of the current XMLHttpRequest. If the callback returns a falsy value, the default groupname is used.
boolean} [options.disableDownload] Set this flag to true if you don´t want to download the recording after the recording is finished. This parameter is only used for testing purposes.
{boolean} [options.promptForDownloadFilename] Activates a prompt popup after stop is called to enter a desired filename.
{array|RegExp} [options.entriesUrlFilter] A list of regular expressions, if it matches the URL the request-entry is filtered. | [
"Start",
"recording",
"with",
"a",
"desired",
"filename",
"and",
"the",
"required",
"options",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js#L569-L628 | train | record the request | [
30522,
3853,
1006,
5371,
18442,
1010,
7047,
1007,
1063,
1035,
2797,
1012,
19330,
8649,
1012,
18558,
1006,
15488,
7716,
9307,
18442,
1009,
1000,
1011,
2501,
1000,
1007,
1025,
2065,
1006,
3332,
1012,
20950,
11039,
25856,
2890,
15500,
1012,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableUtils.js | function(oTable) {
if (oTable._iHeaderRowCount === undefined) {
if (!oTable.getColumnHeaderVisible()) {
oTable._iHeaderRowCount = 0;
} else {
var iHeaderRows = 1;
var aColumns = oTable.getColumns();
for (var i = 0; i < aColumns.length; i++) {
if (aColumns[i].shouldRender()) {
// only visible columns need to be considered. We don't invoke getVisibleColumns due to
// performance considerations. With several dozens of columns, it's quite costy to loop them twice.
iHeaderRows = Math.max(iHeaderRows, aColumns[i].getMultiLabels().length);
}
}
oTable._iHeaderRowCount = iHeaderRows;
}
}
return oTable._iHeaderRowCount;
} | javascript | function(oTable) {
if (oTable._iHeaderRowCount === undefined) {
if (!oTable.getColumnHeaderVisible()) {
oTable._iHeaderRowCount = 0;
} else {
var iHeaderRows = 1;
var aColumns = oTable.getColumns();
for (var i = 0; i < aColumns.length; i++) {
if (aColumns[i].shouldRender()) {
// only visible columns need to be considered. We don't invoke getVisibleColumns due to
// performance considerations. With several dozens of columns, it's quite costy to loop them twice.
iHeaderRows = Math.max(iHeaderRows, aColumns[i].getMultiLabels().length);
}
}
oTable._iHeaderRowCount = iHeaderRows;
}
}
return oTable._iHeaderRowCount;
} | [
"function",
"(",
"oTable",
")",
"{",
"if",
"(",
"oTable",
".",
"_iHeaderRowCount",
"===",
"undefined",
")",
"{",
"if",
"(",
"!",
"oTable",
".",
"getColumnHeaderVisible",
"(",
")",
")",
"{",
"oTable",
".",
"_iHeaderRowCount",
"=",
"0",
";",
"}",
"else",
... | Returns the number of header rows.
@param {sap.ui.table.Table} oTable Instance of the table.
@returns {int} The number of rows in the table header. | [
"Returns",
"the",
"number",
"of",
"header",
"rows",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L558-L577 | train | Returns the number of rows in the header of the table. | [
30522,
3853,
1006,
27178,
3085,
1007,
1063,
2065,
1006,
27178,
3085,
1012,
1035,
1045,
4974,
2121,
10524,
3597,
16671,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
2065,
1006,
999,
27178,
3085,
1012,
2131,
25778,
2819,
25311,
13775,
2121,
113... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | parseVariableIdentifier | function parseVariableIdentifier() {
var token, startToken;
startToken = lookahead;
token = lex();
if (token.type !== Token.Identifier) {
throwUnexpected(token);
}
return delegate.markEnd(delegate.createIdentifier(token.value), startToken);
} | javascript | function parseVariableIdentifier() {
var token, startToken;
startToken = lookahead;
token = lex();
if (token.type !== Token.Identifier) {
throwUnexpected(token);
}
return delegate.markEnd(delegate.createIdentifier(token.value), startToken);
} | [
"function",
"parseVariableIdentifier",
"(",
")",
"{",
"var",
"token",
",",
"startToken",
";",
"startToken",
"=",
"lookahead",
";",
"token",
"=",
"lex",
"(",
")",
";",
"if",
"(",
"token",
".",
"type",
"!==",
"Token",
".",
"Identifier",
")",
"{",
"throwUne... | 12.2 Variable Statement | [
"12",
".",
"2",
"Variable",
"Statement"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2643-L2654 | train | ECMA - 262 12. 2 The identifier | [
30522,
3853,
11968,
3366,
10755,
19210,
5178,
16778,
8873,
2121,
1006,
1007,
1063,
13075,
19204,
1010,
2707,
18715,
2368,
1025,
2707,
18715,
2368,
1027,
2298,
4430,
13775,
1025,
19204,
1027,
17244,
1006,
1007,
1025,
2065,
1006,
19204,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/main.js | setUpdateStateInJSON | function setUpdateStateInJSON(key, value) {
var result = $.Deferred();
updateJsonHandler.set(key, value)
.done(function () {
result.resolve();
})
.fail(function () {
resetStateInFailure("AutoUpdate : Could not modify updatehelper.json");
result.reject();
});
return result.promise();
} | javascript | function setUpdateStateInJSON(key, value) {
var result = $.Deferred();
updateJsonHandler.set(key, value)
.done(function () {
result.resolve();
})
.fail(function () {
resetStateInFailure("AutoUpdate : Could not modify updatehelper.json");
result.reject();
});
return result.promise();
} | [
"function",
"setUpdateStateInJSON",
"(",
"key",
",",
"value",
")",
"{",
"var",
"result",
"=",
"$",
".",
"Deferred",
"(",
")",
";",
"updateJsonHandler",
".",
"set",
"(",
"key",
",",
"value",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"result",
... | Sets the update state in updateHelper.json in Appdata
@param {string} key - key to be set
@param {string} value - value to be set
@returns {$.Deferred} - a jquery promise, that is resolved with
success or failure of state update in json file | [
"Sets",
"the",
"update",
"state",
"in",
"updateHelper",
".",
"json",
"in",
"Appdata"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L632-L644 | train | set update state in updatehelper. json | [
30522,
3853,
16437,
27122,
12259,
2378,
22578,
2239,
1006,
3145,
1010,
3643,
1007,
1063,
13075,
2765,
1027,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
10651,
22578,
2239,
11774,
3917,
1012,
30524,
4842,
1012,
1046,
3385,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js | getObjectValues | function getObjectValues(oObject) {
var aKeys = Object.keys(oObject),
aValues = [];
aKeys.forEach(function(sKey) {
aValues.push(oObject[sKey]);
});
return aValues;
} | javascript | function getObjectValues(oObject) {
var aKeys = Object.keys(oObject),
aValues = [];
aKeys.forEach(function(sKey) {
aValues.push(oObject[sKey]);
});
return aValues;
} | [
"function",
"getObjectValues",
"(",
"oObject",
")",
"{",
"var",
"aKeys",
"=",
"Object",
".",
"keys",
"(",
"oObject",
")",
",",
"aValues",
"=",
"[",
"]",
";",
"aKeys",
".",
"forEach",
"(",
"function",
"(",
"sKey",
")",
"{",
"aValues",
".",
"push",
"("... | Polyfill for Object.values
as original Object.values is N/A on IE
@param oObject
@returns {Array} | [
"Polyfill",
"for",
"Object",
".",
"values"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js#L467-L476 | train | Get the values of an object | [
30522,
3853,
2131,
16429,
20614,
10175,
15808,
1006,
1051,
16429,
20614,
1007,
1063,
13075,
17712,
3240,
2015,
1027,
4874,
1012,
6309,
1006,
1051,
16429,
20614,
1007,
1010,
10927,
7630,
2229,
1027,
1031,
1033,
1025,
17712,
3240,
2015,
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... |
ColorlibHQ/AdminLTE | build/js/BoxRefresh.js | Plugin | function Plugin(option) {
return this.each(function () {
var $this = $(this);
var data = $this.data(DataKey);
if (!data) {
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new BoxRefresh($this, options)));
}
if (typeof data == 'string') {
if (typeof data[option] == 'undefined') {
throw new Error('No method named ' + option);
}
data[option]();
}
});
} | javascript | function Plugin(option) {
return this.each(function () {
var $this = $(this);
var data = $this.data(DataKey);
if (!data) {
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new BoxRefresh($this, options)));
}
if (typeof data == 'string') {
if (typeof data[option] == 'undefined') {
throw new Error('No method named ' + option);
}
data[option]();
}
});
} | [
"function",
"Plugin",
"(",
"option",
")",
"{",
"return",
"this",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"$this",
".",
"data",
"(",
"DataKey",
")",
";",
"if",
"(",
"!",
"... | Plugin Definition ================= | [
"Plugin",
"Definition",
"================="
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/build/js/BoxRefresh.js#L80-L97 | train | Plugin constructor. | [
30522,
3853,
13354,
2378,
1006,
5724,
1007,
1063,
2709,
2023,
1012,
2169,
1006,
3853,
1006,
1007,
1063,
13075,
1002,
2023,
1027,
1002,
1006,
2023,
1007,
1025,
13075,
2951,
1027,
1002,
2023,
1012,
2951,
1006,
2951,
14839,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/one-var.js | recordTypes | function recordTypes(statementType, declarations, currentScope) {
for (let i = 0; i < declarations.length; i++) {
if (declarations[i].init === null) {
if (options[statementType] && options[statementType].uninitialized === MODE_ALWAYS) {
currentScope.uninitialized = true;
}
} else {
if (options[statementType] && options[statementType].initialized === MODE_ALWAYS) {
if (options.separateRequires && isRequire(declarations[i])) {
currentScope.required = true;
} else {
currentScope.initialized = true;
}
}
}
}
} | javascript | function recordTypes(statementType, declarations, currentScope) {
for (let i = 0; i < declarations.length; i++) {
if (declarations[i].init === null) {
if (options[statementType] && options[statementType].uninitialized === MODE_ALWAYS) {
currentScope.uninitialized = true;
}
} else {
if (options[statementType] && options[statementType].initialized === MODE_ALWAYS) {
if (options.separateRequires && isRequire(declarations[i])) {
currentScope.required = true;
} else {
currentScope.initialized = true;
}
}
}
}
} | [
"function",
"recordTypes",
"(",
"statementType",
",",
"declarations",
",",
"currentScope",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"declarations",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"declarations",
"[",
"i",
"]",
"... | Records whether initialized/uninitialized/required variables are defined in current scope.
@param {string} statementType node.kind, one of: "var", "let", or "const"
@param {ASTNode[]} declarations List of declarations
@param {Object} currentScope The scope being investigated
@returns {void}
@private | [
"Records",
"whether",
"initialized",
"/",
"uninitialized",
"/",
"required",
"variables",
"are",
"defined",
"in",
"current",
"scope",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L163-L179 | train | record types | [
30522,
3853,
2501,
13874,
2015,
1006,
4861,
13874,
1010,
8170,
2015,
1010,
14731,
16186,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
8170,
2015,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2065,
1006,
8170,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/semi.js | checkForSemicolonForVariableDeclaration | function checkForSemicolonForVariableDeclaration(node) {
const parent = node.parent;
if ((parent.type !== "ForStatement" || parent.init !== node) &&
(!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)
) {
checkForSemicolon(node);
}
} | javascript | function checkForSemicolonForVariableDeclaration(node) {
const parent = node.parent;
if ((parent.type !== "ForStatement" || parent.init !== node) &&
(!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)
) {
checkForSemicolon(node);
}
} | [
"function",
"checkForSemicolonForVariableDeclaration",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"if",
"(",
"(",
"parent",
".",
"type",
"!==",
"\"ForStatement\"",
"||",
"parent",
".",
"init",
"!==",
"node",
")",
"&&",
"(",
... | Checks to see if there's a semicolon after a variable declaration.
@param {ASTNode} node The node to check.
@returns {void} | [
"Checks",
"to",
"see",
"if",
"there",
"s",
"a",
"semicolon",
"after",
"a",
"variable",
"declaration",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi.js#L290-L298 | train | Check if a semicolon is needed for a variable declaration | [
30522,
3853,
4638,
29278,
3366,
7712,
12898,
2078,
29278,
10755,
19210,
3207,
20464,
25879,
3258,
1006,
13045,
1007,
1063,
9530,
3367,
6687,
1027,
13045,
1012,
6687,
1025,
2065,
1006,
1006,
6687,
1012,
2828,
999,
1027,
1027,
1000,
2005,
915... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | src/build/iconBuild.js | iconBuild | function iconBuild(inpOptions, callback) {
const options = Object.assign({}, inpOptions);
const returnCallback = () => {
callback(null, options);
};
if (!options.icon) {
returnCallback();
return;
}
if (options.platform === 'win32') {
if (iconIsIco(options.icon)) {
returnCallback();
return;
}
convertToIco(options.icon)
.then((outPath) => {
options.icon = outPath;
returnCallback();
})
.catch((error) => {
log.warn('Skipping icon conversion to .ico', error);
returnCallback();
});
return;
}
if (options.platform === 'linux') {
if (iconIsPng(options.icon)) {
returnCallback();
return;
}
convertToPng(options.icon)
.then((outPath) => {
options.icon = outPath;
returnCallback();
})
.catch((error) => {
log.warn('Skipping icon conversion to .png', error);
returnCallback();
});
return;
}
if (iconIsIcns(options.icon)) {
returnCallback();
return;
}
if (!isOSX()) {
log.warn(
'Skipping icon conversion to .icns, conversion is only supported on OSX',
);
returnCallback();
return;
}
convertToIcns(options.icon)
.then((outPath) => {
options.icon = outPath;
returnCallback();
})
.catch((error) => {
log.warn('Skipping icon conversion to .icns', error);
options.icon = undefined;
returnCallback();
});
} | javascript | function iconBuild(inpOptions, callback) {
const options = Object.assign({}, inpOptions);
const returnCallback = () => {
callback(null, options);
};
if (!options.icon) {
returnCallback();
return;
}
if (options.platform === 'win32') {
if (iconIsIco(options.icon)) {
returnCallback();
return;
}
convertToIco(options.icon)
.then((outPath) => {
options.icon = outPath;
returnCallback();
})
.catch((error) => {
log.warn('Skipping icon conversion to .ico', error);
returnCallback();
});
return;
}
if (options.platform === 'linux') {
if (iconIsPng(options.icon)) {
returnCallback();
return;
}
convertToPng(options.icon)
.then((outPath) => {
options.icon = outPath;
returnCallback();
})
.catch((error) => {
log.warn('Skipping icon conversion to .png', error);
returnCallback();
});
return;
}
if (iconIsIcns(options.icon)) {
returnCallback();
return;
}
if (!isOSX()) {
log.warn(
'Skipping icon conversion to .icns, conversion is only supported on OSX',
);
returnCallback();
return;
}
convertToIcns(options.icon)
.then((outPath) => {
options.icon = outPath;
returnCallback();
})
.catch((error) => {
log.warn('Skipping icon conversion to .icns', error);
options.icon = undefined;
returnCallback();
});
} | [
"function",
"iconBuild",
"(",
"inpOptions",
",",
"callback",
")",
"{",
"const",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"inpOptions",
")",
";",
"const",
"returnCallback",
"=",
"(",
")",
"=>",
"{",
"callback",
"(",
"null",
",",
"opt... | @callback augmentIconsCallback
@param error
@param options
Will check and convert a `.png` to `.icns` if necessary and augment
options.icon with the result
@param inpOptions will need options.platform and options.icon
@param {augmentIconsCallback} callback | [
"@callback",
"augmentIconsCallback",
"@param",
"error",
"@param",
"options",
"Will",
"check",
"and",
"convert",
"a",
".",
"png",
"to",
".",
"icns",
"if",
"necessary",
"and",
"augment",
"options",
".",
"icon",
"with",
"the",
"result"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/src/build/iconBuild.js#L34-L104 | train | Build the image from the input options | [
30522,
3853,
12696,
8569,
4014,
2094,
1006,
1999,
16340,
9285,
1010,
2655,
5963,
1007,
1063,
9530,
3367,
7047,
1027,
4874,
1012,
23911,
1006,
1063,
1065,
1010,
1999,
16340,
9285,
1007,
1025,
9530,
3367,
2709,
9289,
20850,
8684,
1027,
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... |
mochajs/mocha | lib/errors.js | createInvalidArgumentValueError | function createInvalidArgumentValueError(message, argument, value, reason) {
var err = new TypeError(message);
err.code = 'ERR_MOCHA_INVALID_ARG_VALUE';
err.argument = argument;
err.value = value;
err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
return err;
} | javascript | function createInvalidArgumentValueError(message, argument, value, reason) {
var err = new TypeError(message);
err.code = 'ERR_MOCHA_INVALID_ARG_VALUE';
err.argument = argument;
err.value = value;
err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
return err;
} | [
"function",
"createInvalidArgumentValueError",
"(",
"message",
",",
"argument",
",",
"value",
",",
"reason",
")",
"{",
"var",
"err",
"=",
"new",
"TypeError",
"(",
"message",
")",
";",
"err",
".",
"code",
"=",
"'ERR_MOCHA_INVALID_ARG_VALUE'",
";",
"err",
".",
... | Creates an error object to be thrown when an argument did not use the supported value
@public
@param {string} message - Error message to be displayed.
@param {string} argument - Argument name.
@param {string} value - Argument value.
@param {string} [reason] - Why value is invalid.
@returns {Error} instance detailing the error condition | [
"Creates",
"an",
"error",
"object",
"to",
"be",
"thrown",
"when",
"an",
"argument",
"did",
"not",
"use",
"the",
"supported",
"value"
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/errors.js#L108-L115 | train | Creates an error object for an invalid argument value | [
30522,
3853,
3443,
2378,
10175,
8524,
10623,
27417,
9189,
2389,
5657,
2121,
29165,
1006,
4471,
1010,
6685,
1010,
3643,
1010,
3114,
1007,
1063,
13075,
9413,
2099,
1027,
2047,
2828,
2121,
29165,
1006,
4471,
1007,
1025,
9413,
2099,
1012,
3642,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
BrainJS/brain.js | dist/recurrent/matrix/add-b.js | addB | function addB(product, left, right) {
for (var i = 0; i < product.deltas.length; i++) {
left.deltas[i] = product.deltas[i];
right.deltas[i] = product.deltas[i];
}
} | javascript | function addB(product, left, right) {
for (var i = 0; i < product.deltas.length; i++) {
left.deltas[i] = product.deltas[i];
right.deltas[i] = product.deltas[i];
}
} | [
"function",
"addB",
"(",
"product",
",",
"left",
",",
"right",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"product",
".",
"deltas",
".",
"length",
";",
"i",
"++",
")",
"{",
"left",
".",
"deltas",
"[",
"i",
"]",
"=",
"product",
... | adds {from} deltas to {left} and {right} deltas
@param {Matrix} product
@param {Matrix} left
@param {Matrix} right | [
"adds",
"{",
"from",
"}",
"deltas",
"to",
"{",
"left",
"}",
"and",
"{",
"right",
"}",
"deltas"
] | ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef | https://github.com/BrainJS/brain.js/blob/ab09bfc74a0d29d4731dcbdebfa17aeba7f7b1ef/dist/recurrent/matrix/add-b.js#L13-L18 | train | Add a product to the left and right vectors | [
30522,
3853,
5587,
2497,
1006,
4031,
1010,
2187,
1010,
2157,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
4031,
1012,
7160,
2015,
1012,
3091,
1025,
1045,
1009,
1009,
1007,
1063,
2187,
1012,
7160,
2015,
1031,
1045,
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.demokit/src/sap/ui/demokit/explored/view/master.controller.js | function () {
// subscribe to routing
this.router = UIComponent.getRouterFor(this);
this.router.attachRoutePatternMatched(this.onRouteMatched, this);
// subscribe to app events
this._component = Component.getOwnerComponentFor(this.getView());
this._component.getEventBus().subscribe("app", "selectEntity", this.onSelectEntity, this);
// set the group to the default used in the view
this._sCurrentGroup = this._oDefaultSettings.groupProperty;
// subscribe to nav container events
this.getView().addEventDelegate({
onBeforeFirstShow: jQuery.proxy(this.onBeforeFirstShow, this)
});
} | javascript | function () {
// subscribe to routing
this.router = UIComponent.getRouterFor(this);
this.router.attachRoutePatternMatched(this.onRouteMatched, this);
// subscribe to app events
this._component = Component.getOwnerComponentFor(this.getView());
this._component.getEventBus().subscribe("app", "selectEntity", this.onSelectEntity, this);
// set the group to the default used in the view
this._sCurrentGroup = this._oDefaultSettings.groupProperty;
// subscribe to nav container events
this.getView().addEventDelegate({
onBeforeFirstShow: jQuery.proxy(this.onBeforeFirstShow, this)
});
} | [
"function",
"(",
")",
"{",
"// subscribe to routing",
"this",
".",
"router",
"=",
"UIComponent",
".",
"getRouterFor",
"(",
"this",
")",
";",
"this",
".",
"router",
".",
"attachRoutePatternMatched",
"(",
"this",
".",
"onRouteMatched",
",",
"this",
")",
";",
"... | ====== init ==================================================================== | [
"======",
"init",
"===================================================================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/explored/view/master.controller.js#L40-L56 | train | subscribe to routing events | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
4942,
29234,
2000,
16972,
2023,
1012,
2799,
2099,
1027,
21318,
9006,
29513,
3372,
1012,
2131,
22494,
3334,
29278,
1006,
2023,
1007,
1025,
2023,
1012,
2799,
2099,
1012,
22476,
22494,
2618,
4502,
120... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | getFileInfo | function getFileInfo(session, preventPartialUpdates) {
var start = session.getCursor(),
end = start,
document = session.editor.document,
path = document.file.fullPath,
isHtmlFile = LanguageManager.getLanguageForPath(path).getId() === "html",
result;
if (isHtmlFile) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: session.getJavascriptText()};
} else if (!documentChanges) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_EMPTY,
name: path,
text: ""};
} else if (!preventPartialUpdates && session.editor.lineCount() > LARGE_LINE_COUNT &&
(documentChanges.to - documentChanges.from < LARGE_LINE_CHANGE) &&
documentChanges.from <= start.line &&
documentChanges.to > end.line) {
result = getFragmentAround(session, start);
} else {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: getTextFromDocument(document)};
}
documentChanges = null;
return result;
} | javascript | function getFileInfo(session, preventPartialUpdates) {
var start = session.getCursor(),
end = start,
document = session.editor.document,
path = document.file.fullPath,
isHtmlFile = LanguageManager.getLanguageForPath(path).getId() === "html",
result;
if (isHtmlFile) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: session.getJavascriptText()};
} else if (!documentChanges) {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_EMPTY,
name: path,
text: ""};
} else if (!preventPartialUpdates && session.editor.lineCount() > LARGE_LINE_COUNT &&
(documentChanges.to - documentChanges.from < LARGE_LINE_CHANGE) &&
documentChanges.from <= start.line &&
documentChanges.to > end.line) {
result = getFragmentAround(session, start);
} else {
result = {type: MessageIds.TERN_FILE_INFO_TYPE_FULL,
name: path,
text: getTextFromDocument(document)};
}
documentChanges = null;
return result;
} | [
"function",
"getFileInfo",
"(",
"session",
",",
"preventPartialUpdates",
")",
"{",
"var",
"start",
"=",
"session",
".",
"getCursor",
"(",
")",
",",
"end",
"=",
"start",
",",
"document",
"=",
"session",
".",
"editor",
".",
"document",
",",
"path",
"=",
"d... | Get an object that describes what tern needs to know about the updated
file to produce a hint. As a side-effect of this calls the document
changes are reset.
@param {!Session} session - the current session
@param {boolean=} preventPartialUpdates - if true, disallow partial updates.
Optional, defaults to false.
@return {{type: string, name: string, offsetLines: number, text: string}} | [
"Get",
"an",
"object",
"that",
"describes",
"what",
"tern",
"needs",
"to",
"know",
"about",
"the",
"updated",
"file",
"to",
"produce",
"a",
"hint",
".",
"As",
"a",
"side",
"-",
"effect",
"of",
"this",
"calls",
"the",
"document",
"changes",
"are",
"reset"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L592-L621 | train | getFileInfo - Get file info | [
30522,
3853,
2131,
8873,
19856,
14876,
1006,
5219,
1010,
4652,
19362,
20925,
6279,
27122,
1007,
1063,
13075,
2707,
1027,
5219,
1012,
2131,
10841,
25301,
2099,
1006,
1007,
1010,
2203,
1027,
2707,
1010,
6254,
1027,
5219,
1012,
3559,
1012,
625... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
NetEase/pomelo | lib/util/appUtil.js | function(app) {
app.loadConfigBaseApp(Constants.RESERVED.MASTER, Constants.FILEPATH.MASTER);
app.master = app.get(Constants.RESERVED.MASTER);
} | javascript | function(app) {
app.loadConfigBaseApp(Constants.RESERVED.MASTER, Constants.FILEPATH.MASTER);
app.master = app.get(Constants.RESERVED.MASTER);
} | [
"function",
"(",
"app",
")",
"{",
"app",
".",
"loadConfigBaseApp",
"(",
"Constants",
".",
"RESERVED",
".",
"MASTER",
",",
"Constants",
".",
"FILEPATH",
".",
"MASTER",
")",
";",
"app",
".",
"master",
"=",
"app",
".",
"get",
"(",
"Constants",
".",
"RESER... | Load master info from config/master.json. | [
"Load",
"master",
"info",
"from",
"config",
"/",
"master",
".",
"json",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/util/appUtil.js#L155-L158 | train | Load the master config | [
30522,
3853,
1006,
10439,
1007,
1063,
10439,
1012,
7170,
8663,
8873,
18259,
11022,
29098,
1006,
5377,
2015,
1012,
9235,
1012,
3040,
1010,
5377,
2015,
1012,
5371,
15069,
1012,
3040,
1007,
1025,
10439,
1012,
3040,
1027,
10439,
1012,
2131,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js | function (padding) {
var p = (typeof padding === "number") ? [padding] : padding;
if (p.length === 1) {
p[1] = p[0];
}
if (p.length === 2) {
p[2] = p[0];
}
if (p.length === 3) {
p[3] = p[1];
}
return p;
} | javascript | function (padding) {
var p = (typeof padding === "number") ? [padding] : padding;
if (p.length === 1) {
p[1] = p[0];
}
if (p.length === 2) {
p[2] = p[0];
}
if (p.length === 3) {
p[3] = p[1];
}
return p;
} | [
"function",
"(",
"padding",
")",
"{",
"var",
"p",
"=",
"(",
"typeof",
"padding",
"===",
"\"number\"",
")",
"?",
"[",
"padding",
"]",
":",
"padding",
";",
"if",
"(",
"p",
".",
"length",
"===",
"1",
")",
"{",
"p",
"[",
"1",
"]",
"=",
"p",
"[",
... | Convert CSS padding shorthand to longhand
@param {number|Array.number} padding Element padding
@return {Array.number} | [
"Convert",
"CSS",
"padding",
"shorthand",
"to",
"longhand"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js#L218-L232 | train | Returns an array of padding numbers | [
30522,
3853,
1006,
11687,
30524,
1029,
1031,
11687,
4667,
1033,
1024,
11687,
4667,
1025,
2065,
1006,
1052,
1012,
3091,
1027,
1027,
1027,
1015,
1007,
1063,
1052,
1031,
1015,
1033,
1027,
1052,
1031,
1014,
1033,
1025,
1065,
2065,
1006,
1052,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
uber/deck.gl | modules/core/src/lifecycle/create-props.js | createPropsPrototypeAndTypes | function createPropsPrototypeAndTypes(componentClass) {
const parent = componentClass.prototype;
if (!parent) {
return {
defaultProps: {}
};
}
const parentClass = Object.getPrototypeOf(componentClass);
const parentPropDefs = (parent && getPropsPrototypeAndTypes(parentClass)) || null;
// Parse propTypes from Component.defaultProps
const componentDefaultProps = getOwnProperty(componentClass, 'defaultProps') || {};
const componentPropDefs = parsePropTypes(componentDefaultProps);
// Create a merged type object
const propTypes = Object.assign(
{},
parentPropDefs && parentPropDefs.propTypes,
componentPropDefs.propTypes
);
// Create any necessary property descriptors and create the default prop object
// Assign merged default props
const defaultProps = createPropsPrototype(
componentPropDefs.defaultProps,
parentPropDefs && parentPropDefs.defaultProps,
propTypes,
componentClass
);
// Create a map for prop whose default value is a callback
const deprecatedProps = Object.assign(
{},
parentPropDefs && parentPropDefs.deprecatedProps,
componentPropDefs.deprecatedProps
);
// Store the precalculated props
componentClass._mergedDefaultProps = defaultProps;
componentClass._propTypes = propTypes;
componentClass._deprecatedProps = deprecatedProps;
return {propTypes, defaultProps, deprecatedProps};
} | javascript | function createPropsPrototypeAndTypes(componentClass) {
const parent = componentClass.prototype;
if (!parent) {
return {
defaultProps: {}
};
}
const parentClass = Object.getPrototypeOf(componentClass);
const parentPropDefs = (parent && getPropsPrototypeAndTypes(parentClass)) || null;
// Parse propTypes from Component.defaultProps
const componentDefaultProps = getOwnProperty(componentClass, 'defaultProps') || {};
const componentPropDefs = parsePropTypes(componentDefaultProps);
// Create a merged type object
const propTypes = Object.assign(
{},
parentPropDefs && parentPropDefs.propTypes,
componentPropDefs.propTypes
);
// Create any necessary property descriptors and create the default prop object
// Assign merged default props
const defaultProps = createPropsPrototype(
componentPropDefs.defaultProps,
parentPropDefs && parentPropDefs.defaultProps,
propTypes,
componentClass
);
// Create a map for prop whose default value is a callback
const deprecatedProps = Object.assign(
{},
parentPropDefs && parentPropDefs.deprecatedProps,
componentPropDefs.deprecatedProps
);
// Store the precalculated props
componentClass._mergedDefaultProps = defaultProps;
componentClass._propTypes = propTypes;
componentClass._deprecatedProps = deprecatedProps;
return {propTypes, defaultProps, deprecatedProps};
} | [
"function",
"createPropsPrototypeAndTypes",
"(",
"componentClass",
")",
"{",
"const",
"parent",
"=",
"componentClass",
".",
"prototype",
";",
"if",
"(",
"!",
"parent",
")",
"{",
"return",
"{",
"defaultProps",
":",
"{",
"}",
"}",
";",
"}",
"const",
"parentCla... | Build defaultProps and propType objects by walking component prototype chain | [
"Build",
"defaultProps",
"and",
"propType",
"objects",
"by",
"walking",
"component",
"prototype",
"chain"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/core/src/lifecycle/create-props.js#L92-L136 | train | Create prop descriptors and prop types | [
30522,
3853,
3443,
21572,
4523,
21572,
3406,
13874,
5685,
13874,
2015,
1006,
6922,
26266,
1007,
1063,
9530,
3367,
6687,
1027,
6922,
26266,
1012,
8773,
1025,
2065,
1006,
999,
6687,
1007,
1063,
2709,
1063,
12398,
21572,
4523,
1024,
1063,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
kriasoft/react-starter-kit | tools/lib/overrideRules.js | overrideRules | function overrideRules(rules, patch) {
return rules.map(ruleToPatch => {
let rule = patch(ruleToPatch);
if (rule.rules) {
rule = { ...rule, rules: overrideRules(rule.rules, patch) };
}
if (rule.oneOf) {
rule = { ...rule, oneOf: overrideRules(rule.oneOf, patch) };
}
return rule;
});
} | javascript | function overrideRules(rules, patch) {
return rules.map(ruleToPatch => {
let rule = patch(ruleToPatch);
if (rule.rules) {
rule = { ...rule, rules: overrideRules(rule.rules, patch) };
}
if (rule.oneOf) {
rule = { ...rule, oneOf: overrideRules(rule.oneOf, patch) };
}
return rule;
});
} | [
"function",
"overrideRules",
"(",
"rules",
",",
"patch",
")",
"{",
"return",
"rules",
".",
"map",
"(",
"ruleToPatch",
"=>",
"{",
"let",
"rule",
"=",
"patch",
"(",
"ruleToPatch",
")",
";",
"if",
"(",
"rule",
".",
"rules",
")",
"{",
"rule",
"=",
"{",
... | React Starter Kit (https://www.reactstarterkit.com/)
Copyright © 2014-present Kriasoft, LLC. All rights reserved.
This source code is licensed under the MIT license found in the
LICENSE.txt file in the root directory of this source tree. | [
"React",
"Starter",
"Kit",
"(",
"https",
":",
"//",
"www",
".",
"reactstarterkit",
".",
"com",
"/",
")"
] | 8d6c018f3198dec2a580ecafb011a32f06e38dbf | https://github.com/kriasoft/react-starter-kit/blob/8d6c018f3198dec2a580ecafb011a32f06e38dbf/tools/lib/overrideRules.js#L10-L21 | train | override rules with patch | [
30522,
3853,
2058,
15637,
6820,
4244,
1006,
3513,
1010,
8983,
1007,
1063,
2709,
3513,
1012,
4949,
1006,
3627,
14399,
4017,
2818,
1027,
1028,
1063,
2292,
3627,
1027,
8983,
1006,
3627,
14399,
4017,
2818,
1007,
1025,
2065,
1006,
3627,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (sLiteral, sType, sPath) {
function checkNaN(nValue) {
if (!isFinite(nValue)) { // this rejects NaN, Infinity, -Infinity
throw new Error(sPath + ": Not a valid " + sType + " literal: " + sLiteral);
}
return nValue;
}
if (sLiteral === "null") {
return null;
}
switch (sType) {
case "Edm.Boolean":
return sLiteral === "true";
case "Edm.Byte":
case "Edm.Int16":
case "Edm.Int32":
case "Edm.SByte":
return checkNaN(parseInt(sLiteral));
case "Edm.Date":
case "Edm.DateTimeOffset":
case "Edm.Decimal":
case "Edm.Guid":
case "Edm.Int64":
case "Edm.TimeOfDay":
return sLiteral;
case "Edm.Double":
case "Edm.Single":
return sLiteral === "INF" || sLiteral === "-INF" || sLiteral === "NaN"
? sLiteral
: checkNaN(parseFloat(sLiteral));
default:
throw new Error(sPath + ": Unsupported type: " + sType);
}
} | javascript | function (sLiteral, sType, sPath) {
function checkNaN(nValue) {
if (!isFinite(nValue)) { // this rejects NaN, Infinity, -Infinity
throw new Error(sPath + ": Not a valid " + sType + " literal: " + sLiteral);
}
return nValue;
}
if (sLiteral === "null") {
return null;
}
switch (sType) {
case "Edm.Boolean":
return sLiteral === "true";
case "Edm.Byte":
case "Edm.Int16":
case "Edm.Int32":
case "Edm.SByte":
return checkNaN(parseInt(sLiteral));
case "Edm.Date":
case "Edm.DateTimeOffset":
case "Edm.Decimal":
case "Edm.Guid":
case "Edm.Int64":
case "Edm.TimeOfDay":
return sLiteral;
case "Edm.Double":
case "Edm.Single":
return sLiteral === "INF" || sLiteral === "-INF" || sLiteral === "NaN"
? sLiteral
: checkNaN(parseFloat(sLiteral));
default:
throw new Error(sPath + ": Unsupported type: " + sType);
}
} | [
"function",
"(",
"sLiteral",
",",
"sType",
",",
"sPath",
")",
"{",
"function",
"checkNaN",
"(",
"nValue",
")",
"{",
"if",
"(",
"!",
"isFinite",
"(",
"nValue",
")",
")",
"{",
"// this rejects NaN, Infinity, -Infinity",
"throw",
"new",
"Error",
"(",
"sPath",
... | Parses a literal to the model value. The types "Edm.Binary" and "Edm.String" are
unsupported.
@param {string} sLiteral The literal value
@param {string} sType The type
@param {string} sPath The path for this literal (for error messages)
@returns {*} The model value
@throws {Error} If the type is invalid or unsupported; the function only validates when a
conversion is required | [
"Parses",
"a",
"literal",
"to",
"the",
"model",
"value",
".",
"The",
"types",
"Edm",
".",
"Binary",
"and",
"Edm",
".",
"String",
"are",
"unsupported",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L910-L946 | train | Returns the value of an object literal | [
30522,
3853,
1006,
18036,
21673,
1010,
2358,
18863,
1010,
14690,
2232,
1007,
1063,
3853,
4638,
7229,
1006,
1050,
10175,
5657,
1007,
1063,
2065,
1006,
999,
2003,
16294,
4221,
1006,
1050,
10175,
5657,
1007,
1007,
1063,
1013,
1013,
2023,
19164... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/geo/geoCreator.js | function (originRegionArr, mapName, nameMap) {
// Not use the original
var regionsArr = (originRegionArr || []).slice();
var dataNameMap = zrUtil.createHashMap();
for (var i = 0; i < regionsArr.length; i++) {
dataNameMap.set(regionsArr[i].name, regionsArr[i]);
}
var source = geoSourceManager.load(mapName, nameMap);
zrUtil.each(source.regions, function (region) {
var name = region.name;
!dataNameMap.get(name) && regionsArr.push({name: name});
});
return regionsArr;
} | javascript | function (originRegionArr, mapName, nameMap) {
// Not use the original
var regionsArr = (originRegionArr || []).slice();
var dataNameMap = zrUtil.createHashMap();
for (var i = 0; i < regionsArr.length; i++) {
dataNameMap.set(regionsArr[i].name, regionsArr[i]);
}
var source = geoSourceManager.load(mapName, nameMap);
zrUtil.each(source.regions, function (region) {
var name = region.name;
!dataNameMap.get(name) && regionsArr.push({name: name});
});
return regionsArr;
} | [
"function",
"(",
"originRegionArr",
",",
"mapName",
",",
"nameMap",
")",
"{",
"// Not use the original",
"var",
"regionsArr",
"=",
"(",
"originRegionArr",
"||",
"[",
"]",
")",
".",
"slice",
"(",
")",
";",
"var",
"dataNameMap",
"=",
"zrUtil",
".",
"createHash... | Fill given regions array
@param {Array.<Object>} originRegionArr
@param {string} mapName
@param {Object} [nameMap]
@return {Array} | [
"Fill",
"given",
"regions",
"array"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/geo/geoCreator.js#L219-L235 | train | Get regions array from the map | [
30522,
3853,
1006,
4761,
23784,
2906,
2099,
1010,
4949,
18442,
1010,
2171,
2863,
2361,
1007,
1063,
1013,
1013,
2025,
2224,
1996,
2434,
13075,
4655,
2906,
2099,
1027,
1006,
4761,
23784,
2906,
2099,
1064,
1064,
1031,
1033,
1007,
1012,
14704,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(html) {
var range = rangy.createRange(this.doc),
node = this.doc.createElement('DIV'),
fragment = this.doc.createDocumentFragment(),
lastChild;
node.innerHTML = html;
lastChild = node.lastChild;
while (node.firstChild) {
fragment.appendChild(node.firstChild);
}
this.insertNode(fragment);
if (lastChild) {
this.setAfter(lastChild);
}
} | javascript | function(html) {
var range = rangy.createRange(this.doc),
node = this.doc.createElement('DIV'),
fragment = this.doc.createDocumentFragment(),
lastChild;
node.innerHTML = html;
lastChild = node.lastChild;
while (node.firstChild) {
fragment.appendChild(node.firstChild);
}
this.insertNode(fragment);
if (lastChild) {
this.setAfter(lastChild);
}
} | [
"function",
"(",
"html",
")",
"{",
"var",
"range",
"=",
"rangy",
".",
"createRange",
"(",
"this",
".",
"doc",
")",
",",
"node",
"=",
"this",
".",
"doc",
".",
"createElement",
"(",
"'DIV'",
")",
",",
"fragment",
"=",
"this",
".",
"doc",
".",
"create... | Insert html at the caret position and move the cursor after the inserted html
@param {String} html HTML string to insert
@example
selection.insertHTML("<p>foobar</p>"); | [
"Insert",
"html",
"at",
"the",
"caret",
"position",
"and",
"move",
"the",
"cursor",
"after",
"the",
"inserted",
"html"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L9161-L9178 | train | Creates a new element with the given HTML | [
30522,
3853,
1006,
16129,
1007,
1063,
13075,
2846,
1027,
8369,
2100,
1012,
3443,
24388,
2063,
1006,
2023,
1012,
9986,
1007,
1010,
13045,
1027,
2023,
1012,
9986,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1010,
15778,
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... | |
SheetJS/js-xlsx | xlsx.js | parse_BrtWbProp | function parse_BrtWbProp(data, length) {
var o = ({});
var flags = data.read_shift(4);
o.defaultThemeVersion = data.read_shift(4);
var strName = (length > 8) ? parse_XLWideString(data) : "";
if(strName.length > 0) o.CodeName = strName;
o.autoCompressPictures = !!(flags & 0x10000);
o.backupFile = !!(flags & 0x40);
o.checkCompatibility = !!(flags & 0x1000);
o.date1904 = !!(flags & 0x01);
o.filterPrivacy = !!(flags & 0x08);
o.hidePivotFieldList = !!(flags & 0x400);
o.promptedSolutions = !!(flags & 0x10);
o.publishItems = !!(flags & 0x800);
o.refreshAllConnections = !!(flags & 0x40000);
o.saveExternalLinkValues = !!(flags & 0x80);
o.showBorderUnselectedTables = !!(flags & 0x04);
o.showInkAnnotation = !!(flags & 0x20);
o.showObjects = ["all", "placeholders", "none"][(flags >> 13) & 0x03];
o.showPivotChartFilter = !!(flags & 0x8000);
o.updateLinks = ["userSet", "never", "always"][(flags >> 8) & 0x03];
return o;
} | javascript | function parse_BrtWbProp(data, length) {
var o = ({});
var flags = data.read_shift(4);
o.defaultThemeVersion = data.read_shift(4);
var strName = (length > 8) ? parse_XLWideString(data) : "";
if(strName.length > 0) o.CodeName = strName;
o.autoCompressPictures = !!(flags & 0x10000);
o.backupFile = !!(flags & 0x40);
o.checkCompatibility = !!(flags & 0x1000);
o.date1904 = !!(flags & 0x01);
o.filterPrivacy = !!(flags & 0x08);
o.hidePivotFieldList = !!(flags & 0x400);
o.promptedSolutions = !!(flags & 0x10);
o.publishItems = !!(flags & 0x800);
o.refreshAllConnections = !!(flags & 0x40000);
o.saveExternalLinkValues = !!(flags & 0x80);
o.showBorderUnselectedTables = !!(flags & 0x04);
o.showInkAnnotation = !!(flags & 0x20);
o.showObjects = ["all", "placeholders", "none"][(flags >> 13) & 0x03];
o.showPivotChartFilter = !!(flags & 0x8000);
o.updateLinks = ["userSet", "never", "always"][(flags >> 8) & 0x03];
return o;
} | [
"function",
"parse_BrtWbProp",
"(",
"data",
",",
"length",
")",
"{",
"var",
"o",
"=",
"(",
"{",
"}",
")",
";",
"var",
"flags",
"=",
"data",
".",
"read_shift",
"(",
"4",
")",
";",
"o",
".",
"defaultThemeVersion",
"=",
"data",
".",
"read_shift",
"(",
... | /* [MS-XLSB] 2.4.815 BrtWbProp | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"815",
"BrtWbProp"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L14787-L14809 | train | Parse BrtWbProp | [
30522,
3853,
11968,
3366,
1035,
7987,
2102,
2860,
2497,
21572,
2361,
1006,
2951,
1010,
3091,
1007,
1063,
13075,
1051,
1027,
1006,
1063,
1065,
1007,
1025,
13075,
9245,
1027,
2951,
1012,
3191,
1035,
5670,
1006,
1018,
1007,
1025,
1051,
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... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/tabs.js | tabBrowser_getTabPanelElement | function tabBrowser_getTabPanelElement(tabIndex, elemString)
{
var index = tabIndex ? tabIndex : this.selectedIndex;
var elemStr = elemString ? elemString : "";
// Get the tab panel and check if an element has to be fetched
var panel = this.getElement({type: "tabs_tabPanel", subtype: "tab", value: this.getTab(index)});
var elem = new elementslib.Lookup(this._controller.window.document, panel.expression + elemStr);
return elem;
} | javascript | function tabBrowser_getTabPanelElement(tabIndex, elemString)
{
var index = tabIndex ? tabIndex : this.selectedIndex;
var elemStr = elemString ? elemString : "";
// Get the tab panel and check if an element has to be fetched
var panel = this.getElement({type: "tabs_tabPanel", subtype: "tab", value: this.getTab(index)});
var elem = new elementslib.Lookup(this._controller.window.document, panel.expression + elemStr);
return elem;
} | [
"function",
"tabBrowser_getTabPanelElement",
"(",
"tabIndex",
",",
"elemString",
")",
"{",
"var",
"index",
"=",
"tabIndex",
"?",
"tabIndex",
":",
"this",
".",
"selectedIndex",
";",
"var",
"elemStr",
"=",
"elemString",
"?",
"elemString",
":",
"\"\"",
";",
"// G... | Creates the child element of the tab's notification bar
@param {number} tabIndex
(Optional) Index of the tab to check
@param {string} elemString
(Optional) Lookup string of the notification bar's child element
@return The created child element
@type {ElemBase} | [
"Creates",
"the",
"child",
"element",
"of",
"the",
"tab",
"s",
"notification",
"bar"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/tabs.js#L352-L362 | train | Get the tab panel element | [
30522,
3853,
21628,
12618,
9333,
2121,
1035,
2131,
2696,
2497,
9739,
12260,
16930,
4765,
1006,
21628,
22254,
10288,
1010,
3449,
6633,
3367,
4892,
1007,
1063,
13075,
5950,
1027,
21628,
22254,
10288,
1029,
21628,
22254,
10288,
1024,
2023,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | buildPropertyPaths | function buildPropertyPaths(oObject, sObjectName) {
Object.keys(oObject).forEach(function (sProperty) {
var sPropertyPath = _Helper.buildPath(sObjectName, sProperty),
vPropertyValue = oObject[sProperty];
if (sProperty === "@$ui5._") {
return; // ignore private namespace
}
if (vPropertyValue !== null && typeof vPropertyValue === "object") {
buildPropertyPaths(vPropertyValue, sPropertyPath);
} else {
aSelect.push(sPropertyPath);
}
});
} | javascript | function buildPropertyPaths(oObject, sObjectName) {
Object.keys(oObject).forEach(function (sProperty) {
var sPropertyPath = _Helper.buildPath(sObjectName, sProperty),
vPropertyValue = oObject[sProperty];
if (sProperty === "@$ui5._") {
return; // ignore private namespace
}
if (vPropertyValue !== null && typeof vPropertyValue === "object") {
buildPropertyPaths(vPropertyValue, sPropertyPath);
} else {
aSelect.push(sPropertyPath);
}
});
} | [
"function",
"buildPropertyPaths",
"(",
"oObject",
",",
"sObjectName",
")",
"{",
"Object",
".",
"keys",
"(",
"oObject",
")",
".",
"forEach",
"(",
"function",
"(",
"sProperty",
")",
"{",
"var",
"sPropertyPath",
"=",
"_Helper",
".",
"buildPath",
"(",
"sObjectNa... | /*
Creates an array of all property paths for a given object
@param {object} oObject
@param {object} [sObjectName] The name of the complex property | [
"/",
"*",
"Creates",
"an",
"array",
"of",
"all",
"property",
"paths",
"for",
"a",
"given",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L1236-L1251 | train | Build property paths for the given object | [
30522,
3853,
3857,
21572,
4842,
3723,
15069,
2015,
1006,
1051,
16429,
20614,
1010,
17540,
20614,
18442,
1007,
1063,
4874,
1012,
6309,
1006,
1051,
16429,
20614,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
11867,
18981,
15010,
1007,
1063,
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... |
SAP/openui5 | lib/jsdoc/transform-apijson-for-sdk.js | createApiRefApiJson | function createApiRefApiJson(oChainObject) {
if (returnOutputFiles) {
// If requested, return data instead of writing to FS (required by UI5 Tooling/UI5 Builder)
return JSON.stringify(oChainObject.parsedData);
}
let sOutputDir = path.dirname(oChainObject.outputFile);
// Create dir if it does not exist
if (!fs.existsSync(sOutputDir)) {
fs.mkdirSync(sOutputDir);
}
// Write result to file
fs.writeFileSync(oChainObject.outputFile, JSON.stringify(oChainObject.parsedData) /* Transform back to string */, 'utf8');
} | javascript | function createApiRefApiJson(oChainObject) {
if (returnOutputFiles) {
// If requested, return data instead of writing to FS (required by UI5 Tooling/UI5 Builder)
return JSON.stringify(oChainObject.parsedData);
}
let sOutputDir = path.dirname(oChainObject.outputFile);
// Create dir if it does not exist
if (!fs.existsSync(sOutputDir)) {
fs.mkdirSync(sOutputDir);
}
// Write result to file
fs.writeFileSync(oChainObject.outputFile, JSON.stringify(oChainObject.parsedData) /* Transform back to string */, 'utf8');
} | [
"function",
"createApiRefApiJson",
"(",
"oChainObject",
")",
"{",
"if",
"(",
"returnOutputFiles",
")",
"{",
"// If requested, return data instead of writing to FS (required by UI5 Tooling/UI5 Builder)",
"return",
"JSON",
".",
"stringify",
"(",
"oChainObject",
".",
"parsedData",... | Create api.json from parsed data
@param oChainObject chain object | [
"Create",
"api",
".",
"json",
"from",
"parsed",
"data"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/transform-apijson-for-sdk.js#L747-L761 | train | Creates the JSON file for the API reference | [
30522,
3853,
3443,
9331,
7442,
7011,
8197,
22578,
2239,
1006,
28166,
8113,
16429,
20614,
1007,
1063,
2065,
1006,
2709,
5833,
18780,
8873,
4244,
1007,
1063,
1013,
1013,
2065,
7303,
1010,
2709,
2951,
2612,
1997,
3015,
2000,
1042,
2015,
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... |
postmanlabs/newman | lib/run/options.js | function (location, options, callback) {
if (_.isArray(location)) { return callback(null, location); }
util.fetch(location, function (err, data) {
if (err) {
return callback(err);
}
// Try loading as a JSON, fall-back to CSV. @todo: switch to file extension based loading.
async.waterfall([
(cb) => {
try {
return cb(null, liquidJSON.parse(data.trim()));
}
catch (e) {
return cb(null, undefined); // e masked to avoid displaying JSON parse errors for CSV files
}
},
(json, cb) => {
if (json) {
return cb(null, json);
}
// Wasn't JSON
parseCsv(data, {
columns: true,
escape: '\\',
cast: csvAutoParse,
trim: true
}, cb);
}
], (err, parsed) => {
if (err) {
// todo: Log meaningful stuff here
return callback(err);
}
callback(null, parsed);
});
});
} | javascript | function (location, options, callback) {
if (_.isArray(location)) { return callback(null, location); }
util.fetch(location, function (err, data) {
if (err) {
return callback(err);
}
// Try loading as a JSON, fall-back to CSV. @todo: switch to file extension based loading.
async.waterfall([
(cb) => {
try {
return cb(null, liquidJSON.parse(data.trim()));
}
catch (e) {
return cb(null, undefined); // e masked to avoid displaying JSON parse errors for CSV files
}
},
(json, cb) => {
if (json) {
return cb(null, json);
}
// Wasn't JSON
parseCsv(data, {
columns: true,
escape: '\\',
cast: csvAutoParse,
trim: true
}, cb);
}
], (err, parsed) => {
if (err) {
// todo: Log meaningful stuff here
return callback(err);
}
callback(null, parsed);
});
});
} | [
"function",
"(",
"location",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"_",
".",
"isArray",
"(",
"location",
")",
")",
"{",
"return",
"callback",
"(",
"null",
",",
"location",
")",
";",
"}",
"util",
".",
"fetch",
"(",
"location",
",",
"... | The iterationData loader module, with support for JSON or CSV data files.
@param {String|Object[]} location - The path to the iteration data file for the current collection run, or
the array of iteration data objects.
@param {Object} options - The set of wrapped options.
@param {Function} callback - The function invoked to indicate the end of the iteration data loading routine.
@returns {*} | [
"The",
"iterationData",
"loader",
"module",
"with",
"support",
"for",
"JSON",
"or",
"CSV",
"data",
"files",
"."
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L261-L300 | train | Load the content of a file | [
30522,
3853,
1006,
3295,
1010,
7047,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
1035,
1012,
18061,
11335,
2100,
1006,
3295,
1007,
1007,
1063,
2709,
2655,
5963,
1006,
19701,
1010,
3295,
1007,
1025,
1065,
21183,
4014,
1012,
18584,
1006,
3295,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | parse_PtgRefN | function parse_PtgRefN(blob, length, opts) {
var type = (blob[blob.l] & 0x60)>>5;
blob.l += 1;
var loc = parse_RgceLocRel(blob, 0, opts);
return [type, loc];
} | javascript | function parse_PtgRefN(blob, length, opts) {
var type = (blob[blob.l] & 0x60)>>5;
blob.l += 1;
var loc = parse_RgceLocRel(blob, 0, opts);
return [type, loc];
} | [
"function",
"parse_PtgRefN",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"type",
"=",
"(",
"blob",
"[",
"blob",
".",
"l",
"]",
"&",
"0x60",
")",
">>",
"5",
";",
"blob",
".",
"l",
"+=",
"1",
";",
"var",
"loc",
"=",
"parse_RgceLocRel"... | /* [MS-XLS] 2.5.198.88 ; [MS-XLSB] 2.5.97.72 TODO | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"88",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"72",
"TODO"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10431-L10436 | train | Parse a PTG RefN | [
30522,
3853,
11968,
3366,
1035,
13866,
17603,
2546,
2078,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2828,
1027,
1006,
1038,
4135,
2497,
1031,
1038,
4135,
2497,
1012,
1048,
1033,
1004,
1014,
2595,
16086,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js | function(oList){
var jListContRef = oList.$("lst");
if (jListContRef.hasClass("sapUiUx3ExactLstExpanded")) {
//collapse
oList._oPopup.close();
} else {
//expand
oList._oPopup.open();
}
} | javascript | function(oList){
var jListContRef = oList.$("lst");
if (jListContRef.hasClass("sapUiUx3ExactLstExpanded")) {
//collapse
oList._oPopup.close();
} else {
//expand
oList._oPopup.open();
}
} | [
"function",
"(",
"oList",
")",
"{",
"var",
"jListContRef",
"=",
"oList",
".",
"$",
"(",
"\"lst\"",
")",
";",
"if",
"(",
"jListContRef",
".",
"hasClass",
"(",
"\"sapUiUx3ExactLstExpanded\"",
")",
")",
"{",
"//collapse",
"oList",
".",
"_oPopup",
".",
"close"... | Toggles the vertical Collapse State | [
"Toggles",
"the",
"vertical",
"Collapse",
"State"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js#L1362-L1371 | train | If the list has a class sapUiUx3ExactLstExpanded then collapse the list | [
30522,
3853,
1006,
19330,
2923,
1007,
1063,
13075,
1046,
9863,
8663,
7913,
2546,
1027,
19330,
2923,
1012,
1002,
1006,
1000,
1048,
3367,
1000,
1007,
1025,
2065,
1006,
1046,
9863,
8663,
7913,
2546,
1012,
2038,
26266,
1006,
1000,
20066,
10179,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | Collection | function Collection(cy, elements, options) {
if (cy === undefined || !core(cy)) {
error('A collection must have a reference to the core');
return;
}
var map = new Map$1();
var createdElements = false;
if (!elements) {
elements = [];
} else if (elements.length > 0 && plainObject(elements[0]) && !element(elements[0])) {
createdElements = true; // make elements from json and restore all at once later
var eles = [];
var elesIds = new Set$1();
for (var i = 0, l = elements.length; i < l; i++) {
var json = elements[i];
if (json.data == null) {
json.data = {};
}
var _data = json.data; // make sure newly created elements have valid ids
if (_data.id == null) {
_data.id = idFactory.generate(cy, json);
} else if (cy.hasElementWithId(_data.id) || elesIds.has(_data.id)) {
continue; // can't create element if prior id already exists
}
var ele = new Element(cy, json, false);
eles.push(ele);
elesIds.add(_data.id);
}
elements = eles;
}
this.length = 0;
for (var _i = 0, _l = elements.length; _i < _l; _i++) {
var element$$1 = elements[_i];
if (element$$1 == null) {
continue;
}
var id = element$$1._private.data.id;
if (options == null || options.unique && !map.has(id)) {
map.set(id, {
index: this.length,
ele: element$$1
});
this[this.length] = element$$1;
this.length++;
}
}
this._private = {
cy: cy,
map: map
}; // restore the elements if we created them from json
if (createdElements) {
this.restore();
}
} | javascript | function Collection(cy, elements, options) {
if (cy === undefined || !core(cy)) {
error('A collection must have a reference to the core');
return;
}
var map = new Map$1();
var createdElements = false;
if (!elements) {
elements = [];
} else if (elements.length > 0 && plainObject(elements[0]) && !element(elements[0])) {
createdElements = true; // make elements from json and restore all at once later
var eles = [];
var elesIds = new Set$1();
for (var i = 0, l = elements.length; i < l; i++) {
var json = elements[i];
if (json.data == null) {
json.data = {};
}
var _data = json.data; // make sure newly created elements have valid ids
if (_data.id == null) {
_data.id = idFactory.generate(cy, json);
} else if (cy.hasElementWithId(_data.id) || elesIds.has(_data.id)) {
continue; // can't create element if prior id already exists
}
var ele = new Element(cy, json, false);
eles.push(ele);
elesIds.add(_data.id);
}
elements = eles;
}
this.length = 0;
for (var _i = 0, _l = elements.length; _i < _l; _i++) {
var element$$1 = elements[_i];
if (element$$1 == null) {
continue;
}
var id = element$$1._private.data.id;
if (options == null || options.unique && !map.has(id)) {
map.set(id, {
index: this.length,
ele: element$$1
});
this[this.length] = element$$1;
this.length++;
}
}
this._private = {
cy: cy,
map: map
}; // restore the elements if we created them from json
if (createdElements) {
this.restore();
}
} | [
"function",
"Collection",
"(",
"cy",
",",
"elements",
",",
"options",
")",
"{",
"if",
"(",
"cy",
"===",
"undefined",
"||",
"!",
"core",
"(",
"cy",
")",
")",
"{",
"error",
"(",
"'A collection must have a reference to the core'",
")",
";",
"return",
";",
"}"... | represents a set of nodes, edges, or both together | [
"represents",
"a",
"set",
"of",
"nodes",
"edges",
"or",
"both",
"together"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L11811-L11880 | train | A collection of elements | [
30522,
3853,
3074,
1006,
22330,
1010,
3787,
1010,
7047,
1007,
1063,
2065,
1006,
22330,
1027,
1027,
1027,
6151,
28344,
1064,
1064,
999,
4563,
1006,
22330,
1007,
1007,
1063,
7561,
1006,
1005,
1037,
3074,
2442,
2031,
1037,
4431,
2000,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/filesystem/impls/appshell/AppshellFileSystem.js | unlink | function unlink(path, callback) {
appshell.fs.unlink(path, function (err) {
callback(_mapError(err));
});
} | javascript | function unlink(path, callback) {
appshell.fs.unlink(path, function (err) {
callback(_mapError(err));
});
} | [
"function",
"unlink",
"(",
"path",
",",
"callback",
")",
"{",
"appshell",
".",
"fs",
".",
"unlink",
"(",
"path",
",",
"function",
"(",
"err",
")",
"{",
"callback",
"(",
"_mapError",
"(",
"err",
")",
")",
";",
"}",
")",
";",
"}"
] | Unlink (i.e., permanently delete) the file or directory at the given path,
calling back asynchronously with a possibly null FileSystemError string.
Directories will be unlinked even when non-empty.
@param {string} path
@param {function(string)=} callback | [
"Unlink",
"(",
"i",
".",
"e",
".",
"permanently",
"delete",
")",
"the",
"file",
"or",
"directory",
"at",
"the",
"given",
"path",
"calling",
"back",
"asynchronously",
"with",
"a",
"possibly",
"null",
"FileSystemError",
"string",
".",
"Directories",
"will",
"b... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/AppshellFileSystem.js#L470-L474 | train | unlink the file at the given path | [
30522,
3853,
4895,
13767,
1006,
4130,
1010,
2655,
5963,
1007,
1063,
18726,
18223,
1012,
1042,
2015,
1012,
4895,
13767,
1006,
4130,
1010,
3853,
1006,
9413,
2099,
1007,
1063,
2655,
5963,
1006,
1035,
4949,
2121,
29165,
1006,
9413,
2099,
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... |
aws/aws-sdk-js | lib/credentials/shared_ini_file_credentials.js | SharedIniFileCredentials | function SharedIniFileCredentials(options) {
AWS.Credentials.call(this);
options = options || {};
this.filename = options.filename;
this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile;
this.disableAssumeRole = Boolean(options.disableAssumeRole);
this.preferStaticCredentials = Boolean(options.preferStaticCredentials);
this.tokenCodeFn = options.tokenCodeFn || null;
this.httpOptions = options.httpOptions || null;
this.get(options.callback || AWS.util.fn.noop);
} | javascript | function SharedIniFileCredentials(options) {
AWS.Credentials.call(this);
options = options || {};
this.filename = options.filename;
this.profile = options.profile || process.env.AWS_PROFILE || AWS.util.defaultProfile;
this.disableAssumeRole = Boolean(options.disableAssumeRole);
this.preferStaticCredentials = Boolean(options.preferStaticCredentials);
this.tokenCodeFn = options.tokenCodeFn || null;
this.httpOptions = options.httpOptions || null;
this.get(options.callback || AWS.util.fn.noop);
} | [
"function",
"SharedIniFileCredentials",
"(",
"options",
")",
"{",
"AWS",
".",
"Credentials",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"filename",
"=",
"options",
".",
"filename",
";",
"this",
".",
... | Creates a new SharedIniFileCredentials object.
@param options [map] a set of options
@option options profile [String] (AWS_PROFILE env var or 'default')
the name of the profile to load.
@option options filename [String] ('~/.aws/credentials' or defined by
AWS_SHARED_CREDENTIALS_FILE process env var)
the filename to use when loading credentials.
@option options disableAssumeRole [Boolean] (false) True to disable
support for profiles that assume an IAM role. If true, and an assume
role profile is selected, an error is raised.
@option options preferStaticCredentials [Boolean] (false) True to
prefer static credentials to role_arn if both are present.
@option options tokenCodeFn [Function] (null) Function to provide
STS Assume Role TokenCode, if mfa_serial is provided for profile in ini
file. Function is called with value of mfa_serial and callback, and
should provide the TokenCode or an error to the callback in the format
callback(err, token)
@option options callback [Function] (err) Credentials are eagerly loaded
by the constructor. When the callback is called with no error, the
credentials have been loaded successfully.
@option options httpOptions [map] A set of options to pass to the low-level
HTTP request. Currently supported options are:
* **proxy** [String] — the URL to proxy requests through
* **agent** [http.Agent, https.Agent] — the Agent object to perform
HTTP requests with. Used for connection pooling. Defaults to the global
agent (`http.globalAgent`) for non-SSL connections. Note that for
SSL connections, a special Agent object is used in order to enable
peer certificate verification. This feature is only available in the
Node.js environment.
* **connectTimeout** [Integer] — Sets the socket to timeout after
failing to establish a connection with the server after
`connectTimeout` milliseconds. This timeout has no effect once a socket
connection has been established.
* **timeout** [Integer] — Sets the socket to timeout after timeout
milliseconds of inactivity on the socket. Defaults to two minutes
(120000). | [
"Creates",
"a",
"new",
"SharedIniFileCredentials",
"object",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/credentials/shared_ini_file_credentials.js#L76-L88 | train | SharedIniFileCredentials constructor. | [
30522,
3853,
4207,
5498,
8873,
2571,
16748,
16454,
26340,
1006,
7047,
1007,
1063,
22091,
2015,
1012,
22496,
1012,
2655,
1006,
2023,
1007,
1025,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2023,
1012,
5371,
18442,
1027,
7047,
1012,
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... |
uber/deck.gl | modules/json/src/parsers/convert-json.js | convertJSONViews | function convertJSONViews(jsonViews, configuration) {
if (!jsonViews) {
return jsonViews;
}
const viewCatalog = configuration.views || {};
jsonViews = Array.isArray(jsonViews) ? jsonViews : [jsonViews];
return jsonViews
.map(jsonView => {
// Try to find a view definition
const View = viewCatalog[jsonView.type] || DEFAULT_VIEW_CATALOG[jsonView.type];
// Instantiate it
if (View) {
const viewProps = Object.assign({}, jsonView);
delete viewProps.type;
return new View(viewProps);
}
return null;
})
.filter(Boolean);
} | javascript | function convertJSONViews(jsonViews, configuration) {
if (!jsonViews) {
return jsonViews;
}
const viewCatalog = configuration.views || {};
jsonViews = Array.isArray(jsonViews) ? jsonViews : [jsonViews];
return jsonViews
.map(jsonView => {
// Try to find a view definition
const View = viewCatalog[jsonView.type] || DEFAULT_VIEW_CATALOG[jsonView.type];
// Instantiate it
if (View) {
const viewProps = Object.assign({}, jsonView);
delete viewProps.type;
return new View(viewProps);
}
return null;
})
.filter(Boolean);
} | [
"function",
"convertJSONViews",
"(",
"jsonViews",
",",
"configuration",
")",
"{",
"if",
"(",
"!",
"jsonViews",
")",
"{",
"return",
"jsonViews",
";",
"}",
"const",
"viewCatalog",
"=",
"configuration",
".",
"views",
"||",
"{",
"}",
";",
"jsonViews",
"=",
"Ar... | Instantiates views: `{type: MapView, ...props}` to `MapView(...props)` | [
"Instantiates",
"views",
":",
"{",
"type",
":",
"MapView",
"...",
"props",
"}",
"to",
"MapView",
"(",
"...",
"props",
")"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/json/src/parsers/convert-json.js#L80-L101 | train | Converts a JSON view definition to a view object | [
30522,
3853,
10463,
22578,
2239,
8584,
2015,
1006,
1046,
3385,
8584,
2015,
1010,
9563,
1007,
1063,
2065,
1006,
999,
1046,
3385,
8584,
2015,
1007,
1063,
2709,
1046,
3385,
8584,
2015,
1025,
1065,
9530,
3367,
3193,
11266,
23067,
2290,
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... |
caolan/async | lib/someSeries.js | someSeries | function someSeries(coll, iteratee, callback) {
return createTester(Boolean, res => res)(eachOfSeries, coll, iteratee, callback)
} | javascript | function someSeries(coll, iteratee, callback) {
return createTester(Boolean, res => res)(eachOfSeries, coll, iteratee, callback)
} | [
"function",
"someSeries",
"(",
"coll",
",",
"iteratee",
",",
"callback",
")",
"{",
"return",
"createTester",
"(",
"Boolean",
",",
"res",
"=>",
"res",
")",
"(",
"eachOfSeries",
",",
"coll",
",",
"iteratee",
",",
"callback",
")",
"}"
] | The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
@name someSeries
@static
@memberOf module:Collections
@method
@see [async.some]{@link module:Collections.some}
@alias anySeries
@category Collection
@param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
@param {AsyncFunction} iteratee - An async truth test to apply to each item
in the collections in series.
The iteratee should complete with a boolean `result` value.
Invoked with (item, callback).
@param {Function} [callback] - A callback which is called as soon as any
iteratee returns `true`, or after all the iteratee functions have finished.
Result will be either `true` or `false` depending on the values of the async
tests. Invoked with (err, result).
@returns {Promise} a promise, if no callback provided | [
"The",
"same",
"as",
"[",
"some",
"]",
"{",
"@link",
"module",
":",
"Collections",
".",
"some",
"}",
"but",
"runs",
"only",
"a",
"single",
"async",
"operation",
"at",
"a",
"time",
"."
] | 4330d536c106592139fa82062494c9dba0da1fdb | https://github.com/caolan/async/blob/4330d536c106592139fa82062494c9dba0da1fdb/lib/someSeries.js#L26-L28 | train | A function that tests if a collection contains only a single value. | [
30522,
3853,
2070,
8043,
3111,
1006,
8902,
2140,
1010,
2009,
22139,
2063,
1010,
2655,
5963,
1007,
1063,
2709,
3443,
22199,
2121,
1006,
22017,
20898,
1010,
24501,
1027,
1028,
24501,
1007,
1006,
2169,
11253,
8043,
3111,
1010,
8902,
2140,
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... |
eslint/eslint | lib/rules/new-cap.js | isCapAllowed | function isCapAllowed(allowedMap, node, calleeName, pattern) {
const sourceText = sourceCode.getText(node.callee);
if (allowedMap[calleeName] || allowedMap[sourceText]) {
return true;
}
if (pattern && pattern.test(sourceText)) {
return true;
}
if (calleeName === "UTC" && node.callee.type === "MemberExpression") {
// allow if callee is Date.UTC
return node.callee.object.type === "Identifier" &&
node.callee.object.name === "Date";
}
return skipProperties && node.callee.type === "MemberExpression";
} | javascript | function isCapAllowed(allowedMap, node, calleeName, pattern) {
const sourceText = sourceCode.getText(node.callee);
if (allowedMap[calleeName] || allowedMap[sourceText]) {
return true;
}
if (pattern && pattern.test(sourceText)) {
return true;
}
if (calleeName === "UTC" && node.callee.type === "MemberExpression") {
// allow if callee is Date.UTC
return node.callee.object.type === "Identifier" &&
node.callee.object.name === "Date";
}
return skipProperties && node.callee.type === "MemberExpression";
} | [
"function",
"isCapAllowed",
"(",
"allowedMap",
",",
"node",
",",
"calleeName",
",",
"pattern",
")",
"{",
"const",
"sourceText",
"=",
"sourceCode",
".",
"getText",
"(",
"node",
".",
"callee",
")",
";",
"if",
"(",
"allowedMap",
"[",
"calleeName",
"]",
"||",
... | Check if capitalization is allowed for a CallExpression
@param {Object} allowedMap Object mapping calleeName to a Boolean
@param {ASTNode} node CallExpression node
@param {string} calleeName Capitalized callee name from a CallExpression
@param {Object} pattern RegExp object from options pattern
@returns {boolean} Returns true if the callee may be capitalized | [
"Check",
"if",
"capitalization",
"is",
"allowed",
"for",
"a",
"CallExpression"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/new-cap.js#L207-L226 | train | Check if the node is allowed by the given map | [
30522,
3853,
2003,
17695,
8095,
15096,
1006,
3039,
2863,
2361,
1010,
13045,
1010,
2655,
12129,
14074,
30524,
1025,
1065,
2065,
1006,
5418,
1004,
1004,
5418,
1012,
3231,
1006,
3120,
18209,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
2065,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/ui-element.js | UIMap | function UIMap()
{
// the singleton pattern, split into two parts so that "new" can still
// be used, in addition to "getInstance()"
UIMap.self = this;
// need to attach variables directly to the Editor object in order for them
// to be in scope for Editor methods
if (is_IDE()) {
Editor.uiMap = this;
Editor.UI_PREFIX = UI_GLOBAL.UI_PREFIX;
}
this.pagesets = new Object();
/**
* pageset[pagesetName]
* regexp
* elements[elementName]
* UIElement
*/
this.addPageset = function(pagesetShorthand)
{
try {
var pageset = new Pageset(pagesetShorthand);
}
catch (e) {
safe_alert("Could not create pageset from shorthand:\n"
+ print_r(pagesetShorthand) + "\n" + e.message);
return false;
}
if (this.pagesets[pageset.name]) {
safe_alert('Could not add pageset "' + pageset.name
+ '": a pageset with that name already exists!');
return false;
}
this.pagesets[pageset.name] = pageset;
return true;
};
/**
* @param pagesetName
* @param uiElementShorthand a representation of a UIElement object in
* shorthand JSON.
*/
this.addElement = function(pagesetName, uiElementShorthand)
{
try {
var uiElement = new UIElement(uiElementShorthand);
}
catch (e) {
safe_alert("Could not create UI element from shorthand:\n"
+ print_r(uiElementShorthand) + "\n" + e.message);
return false;
}
// run the element's unit tests only for the IDE, and only when the
// IDE is starting. Make a rough guess as to the latter condition.
if (is_IDE() && !editor.selDebugger && !uiElement.test()) {
safe_alert('Could not add UI element "' + uiElement.name
+ '": failed testcases!');
return false;
}
try {
this.pagesets[pagesetName].uiElements[uiElement.name] = uiElement;
}
catch (e) {
safe_alert("Could not add UI element '" + uiElement.name
+ "' to pageset '" + pagesetName + "':\n" + e.message);
return false;
}
return true;
};
/**
* Returns the pageset for a given UI specifier string.
*
* @param uiSpecifierString
* @return a pageset object
*/
this.getPageset = function(uiSpecifierString)
{
try {
var uiSpecifier = new UISpecifier(uiSpecifierString);
return this.pagesets[uiSpecifier.pagesetName];
}
catch (e) {
return null;
}
}
/**
* Returns the UIElement that a UISpecifierString or pageset and element
* pair refer to.
*
* @param pagesetNameOrUISpecifierString
* @return a UIElement, or null if none is found associated with
* uiSpecifierString
*/
this.getUIElement = function(pagesetNameOrUISpecifierString, uiElementName)
{
var pagesetName = pagesetNameOrUISpecifierString;
if (arguments.length == 1) {
var uiSpecifierString = pagesetNameOrUISpecifierString;
try {
var uiSpecifier = new UISpecifier(uiSpecifierString);
pagesetName = uiSpecifier.pagesetName;
var uiElementName = uiSpecifier.elementName;
}
catch (e) {
return null;
}
}
try {
return this.pagesets[pagesetName].uiElements[uiElementName];
}
catch (e) {
return null;
}
};
/**
* Returns a list of pagesets that "contains" the provided page,
* represented as a document object. Containership is defined by the
* Pageset object's contain() method.
*
* @param inDocument the page to get pagesets for
* @return a list of pagesets
*/
this.getPagesetsForPage = function(inDocument)
{
var pagesets = [];
for (var pagesetName in this.pagesets) {
var pageset = this.pagesets[pagesetName];
if (pageset.contains(inDocument)) {
pagesets.push(pageset);
}
}
return pagesets;
};
/**
* Returns a list of all pagesets.
*
* @return a list of pagesets
*/
this.getPagesets = function()
{
var pagesets = [];
for (var pagesetName in this.pagesets) {
pagesets.push(this.pagesets[pagesetName]);
}
return pagesets;
};
/**
* Returns a list of elements on a page that a given UI specifier string,
* maps to. If no elements are mapped to, returns an empty list..
*
* @param uiSpecifierString a String that specifies a UI element with
* attendant argument values
* @param inDocument the document object the specified UI element
* appears in
* @return a potentially-empty list of elements
* specified by uiSpecifierString
*/
this.getPageElements = function(uiSpecifierString, inDocument)
{
var locator = this.getLocator(uiSpecifierString);
var results = locator ? eval_locator(locator, inDocument) : [];
return results;
};
/**
* Returns the locator string that a given UI specifier string maps to, or
* null if it cannot be mapped.
*
* @param uiSpecifierString
*/
this.getLocator = function(uiSpecifierString)
{
try {
var uiSpecifier = new UISpecifier(uiSpecifierString);
}
catch (e) {
safe_alert('Could not create UISpecifier for string "'
+ uiSpecifierString + '": ' + e.message);
return null;
}
var uiElement = this.getUIElement(uiSpecifier.pagesetName,
uiSpecifier.elementName);
try {
return uiElement.getLocator(uiSpecifier.args);
}
catch (e) {
return null;
}
}
/**
* Finds and returns a UI specifier string given an element and the page
* that it appears on.
*
* @param pageElement the document element to map to a UI specifier
* @param inDocument the document the element appears in
* @return a UI specifier string, or false if one cannot be
* constructed
*/
this.getUISpecifierString = function(pageElement, inDocument)
{
var is_fuzzy_match =
BrowserBot.prototype.locateElementByUIElement.is_fuzzy_match;
var pagesets = this.getPagesetsForPage(inDocument);
for (var i = 0; i < pagesets.length; ++i) {
var pageset = pagesets[i];
var uiElements = pageset.getUIElements();
for (var j = 0; j < uiElements.length; ++j) {
var uiElement = uiElements[j];
// first test against the generic locator, if there is one.
// This should net some performance benefit when recording on
// more complicated pages.
if (uiElement.getGenericLocator) {
var passedTest = false;
var results =
eval_locator(uiElement.getGenericLocator(), inDocument);
for (var i = 0; i < results.length; ++i) {
if (results[i] == pageElement) {
passedTest = true;
break;
}
}
if (!passedTest) {
continue;
}
}
var defaultLocators;
if (uiElement.isDefaultLocatorConstructionDeferred) {
defaultLocators = uiElement.getDefaultLocators(inDocument);
}
else {
defaultLocators = uiElement.defaultLocators;
}
//safe_alert(print_r(uiElement.defaultLocators));
for (var locator in defaultLocators) {
var locatedElements = eval_locator(locator, inDocument);
if (locatedElements.length) {
var locatedElement = locatedElements[0];
}
else {
continue;
}
// use a heuristic to determine whether the element
// specified is the "same" as the element we're matching
if (is_fuzzy_match) {
if (is_fuzzy_match(locatedElement, pageElement)) {
return UI_GLOBAL.UI_PREFIX + '=' +
new UISpecifier(pageset.name, uiElement.name,
defaultLocators[locator]);
}
}
else {
if (locatedElement == pageElement) {
return UI_GLOBAL.UI_PREFIX + '=' +
new UISpecifier(pageset.name, uiElement.name,
defaultLocators[locator]);
}
}
// ok, matching the element failed. See if an offset
// locator can complete the match.
if (uiElement.getOffsetLocator) {
for (var k = 0; k < locatedElements.length; ++k) {
var offsetLocator = uiElement
.getOffsetLocator(locatedElements[k], pageElement);
if (offsetLocator) {
return UI_GLOBAL.UI_PREFIX + '=' +
new UISpecifier(pageset.name,
uiElement.name,
defaultLocators[locator])
+ '->' + offsetLocator;
}
}
}
}
}
}
return false;
};
/**
* Returns a sorted list of UI specifier string stubs representing possible
* UI elements for all pagesets, paired the their descriptions. Stubs
* contain all required arguments, but leave argument values blank.
*
* @return a list of UI specifier string stubs
*/
this.getUISpecifierStringStubs = function() {
var stubs = [];
var pagesets = this.getPagesets();
for (var i = 0; i < pagesets.length; ++i) {
stubs = stubs.concat(pagesets[i].getUISpecifierStringStubs());
}
stubs.sort(function(a, b) {
if (a[0] < b[0]) {
return -1;
}
return a[0] == b[0] ? 0 : 1;
});
return stubs;
}
} | javascript | function UIMap()
{
// the singleton pattern, split into two parts so that "new" can still
// be used, in addition to "getInstance()"
UIMap.self = this;
// need to attach variables directly to the Editor object in order for them
// to be in scope for Editor methods
if (is_IDE()) {
Editor.uiMap = this;
Editor.UI_PREFIX = UI_GLOBAL.UI_PREFIX;
}
this.pagesets = new Object();
/**
* pageset[pagesetName]
* regexp
* elements[elementName]
* UIElement
*/
this.addPageset = function(pagesetShorthand)
{
try {
var pageset = new Pageset(pagesetShorthand);
}
catch (e) {
safe_alert("Could not create pageset from shorthand:\n"
+ print_r(pagesetShorthand) + "\n" + e.message);
return false;
}
if (this.pagesets[pageset.name]) {
safe_alert('Could not add pageset "' + pageset.name
+ '": a pageset with that name already exists!');
return false;
}
this.pagesets[pageset.name] = pageset;
return true;
};
/**
* @param pagesetName
* @param uiElementShorthand a representation of a UIElement object in
* shorthand JSON.
*/
this.addElement = function(pagesetName, uiElementShorthand)
{
try {
var uiElement = new UIElement(uiElementShorthand);
}
catch (e) {
safe_alert("Could not create UI element from shorthand:\n"
+ print_r(uiElementShorthand) + "\n" + e.message);
return false;
}
// run the element's unit tests only for the IDE, and only when the
// IDE is starting. Make a rough guess as to the latter condition.
if (is_IDE() && !editor.selDebugger && !uiElement.test()) {
safe_alert('Could not add UI element "' + uiElement.name
+ '": failed testcases!');
return false;
}
try {
this.pagesets[pagesetName].uiElements[uiElement.name] = uiElement;
}
catch (e) {
safe_alert("Could not add UI element '" + uiElement.name
+ "' to pageset '" + pagesetName + "':\n" + e.message);
return false;
}
return true;
};
/**
* Returns the pageset for a given UI specifier string.
*
* @param uiSpecifierString
* @return a pageset object
*/
this.getPageset = function(uiSpecifierString)
{
try {
var uiSpecifier = new UISpecifier(uiSpecifierString);
return this.pagesets[uiSpecifier.pagesetName];
}
catch (e) {
return null;
}
}
/**
* Returns the UIElement that a UISpecifierString or pageset and element
* pair refer to.
*
* @param pagesetNameOrUISpecifierString
* @return a UIElement, or null if none is found associated with
* uiSpecifierString
*/
this.getUIElement = function(pagesetNameOrUISpecifierString, uiElementName)
{
var pagesetName = pagesetNameOrUISpecifierString;
if (arguments.length == 1) {
var uiSpecifierString = pagesetNameOrUISpecifierString;
try {
var uiSpecifier = new UISpecifier(uiSpecifierString);
pagesetName = uiSpecifier.pagesetName;
var uiElementName = uiSpecifier.elementName;
}
catch (e) {
return null;
}
}
try {
return this.pagesets[pagesetName].uiElements[uiElementName];
}
catch (e) {
return null;
}
};
/**
* Returns a list of pagesets that "contains" the provided page,
* represented as a document object. Containership is defined by the
* Pageset object's contain() method.
*
* @param inDocument the page to get pagesets for
* @return a list of pagesets
*/
this.getPagesetsForPage = function(inDocument)
{
var pagesets = [];
for (var pagesetName in this.pagesets) {
var pageset = this.pagesets[pagesetName];
if (pageset.contains(inDocument)) {
pagesets.push(pageset);
}
}
return pagesets;
};
/**
* Returns a list of all pagesets.
*
* @return a list of pagesets
*/
this.getPagesets = function()
{
var pagesets = [];
for (var pagesetName in this.pagesets) {
pagesets.push(this.pagesets[pagesetName]);
}
return pagesets;
};
/**
* Returns a list of elements on a page that a given UI specifier string,
* maps to. If no elements are mapped to, returns an empty list..
*
* @param uiSpecifierString a String that specifies a UI element with
* attendant argument values
* @param inDocument the document object the specified UI element
* appears in
* @return a potentially-empty list of elements
* specified by uiSpecifierString
*/
this.getPageElements = function(uiSpecifierString, inDocument)
{
var locator = this.getLocator(uiSpecifierString);
var results = locator ? eval_locator(locator, inDocument) : [];
return results;
};
/**
* Returns the locator string that a given UI specifier string maps to, or
* null if it cannot be mapped.
*
* @param uiSpecifierString
*/
this.getLocator = function(uiSpecifierString)
{
try {
var uiSpecifier = new UISpecifier(uiSpecifierString);
}
catch (e) {
safe_alert('Could not create UISpecifier for string "'
+ uiSpecifierString + '": ' + e.message);
return null;
}
var uiElement = this.getUIElement(uiSpecifier.pagesetName,
uiSpecifier.elementName);
try {
return uiElement.getLocator(uiSpecifier.args);
}
catch (e) {
return null;
}
}
/**
* Finds and returns a UI specifier string given an element and the page
* that it appears on.
*
* @param pageElement the document element to map to a UI specifier
* @param inDocument the document the element appears in
* @return a UI specifier string, or false if one cannot be
* constructed
*/
this.getUISpecifierString = function(pageElement, inDocument)
{
var is_fuzzy_match =
BrowserBot.prototype.locateElementByUIElement.is_fuzzy_match;
var pagesets = this.getPagesetsForPage(inDocument);
for (var i = 0; i < pagesets.length; ++i) {
var pageset = pagesets[i];
var uiElements = pageset.getUIElements();
for (var j = 0; j < uiElements.length; ++j) {
var uiElement = uiElements[j];
// first test against the generic locator, if there is one.
// This should net some performance benefit when recording on
// more complicated pages.
if (uiElement.getGenericLocator) {
var passedTest = false;
var results =
eval_locator(uiElement.getGenericLocator(), inDocument);
for (var i = 0; i < results.length; ++i) {
if (results[i] == pageElement) {
passedTest = true;
break;
}
}
if (!passedTest) {
continue;
}
}
var defaultLocators;
if (uiElement.isDefaultLocatorConstructionDeferred) {
defaultLocators = uiElement.getDefaultLocators(inDocument);
}
else {
defaultLocators = uiElement.defaultLocators;
}
//safe_alert(print_r(uiElement.defaultLocators));
for (var locator in defaultLocators) {
var locatedElements = eval_locator(locator, inDocument);
if (locatedElements.length) {
var locatedElement = locatedElements[0];
}
else {
continue;
}
// use a heuristic to determine whether the element
// specified is the "same" as the element we're matching
if (is_fuzzy_match) {
if (is_fuzzy_match(locatedElement, pageElement)) {
return UI_GLOBAL.UI_PREFIX + '=' +
new UISpecifier(pageset.name, uiElement.name,
defaultLocators[locator]);
}
}
else {
if (locatedElement == pageElement) {
return UI_GLOBAL.UI_PREFIX + '=' +
new UISpecifier(pageset.name, uiElement.name,
defaultLocators[locator]);
}
}
// ok, matching the element failed. See if an offset
// locator can complete the match.
if (uiElement.getOffsetLocator) {
for (var k = 0; k < locatedElements.length; ++k) {
var offsetLocator = uiElement
.getOffsetLocator(locatedElements[k], pageElement);
if (offsetLocator) {
return UI_GLOBAL.UI_PREFIX + '=' +
new UISpecifier(pageset.name,
uiElement.name,
defaultLocators[locator])
+ '->' + offsetLocator;
}
}
}
}
}
}
return false;
};
/**
* Returns a sorted list of UI specifier string stubs representing possible
* UI elements for all pagesets, paired the their descriptions. Stubs
* contain all required arguments, but leave argument values blank.
*
* @return a list of UI specifier string stubs
*/
this.getUISpecifierStringStubs = function() {
var stubs = [];
var pagesets = this.getPagesets();
for (var i = 0; i < pagesets.length; ++i) {
stubs = stubs.concat(pagesets[i].getUISpecifierStringStubs());
}
stubs.sort(function(a, b) {
if (a[0] < b[0]) {
return -1;
}
return a[0] == b[0] ? 0 : 1;
});
return stubs;
}
} | [
"function",
"UIMap",
"(",
")",
"{",
"// the singleton pattern, split into two parts so that \"new\" can still",
"// be used, in addition to \"getInstance()\"",
"UIMap",
".",
"self",
"=",
"this",
";",
"// need to attach variables directly to the Editor object in order for them",
"// to be... | Construct the UI map object, and return it. Once the object is instantiated,
it binds to a global variable and will not leave scope.
@return new UIMap object | [
"Construct",
"the",
"UI",
"map",
"object",
"and",
"return",
"it",
".",
"Once",
"the",
"object",
"is",
"instantiated",
"it",
"binds",
"to",
"a",
"global",
"variable",
"and",
"will",
"not",
"leave",
"scope",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/ui-element.js#L822-L1163 | train | UIMap constructor. | [
30522,
3853,
21318,
2863,
2361,
1006,
1007,
1063,
1013,
1013,
1996,
28159,
5418,
1010,
3975,
2046,
2048,
3033,
2061,
2008,
1000,
2047,
1000,
2064,
2145,
1013,
1013,
2022,
2109,
1010,
1999,
2804,
2000,
1000,
2131,
7076,
26897,
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... |
akveo/nebular | docs/assets/ghspa.js | redirect | function redirect() {
l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + repo + '/?' +
(l.pathname ? 'p=' + l.pathname.replace(/&/g, '~and~').replace(repo, '') : '') +
(l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +
(l.hash))
} | javascript | function redirect() {
l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + repo + '/?' +
(l.pathname ? 'p=' + l.pathname.replace(/&/g, '~and~').replace(repo, '') : '') +
(l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +
(l.hash))
} | [
"function",
"redirect",
"(",
")",
"{",
"l",
".",
"replace",
"(",
"l",
".",
"protocol",
"+",
"'//'",
"+",
"l",
".",
"hostname",
"+",
"(",
"l",
".",
"port",
"?",
"':'",
"+",
"l",
".",
"port",
":",
"''",
")",
"+",
"repo",
"+",
"'/?'",
"+",
"(",
... | /* redirect all 404 trafic to index.html | [
"/",
"*",
"redirect",
"all",
"404",
"trafic",
"to",
"index",
".",
"html"
] | 6ae213cefd487e3036f933ba24dacf977a0592a5 | https://github.com/akveo/nebular/blob/6ae213cefd487e3036f933ba24dacf977a0592a5/docs/assets/ghspa.js#L30-L35 | train | redirect to the repo | [
30522,
3853,
2417,
7442,
6593,
1006,
1007,
1063,
1048,
1012,
5672,
1006,
1048,
1012,
8778,
1009,
1005,
1013,
1013,
1005,
1009,
1048,
1012,
3677,
18442,
1009,
1006,
1048,
1012,
3417,
1029,
1005,
1024,
1005,
1009,
1048,
1012,
3417,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/nonblock-statement-body-position.js | getOption | function getOption(keywordName) {
return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] ||
context.options[0] ||
"beside";
} | javascript | function getOption(keywordName) {
return context.options[1] && context.options[1].overrides && context.options[1].overrides[keywordName] ||
context.options[0] ||
"beside";
} | [
"function",
"getOption",
"(",
"keywordName",
")",
"{",
"return",
"context",
".",
"options",
"[",
"1",
"]",
"&&",
"context",
".",
"options",
"[",
"1",
"]",
".",
"overrides",
"&&",
"context",
".",
"options",
"[",
"1",
"]",
".",
"overrides",
"[",
"keyword... | ---------------------------------------------------------------------- Helpers ----------------------------------------------------------------------
Gets the applicable preference for a particular keyword
@param {string} keywordName The name of a keyword, e.g. 'if'
@returns {string} The applicable option for the keyword, e.g. 'beside' | [
"----------------------------------------------------------------------",
"Helpers",
"----------------------------------------------------------------------",
"Gets",
"the",
"applicable",
"preference",
"for",
"a",
"particular",
"keyword"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/nonblock-statement-body-position.js#L58-L62 | train | Get the option for the given keyword name | [
30522,
3853,
2131,
7361,
3508,
1006,
3145,
18351,
18442,
1007,
1063,
2709,
6123,
1012,
7047,
1031,
1015,
1033,
1004,
1004,
6123,
1012,
7047,
1031,
1015,
1033,
1012,
2058,
15637,
2015,
1004,
1004,
6123,
1012,
7047,
1031,
1015,
1033,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | clone | function clone(vValue) {
return vValue === undefined || vValue === Infinity || vValue === -Infinity
|| /*NaN?*/vValue !== vValue // eslint-disable-line no-self-compare
? vValue
: JSON.parse(JSON.stringify(vValue));
} | javascript | function clone(vValue) {
return vValue === undefined || vValue === Infinity || vValue === -Infinity
|| /*NaN?*/vValue !== vValue // eslint-disable-line no-self-compare
? vValue
: JSON.parse(JSON.stringify(vValue));
} | [
"function",
"clone",
"(",
"vValue",
")",
"{",
"return",
"vValue",
"===",
"undefined",
"||",
"vValue",
"===",
"Infinity",
"||",
"vValue",
"===",
"-",
"Infinity",
"||",
"/*NaN?*/",
"vValue",
"!==",
"vValue",
"// eslint-disable-line no-self-compare",
"?",
"vValue",
... | Returns a clone of the given value, according to the rules of
<code>JSON.stringify</code>.
<b>Warning: <code>Date</code> objects will be turned into strings</b>
@param {*} vValue - Any value, including <code>undefined</code>
@returns {*} - A clone | [
"Returns",
"a",
"clone",
"of",
"the",
"given",
"value",
"according",
"to",
"the",
"rules",
"of",
"<code",
">",
"JSON",
".",
"stringify<",
"/",
"code",
">",
".",
"<b",
">",
"Warning",
":",
"<code",
">",
"Date<",
"/",
"code",
">",
"objects",
"will",
"b... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L185-L190 | train | Clone a value | [
30522,
3853,
17598,
1006,
1058,
10175,
5657,
1007,
1063,
2709,
1058,
10175,
5657,
1027,
1027,
1027,
6151,
28344,
1064,
1064,
1058,
10175,
5657,
1027,
1027,
1027,
15579,
1064,
1064,
1058,
10175,
5657,
1027,
1027,
1027,
1011,
15579,
1064,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/cli/getOutputFolder.js | getOutputFolder | function getOutputFolder(args) {
var bookRoot = path.resolve(args[0] || process.cwd());
var defaultOutputRoot = path.join(bookRoot, '_book');
var outputFolder = args[1]? path.resolve(process.cwd(), args[1]) : defaultOutputRoot;
return outputFolder;
} | javascript | function getOutputFolder(args) {
var bookRoot = path.resolve(args[0] || process.cwd());
var defaultOutputRoot = path.join(bookRoot, '_book');
var outputFolder = args[1]? path.resolve(process.cwd(), args[1]) : defaultOutputRoot;
return outputFolder;
} | [
"function",
"getOutputFolder",
"(",
"args",
")",
"{",
"var",
"bookRoot",
"=",
"path",
".",
"resolve",
"(",
"args",
"[",
"0",
"]",
"||",
"process",
".",
"cwd",
"(",
")",
")",
";",
"var",
"defaultOutputRoot",
"=",
"path",
".",
"join",
"(",
"bookRoot",
... | Return path to output folder
@param {Array} args
@return {String} | [
"Return",
"path",
"to",
"output",
"folder"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/cli/getOutputFolder.js#L9-L15 | train | Get the output folder | [
30522,
3853,
2131,
5833,
18780,
10371,
2121,
1006,
12098,
5620,
1007,
1063,
13075,
2338,
3217,
4140,
1027,
4130,
1012,
10663,
1006,
12098,
5620,
1031,
1014,
1033,
1064,
1064,
2832,
1012,
19296,
2094,
1006,
1007,
1007,
1025,
13075,
12398,
58... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.