repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
firebase/firebase-js-sdk | packages/auth/demo/public/script.js | onSignInWithGenericIdPCredential | function onSignInWithGenericIdPCredential() {
var providerId = $('#signin-generic-idp-provider-id').val();
var idToken = $('#signin-generic-idp-id-token').val();
var accessToken = $('#signin-generic-idp-access-token').val();
var provider = new firebase.auth.OAuthProvider(providerId);
auth.signInWithCredential(
provider.credential(idToken, accessToken))
.then(onAuthUserCredentialSuccess, onAuthError);
} | javascript | function onSignInWithGenericIdPCredential() {
var providerId = $('#signin-generic-idp-provider-id').val();
var idToken = $('#signin-generic-idp-id-token').val();
var accessToken = $('#signin-generic-idp-access-token').val();
var provider = new firebase.auth.OAuthProvider(providerId);
auth.signInWithCredential(
provider.credential(idToken, accessToken))
.then(onAuthUserCredentialSuccess, onAuthError);
} | [
"function",
"onSignInWithGenericIdPCredential",
"(",
")",
"{",
"var",
"providerId",
"=",
"$",
"(",
"'#signin-generic-idp-provider-id'",
")",
".",
"val",
"(",
")",
";",
"var",
"idToken",
"=",
"$",
"(",
"'#signin-generic-idp-id-token'",
")",
".",
"val",
"(",
")",
... | Signs in with a generic IdP credential. | [
"Signs",
"in",
"with",
"a",
"generic",
"IdP",
"credential",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/demo/public/script.js#L394-L402 | train | Signs in with a generic IDP credential | [
30522,
3853,
2006,
5332,
29076,
2078,
24415,
6914,
22420,
3593,
15042,
5596,
24271,
1006,
1007,
1063,
13075,
10802,
3593,
1027,
1002,
1006,
1005,
1001,
3696,
2378,
1011,
12391,
1011,
8909,
2361,
1011,
10802,
1011,
8909,
1005,
1007,
1012,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | joinDeclarations | function joinDeclarations(declarations) {
const declaration = declarations[0];
const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]);
const previousNode = body[currentIndex - 1];
return fixer => {
const type = sourceCode.getTokenBefore(declaration);
const prevSemi = sourceCode.getTokenBefore(type);
const res = [];
if (previousNode && previousNode.kind === sourceCode.getText(type)) {
if (prevSemi.value === ";") {
res.push(fixer.replaceText(prevSemi, ","));
} else {
res.push(fixer.insertTextAfter(prevSemi, ","));
}
res.push(fixer.replaceText(type, ""));
}
return res;
};
} | javascript | function joinDeclarations(declarations) {
const declaration = declarations[0];
const body = Array.isArray(declaration.parent.parent.body) ? declaration.parent.parent.body : [];
const currentIndex = body.findIndex(node => node.range[0] === declaration.parent.range[0]);
const previousNode = body[currentIndex - 1];
return fixer => {
const type = sourceCode.getTokenBefore(declaration);
const prevSemi = sourceCode.getTokenBefore(type);
const res = [];
if (previousNode && previousNode.kind === sourceCode.getText(type)) {
if (prevSemi.value === ";") {
res.push(fixer.replaceText(prevSemi, ","));
} else {
res.push(fixer.insertTextAfter(prevSemi, ","));
}
res.push(fixer.replaceText(type, ""));
}
return res;
};
} | [
"function",
"joinDeclarations",
"(",
"declarations",
")",
"{",
"const",
"declaration",
"=",
"declarations",
"[",
"0",
"]",
";",
"const",
"body",
"=",
"Array",
".",
"isArray",
"(",
"declaration",
".",
"parent",
".",
"parent",
".",
"body",
")",
"?",
"declara... | Fixer to join VariableDeclaration's into a single declaration
@param {VariableDeclarator[]} declarations The `VariableDeclaration` to join
@returns {Function} The fixer function | [
"Fixer",
"to",
"join",
"VariableDeclaration",
"s",
"into",
"a",
"single",
"declaration"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L264-L286 | train | Join declarations with semicolon | [
30522,
3853,
3693,
3207,
20464,
25879,
8496,
1006,
8170,
2015,
1007,
1063,
9530,
3367,
8170,
1027,
8170,
2015,
1031,
1014,
1033,
1025,
9530,
3367,
2303,
1027,
9140,
1012,
18061,
11335,
2100,
1006,
8170,
1012,
6687,
1012,
6687,
1012,
2303,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | dist/webuploader.withoutimage.js | function( name, cb, ctx ) {
var events = this._events;
if ( !events ) {
return this;
}
if ( !name && !cb && !ctx ) {
this._events = [];
return this;
}
eachEvent( name, cb, function( name, cb ) {
$.each( findHandlers( events, name, cb, ctx ), function() {
delete events[ this.id ];
});
});
return this;
} | javascript | function( name, cb, ctx ) {
var events = this._events;
if ( !events ) {
return this;
}
if ( !name && !cb && !ctx ) {
this._events = [];
return this;
}
eachEvent( name, cb, function( name, cb ) {
$.each( findHandlers( events, name, cb, ctx ), function() {
delete events[ this.id ];
});
});
return this;
} | [
"function",
"(",
"name",
",",
"cb",
",",
"ctx",
")",
"{",
"var",
"events",
"=",
"this",
".",
"_events",
";",
"if",
"(",
"!",
"events",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"!",
"name",
"&&",
"!",
"cb",
"&&",
"!",
"ctx",
")",
"{",
... | 解除事件绑定
@method off
@grammar off( [name[, callback[, context] ] ] ) => self
@param {String} [name] 事件名
@param {Function} [callback] 事件处理器
@param {Object} [context] 事件处理器的上下文。
@return {self} 返回自身,方便链式
@chainable | [
"解除事件绑定"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L644-L663 | train | Remove all event handlers | [
30522,
3853,
1006,
2171,
1010,
17324,
1010,
14931,
2595,
1007,
1063,
13075,
2824,
1027,
2023,
1012,
1035,
2824,
1025,
2065,
1006,
999,
2824,
1007,
1063,
2709,
2023,
1025,
1065,
2065,
1006,
999,
2171,
1004,
1004,
999,
17324,
1004,
1004,
30... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nodejs/node-gyp | lib/process-release.js | processRelease | function processRelease (argv, gyp, defaultVersion, defaultRelease) {
var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion
, versionSemver = semver.parse(version)
, overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl
, isDefaultVersion
, name
, distBaseUrl
, baseUrl
, libUrl32
, libUrl64
, tarballUrl
, canGetHeaders
if (!versionSemver) {
// not a valid semver string, nothing we can do
return { version: version }
}
// flatten version into String
version = versionSemver.version
// defaultVersion should come from process.version so ought to be valid semver
isDefaultVersion = version === semver.parse(defaultVersion).version
// can't use process.release if we're using --target=x.y.z
if (!isDefaultVersion)
defaultRelease = null
if (defaultRelease) {
// v3 onward, has process.release
name = defaultRelease.name
} else {
// old node or alternative --target=
// semver.satisfies() doesn't like prerelease tags so test major directly
name = 'node'
}
// check for the nvm.sh standard mirror env variables
if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR)
overrideDistUrl = process.env.NODEJS_ORG_MIRROR
if (overrideDistUrl)
log.verbose('download', 'using dist-url', overrideDistUrl)
if (overrideDistUrl)
distBaseUrl = overrideDistUrl.replace(/\/+$/, '')
else
distBaseUrl = 'https://nodejs.org/dist'
distBaseUrl += '/v' + version + '/'
// new style, based on process.release so we have a lot of the data we need
if (defaultRelease && defaultRelease.headersUrl && !overrideDistUrl) {
baseUrl = url.resolve(defaultRelease.headersUrl, './')
libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x64', versionSemver.major)
tarballUrl = defaultRelease.headersUrl
} else {
// older versions without process.release are captured here and we have to make
// a lot of assumptions, additionally if you --target=x.y.z then we can't use the
// current process.release
baseUrl = distBaseUrl
libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major)
// making the bold assumption that anything with a version number >3.0.0 will
// have a *-headers.tar.gz file in its dist location, even some frankenstein
// custom version
canGetHeaders = semver.satisfies(versionSemver, headersTarballRange)
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz')
}
return {
version: version,
semver: versionSemver,
name: name,
baseUrl: baseUrl,
tarballUrl: tarballUrl,
shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'),
versionDir: (name !== 'node' ? name + '-' : '') + version,
libUrl32: libUrl32,
libUrl64: libUrl64,
libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)),
libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path))
}
} | javascript | function processRelease (argv, gyp, defaultVersion, defaultRelease) {
var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion
, versionSemver = semver.parse(version)
, overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl
, isDefaultVersion
, name
, distBaseUrl
, baseUrl
, libUrl32
, libUrl64
, tarballUrl
, canGetHeaders
if (!versionSemver) {
// not a valid semver string, nothing we can do
return { version: version }
}
// flatten version into String
version = versionSemver.version
// defaultVersion should come from process.version so ought to be valid semver
isDefaultVersion = version === semver.parse(defaultVersion).version
// can't use process.release if we're using --target=x.y.z
if (!isDefaultVersion)
defaultRelease = null
if (defaultRelease) {
// v3 onward, has process.release
name = defaultRelease.name
} else {
// old node or alternative --target=
// semver.satisfies() doesn't like prerelease tags so test major directly
name = 'node'
}
// check for the nvm.sh standard mirror env variables
if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR)
overrideDistUrl = process.env.NODEJS_ORG_MIRROR
if (overrideDistUrl)
log.verbose('download', 'using dist-url', overrideDistUrl)
if (overrideDistUrl)
distBaseUrl = overrideDistUrl.replace(/\/+$/, '')
else
distBaseUrl = 'https://nodejs.org/dist'
distBaseUrl += '/v' + version + '/'
// new style, based on process.release so we have a lot of the data we need
if (defaultRelease && defaultRelease.headersUrl && !overrideDistUrl) {
baseUrl = url.resolve(defaultRelease.headersUrl, './')
libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x64', versionSemver.major)
tarballUrl = defaultRelease.headersUrl
} else {
// older versions without process.release are captured here and we have to make
// a lot of assumptions, additionally if you --target=x.y.z then we can't use the
// current process.release
baseUrl = distBaseUrl
libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major)
libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major)
// making the bold assumption that anything with a version number >3.0.0 will
// have a *-headers.tar.gz file in its dist location, even some frankenstein
// custom version
canGetHeaders = semver.satisfies(versionSemver, headersTarballRange)
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (canGetHeaders ? '-headers' : '') + '.tar.gz')
}
return {
version: version,
semver: versionSemver,
name: name,
baseUrl: baseUrl,
tarballUrl: tarballUrl,
shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'),
versionDir: (name !== 'node' ? name + '-' : '') + version,
libUrl32: libUrl32,
libUrl64: libUrl64,
libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)),
libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path))
}
} | [
"function",
"processRelease",
"(",
"argv",
",",
"gyp",
",",
"defaultVersion",
",",
"defaultRelease",
")",
"{",
"var",
"version",
"=",
"(",
"semver",
".",
"valid",
"(",
"argv",
"[",
"0",
"]",
")",
"&&",
"argv",
"[",
"0",
"]",
")",
"||",
"gyp",
".",
... | Captures all the logic required to determine download URLs, local directory and file names. Inputs come from command-line switches (--target, --dist-url), `process.version` and `process.release` where it exists. | [
"Captures",
"all",
"the",
"logic",
"required",
"to",
"determine",
"download",
"URLs",
"local",
"directory",
"and",
"file",
"names",
".",
"Inputs",
"come",
"from",
"command",
"-",
"line",
"switches",
"(",
"--",
"target",
"--",
"dist",
"-",
"url",
")",
"proc... | 721eb691cf15556cc2700eda0558d5bad5f84232 | https://github.com/nodejs/node-gyp/blob/721eb691cf15556cc2700eda0558d5bad5f84232/lib/process-release.js#L15-L98 | train | processRelease - process the release | [
30522,
3853,
2832,
16570,
19500,
1006,
12098,
2290,
2615,
1010,
1043,
22571,
1010,
12398,
27774,
1010,
12398,
30524,
1014,
1033,
1007,
1004,
1004,
12098,
2290,
2615,
1031,
1014,
1033,
1007,
1064,
1064,
1043,
22571,
1012,
23569,
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... |
dcloudio/mui | examples/hello-mui/js/beecloud.js | getPayChannel | function getPayChannel(bc_channel) {
var dc_channel_id = '';
switch (bc_channel) {
case 'ALI_APP':
dc_channel_id = 'alipay';
break;
case 'WX_APP':
dc_channel_id = 'wxpay';
break;
default:
break;
}
for (var i in channels) {
if (channels[i].id == dc_channel_id) {
return channels[i];
}
}
return null;
} | javascript | function getPayChannel(bc_channel) {
var dc_channel_id = '';
switch (bc_channel) {
case 'ALI_APP':
dc_channel_id = 'alipay';
break;
case 'WX_APP':
dc_channel_id = 'wxpay';
break;
default:
break;
}
for (var i in channels) {
if (channels[i].id == dc_channel_id) {
return channels[i];
}
}
return null;
} | [
"function",
"getPayChannel",
"(",
"bc_channel",
")",
"{",
"var",
"dc_channel_id",
"=",
"''",
";",
"switch",
"(",
"bc_channel",
")",
"{",
"case",
"'ALI_APP'",
":",
"dc_channel_id",
"=",
"'alipay'",
";",
"break",
";",
"case",
"'WX_APP'",
":",
"dc_channel_id",
... | 获取支付通道 | [
"获取支付通道"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/beecloud.js#L60-L79 | train | Get the channel object | [
30522,
3853,
2131,
4502,
17994,
20147,
2140,
1006,
4647,
1035,
3149,
1007,
1063,
13075,
5887,
1035,
3149,
1035,
8909,
1027,
1005,
1005,
1025,
6942,
1006,
4647,
1035,
3149,
1007,
1063,
2553,
1005,
4862,
1035,
10439,
1005,
1024,
5887,
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... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/dom-utils.js | nodeCollector | function nodeCollector(aRoot) {
this._root = aRoot.wrappedJSObject ? aRoot.wrappedJSObject : aRoot;
this._document = this._root.ownerDocument ? this._root.ownerDocument : this._root;
this._nodes = [ ];
} | javascript | function nodeCollector(aRoot) {
this._root = aRoot.wrappedJSObject ? aRoot.wrappedJSObject : aRoot;
this._document = this._root.ownerDocument ? this._root.ownerDocument : this._root;
this._nodes = [ ];
} | [
"function",
"nodeCollector",
"(",
"aRoot",
")",
"{",
"this",
".",
"_root",
"=",
"aRoot",
".",
"wrappedJSObject",
"?",
"aRoot",
".",
"wrappedJSObject",
":",
"aRoot",
";",
"this",
".",
"_document",
"=",
"this",
".",
"_root",
".",
"ownerDocument",
"?",
"this"... | Default constructor
@param {object} aRoot
Root node in the DOM to use as parent | [
"Default",
"constructor"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L478-L482 | train | Node collector | [
30522,
3853,
13045,
26895,
22471,
2953,
1006,
12098,
17206,
1007,
1063,
2023,
1012,
1035,
7117,
1027,
12098,
17206,
1012,
5058,
22578,
16429,
20614,
1029,
12098,
17206,
1012,
5058,
22578,
16429,
20614,
1024,
12098,
17206,
1025,
2023,
1012,
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... |
GitbookIO/gitbook | lib/api/encodeGlobal.js | function(type, text) {
var parser = parsers.get(type);
return parser.parsePage(text)
.get('content');
} | javascript | function(type, text) {
var parser = parsers.get(type);
return parser.parsePage(text)
.get('content');
} | [
"function",
"(",
"type",
",",
"text",
")",
"{",
"var",
"parser",
"=",
"parsers",
".",
"get",
"(",
"type",
")",
";",
"return",
"parser",
".",
"parsePage",
"(",
"text",
")",
".",
"get",
"(",
"'content'",
")",
";",
"}"
] | Render a block of text (markdown/asciidoc)
@param {String} type
@param {String} text
@return {Promise<String>} | [
"Render",
"a",
"block",
"of",
"text",
"(",
"markdown",
"/",
"asciidoc",
")"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeGlobal.js#L106-L111 | train | Parse a page | [
30522,
3853,
1006,
2828,
1010,
3793,
1007,
1063,
13075,
11968,
8043,
1027,
11968,
8043,
2015,
1012,
2131,
1006,
2828,
1007,
1025,
2709,
11968,
8043,
1012,
11968,
3366,
13704,
1006,
3793,
1007,
1012,
2131,
1006,
1005,
4180,
1005,
1007,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js | steps | function steps(sRelativePath, vNewLocation) {
var bContinue;
if (vLocation) {
return log(WARNING, "Invalid recursion");
}
vLocation = vNewLocation;
bInsideAnnotation = false;
bODataMode = true;
vResult = mScope;
bContinue = sRelativePath.split("/").every(step);
vLocation = undefined;
return bContinue;
} | javascript | function steps(sRelativePath, vNewLocation) {
var bContinue;
if (vLocation) {
return log(WARNING, "Invalid recursion");
}
vLocation = vNewLocation;
bInsideAnnotation = false;
bODataMode = true;
vResult = mScope;
bContinue = sRelativePath.split("/").every(step);
vLocation = undefined;
return bContinue;
} | [
"function",
"steps",
"(",
"sRelativePath",
",",
"vNewLocation",
")",
"{",
"var",
"bContinue",
";",
"if",
"(",
"vLocation",
")",
"{",
"return",
"log",
"(",
"WARNING",
",",
"\"Invalid recursion\"",
")",
";",
"}",
"vLocation",
"=",
"vNewLocation",
";",
"bInside... | /*
Takes multiple steps according to the given relative path, starting at the global
scope and changing <code>vResult</code>.
@param {string} sRelativePath
Some relative path (semantically, it is absolute as we start at the global scope,
but it does not begin with a slash!)
@param {string[]} [vNewLocation]
List of segments up to the point where the relative path has been found (in case
of indirection)
@returns {boolean}
Whether to continue after all steps | [
"/",
"*",
"Takes",
"multiple",
"steps",
"according",
"to",
"the",
"given",
"relative",
"path",
"starting",
"at",
"the",
"global",
"scope",
"and",
"changing",
"<code",
">",
"vResult<",
"/",
"code",
">",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataMetaModel.js#L1396-L1411 | train | Recursively walks through the path and returns true if all steps are done | [
30522,
3853,
4084,
1006,
5034,
10581,
6024,
15069,
1010,
1058,
2638,
13668,
23909,
1007,
1063,
13075,
4647,
12162,
2378,
5657,
1025,
2065,
1006,
1058,
4135,
10719,
1007,
1063,
2709,
8833,
1006,
5432,
1010,
1000,
19528,
28667,
9236,
3258,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/SVGCodeHints/main.js | getTagAttributes | function getTagAttributes(tagName) {
var tag;
if (!cachedAttributes.hasOwnProperty(tagName)) {
tag = tagData.tags[tagName];
cachedAttributes[tagName] = [];
if (tag.attributes) {
cachedAttributes[tagName] = cachedAttributes[tagName].concat(tag.attributes);
}
tag.attributeGroups.forEach(function (group) {
if (tagData.attributeGroups.hasOwnProperty(group)) {
cachedAttributes[tagName] = cachedAttributes[tagName].concat(tagData.attributeGroups[group]);
}
});
cachedAttributes[tagName] = _.uniq(cachedAttributes[tagName].sort(), true);
}
return cachedAttributes[tagName];
} | javascript | function getTagAttributes(tagName) {
var tag;
if (!cachedAttributes.hasOwnProperty(tagName)) {
tag = tagData.tags[tagName];
cachedAttributes[tagName] = [];
if (tag.attributes) {
cachedAttributes[tagName] = cachedAttributes[tagName].concat(tag.attributes);
}
tag.attributeGroups.forEach(function (group) {
if (tagData.attributeGroups.hasOwnProperty(group)) {
cachedAttributes[tagName] = cachedAttributes[tagName].concat(tagData.attributeGroups[group]);
}
});
cachedAttributes[tagName] = _.uniq(cachedAttributes[tagName].sort(), true);
}
return cachedAttributes[tagName];
} | [
"function",
"getTagAttributes",
"(",
"tagName",
")",
"{",
"var",
"tag",
";",
"if",
"(",
"!",
"cachedAttributes",
".",
"hasOwnProperty",
"(",
"tagName",
")",
")",
"{",
"tag",
"=",
"tagData",
".",
"tags",
"[",
"tagName",
"]",
";",
"cachedAttributes",
"[",
... | Returns a list of attributes used by a tag.
@param {string} tagName name of the SVG tag.
@return {Array.<string>} list of attributes. | [
"Returns",
"a",
"list",
"of",
"attributes",
"used",
"by",
"a",
"tag",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/SVGCodeHints/main.js#L76-L93 | train | Get tag attributes | [
30522,
3853,
2131,
15900,
19321,
3089,
8569,
4570,
1006,
6415,
18442,
1007,
1063,
13075,
6415,
1025,
2065,
1006,
999,
17053,
2850,
4779,
3089,
8569,
4570,
1012,
2038,
12384,
21572,
4842,
3723,
1006,
6415,
18442,
1007,
1007,
1063,
6415,
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... |
adobe/brackets | src/language/CodeInspection.js | toggleEnabled | function toggleEnabled(enabled, doNotSave) {
if (enabled === undefined) {
enabled = !_enabled;
}
// Take no action when there is no change.
if (enabled === _enabled) {
return;
}
_enabled = enabled;
CommandManager.get(Commands.VIEW_TOGGLE_INSPECTION).setChecked(_enabled);
updateListeners();
if (!doNotSave) {
prefs.set(PREF_ENABLED, _enabled);
prefs.save();
}
// run immediately
run();
} | javascript | function toggleEnabled(enabled, doNotSave) {
if (enabled === undefined) {
enabled = !_enabled;
}
// Take no action when there is no change.
if (enabled === _enabled) {
return;
}
_enabled = enabled;
CommandManager.get(Commands.VIEW_TOGGLE_INSPECTION).setChecked(_enabled);
updateListeners();
if (!doNotSave) {
prefs.set(PREF_ENABLED, _enabled);
prefs.save();
}
// run immediately
run();
} | [
"function",
"toggleEnabled",
"(",
"enabled",
",",
"doNotSave",
")",
"{",
"if",
"(",
"enabled",
"===",
"undefined",
")",
"{",
"enabled",
"=",
"!",
"_enabled",
";",
"}",
"// Take no action when there is no change.",
"if",
"(",
"enabled",
"===",
"_enabled",
")",
... | Enable or disable all inspection.
@param {?boolean} enabled Enabled state. If omitted, the state is toggled.
@param {?boolean} doNotSave true if the preference should not be saved to user settings. This is generally for events triggered by project-level settings. | [
"Enable",
"or",
"disable",
"all",
"inspection",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CodeInspection.js#L560-L581 | train | Toggle the enabled flag of the assessment. | [
30522,
3853,
2000,
24679,
8189,
23242,
1006,
9124,
1010,
2123,
12868,
10696,
1007,
1063,
2065,
1006,
9124,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
9124,
1027,
999,
1035,
9124,
1025,
1065,
1013,
1013,
2202,
2053,
2895,
2043,
2045,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ApiMaster.controller.js | function (event) {
var sTopicId = decodeURIComponent(event.getParameter("arguments").id) || event.getParameter("name");
try {
this.showMasterSide();
} catch (e) {
// try-catch due to a bug in UI5 SplitApp, CL 1898264 should fix it
Log.error(e);
}
// Expand tree node when the data is loaded
this._oDataLoadedPromise.then(function () {
this._expandTreeToNode(sTopicId, this._oTreeModel);
}.bind(this));
} | javascript | function (event) {
var sTopicId = decodeURIComponent(event.getParameter("arguments").id) || event.getParameter("name");
try {
this.showMasterSide();
} catch (e) {
// try-catch due to a bug in UI5 SplitApp, CL 1898264 should fix it
Log.error(e);
}
// Expand tree node when the data is loaded
this._oDataLoadedPromise.then(function () {
this._expandTreeToNode(sTopicId, this._oTreeModel);
}.bind(this));
} | [
"function",
"(",
"event",
")",
"{",
"var",
"sTopicId",
"=",
"decodeURIComponent",
"(",
"event",
".",
"getParameter",
"(",
"\"arguments\"",
")",
".",
"id",
")",
"||",
"event",
".",
"getParameter",
"(",
"\"name\"",
")",
";",
"try",
"{",
"this",
".",
"showM... | /* =========================================================== /* begin: internal methods /* ===========================================================
Handles "apiId" routing
@function
@param {sap.ui.base.Event} event pattern match event in route 'apiId'
@private | [
"/",
"*",
"===========================================================",
"/",
"*",
"begin",
":",
"internal",
"methods",
"/",
"*",
"===========================================================",
"Handles",
"apiId",
"routing"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/ApiMaster.controller.js#L123-L137 | train | Called when the topic is clicked | [
30522,
3853,
1006,
2724,
1007,
1063,
13075,
2644,
28775,
2094,
1027,
21933,
3207,
9496,
9006,
29513,
3372,
1006,
2724,
1012,
2131,
28689,
22828,
1006,
1000,
9918,
1000,
1007,
1012,
8909,
1007,
1064,
1064,
2724,
1012,
2131,
28689,
22828,
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/prefer-reflect.js | report | function report(node, existing, substitute) {
context.report({
node,
message: "Avoid using {{existing}}, instead use {{substitute}}.",
data: {
existing,
substitute
}
});
} | javascript | function report(node, existing, substitute) {
context.report({
node,
message: "Avoid using {{existing}}, instead use {{substitute}}.",
data: {
existing,
substitute
}
});
} | [
"function",
"report",
"(",
"node",
",",
"existing",
",",
"substitute",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"Avoid using {{existing}}, instead use {{substitute}}.\"",
",",
"data",
":",
"{",
"existing",
",",
"substitute",
"... | Reports the Reflect violation based on the `existing` and `substitute`
@param {Object} node The node that violates the rule.
@param {string} existing The existing method name that has been used.
@param {string} substitute The Reflect substitute that should be used.
@returns {void} | [
"Reports",
"the",
"Reflect",
"violation",
"based",
"on",
"the",
"existing",
"and",
"substitute"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-reflect.js#L89-L98 | train | Report an error for a node. | [
30522,
3853,
3189,
1006,
13045,
1010,
4493,
1010,
7681,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
4471,
1024,
1000,
4468,
2478,
1063,
1063,
4493,
1065,
1065,
1010,
2612,
2224,
1063,
1063,
7681,
1065,
1065,
1012,
1000,
1010,
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... |
pouchdb/pouchdb | docs/static/js/code.js | codeWrap | function codeWrap(){
"use strict";
var DEFAULT_TYPE = 'promise';
var $codes = $('[data-code-id]').get();
var codeIds =
$codes
.map(function(div){
return div.attributes["data-code-id"].value
})
.filter(function(item, index, inputArray){
// Each code block has multiple versions so let's only grab one.
return inputArray.indexOf(item) == index;
});
wrap();
setAll();
$('[data-code-tablist] [href]').on('click', function(e){
var href = $(this).attr('href');
setAll(href.replace('#', ''));
setEqualHeights();
e.preventDefault();
});
function wrap(){
var codeTpl = '' +
'<ul class="nav nav-tabs nav-code" data-code-tablist="{{codeId}}">' +
'<li>' +
'<a href="#async">Async functions</a>' +
'</li>' +
'<li class="active">' +
'<a href="#promise">Promises</a>' +
'</li>' +
'<li>' +
'<a href="#callback">Callbacks</a>' +
'</li>' +
'</ul>' +
'<div class="tab-content">{{tapPanes}}</div>';
codeIds
.forEach(function(id){
var $code = $("[data-code-id='" + id + "']");
var paneHtml = $code.get().map(function(div){
return div.outerHTML;
}).join('');
var codeHtml = codeTpl
.replace(/{{tapPanes}}/g, paneHtml)
.replace(/{{codeId}}/g, id);
$code
.first()
.replaceWith(codeHtml);
$code.remove();
});
// Remove items that are only useful for non-JS users.
$('[data-code-hide]').addClass('hide');
}
function setAll(type){
// We default to callback so no need to do anything the first time.
var firstTime = !localStorage.getItem('codeStyle');
if(firstTime){
localStorage.setItem('codeStyle', DEFAULT_TYPE);
}
type = type || localStorage.getItem('codeStyle');
if(typeof type === "undefined" || type === null) {
return;
}
var $tablist = $('[data-code-tablist] [href="#' + type + '"]').parent();
$('[data-code-tablist] li').removeClass('active');
$tablist.addClass('active');
$('.tab-pane').removeClass('active');
$('.tab-pane[id="' + type + '"]').addClass('active');
localStorage.setItem('codeStyle', type);
}
var setHeights = [];
function setEqualHeights(){
if(setHeights.length > 0){
return;
}
codeIds
.forEach(function(id){
var $code = $("[data-code-id='" + id + "']");
var paneHeight = 0;
$code.get().forEach(function(div){
var originalDisplay = div.style.display;
div.style.display = 'block';
var clientHeight = div.clientHeight;
div.style.display = originalDisplay;
if(clientHeight > paneHeight){
paneHeight = clientHeight;
}
});
$code.find('pre').css('height', paneHeight);
setHeights.push(id);
});
}
} | javascript | function codeWrap(){
"use strict";
var DEFAULT_TYPE = 'promise';
var $codes = $('[data-code-id]').get();
var codeIds =
$codes
.map(function(div){
return div.attributes["data-code-id"].value
})
.filter(function(item, index, inputArray){
// Each code block has multiple versions so let's only grab one.
return inputArray.indexOf(item) == index;
});
wrap();
setAll();
$('[data-code-tablist] [href]').on('click', function(e){
var href = $(this).attr('href');
setAll(href.replace('#', ''));
setEqualHeights();
e.preventDefault();
});
function wrap(){
var codeTpl = '' +
'<ul class="nav nav-tabs nav-code" data-code-tablist="{{codeId}}">' +
'<li>' +
'<a href="#async">Async functions</a>' +
'</li>' +
'<li class="active">' +
'<a href="#promise">Promises</a>' +
'</li>' +
'<li>' +
'<a href="#callback">Callbacks</a>' +
'</li>' +
'</ul>' +
'<div class="tab-content">{{tapPanes}}</div>';
codeIds
.forEach(function(id){
var $code = $("[data-code-id='" + id + "']");
var paneHtml = $code.get().map(function(div){
return div.outerHTML;
}).join('');
var codeHtml = codeTpl
.replace(/{{tapPanes}}/g, paneHtml)
.replace(/{{codeId}}/g, id);
$code
.first()
.replaceWith(codeHtml);
$code.remove();
});
// Remove items that are only useful for non-JS users.
$('[data-code-hide]').addClass('hide');
}
function setAll(type){
// We default to callback so no need to do anything the first time.
var firstTime = !localStorage.getItem('codeStyle');
if(firstTime){
localStorage.setItem('codeStyle', DEFAULT_TYPE);
}
type = type || localStorage.getItem('codeStyle');
if(typeof type === "undefined" || type === null) {
return;
}
var $tablist = $('[data-code-tablist] [href="#' + type + '"]').parent();
$('[data-code-tablist] li').removeClass('active');
$tablist.addClass('active');
$('.tab-pane').removeClass('active');
$('.tab-pane[id="' + type + '"]').addClass('active');
localStorage.setItem('codeStyle', type);
}
var setHeights = [];
function setEqualHeights(){
if(setHeights.length > 0){
return;
}
codeIds
.forEach(function(id){
var $code = $("[data-code-id='" + id + "']");
var paneHeight = 0;
$code.get().forEach(function(div){
var originalDisplay = div.style.display;
div.style.display = 'block';
var clientHeight = div.clientHeight;
div.style.display = originalDisplay;
if(clientHeight > paneHeight){
paneHeight = clientHeight;
}
});
$code.find('pre').css('height', paneHeight);
setHeights.push(id);
});
}
} | [
"function",
"codeWrap",
"(",
")",
"{",
"\"use strict\"",
";",
"var",
"DEFAULT_TYPE",
"=",
"'promise'",
";",
"var",
"$codes",
"=",
"$",
"(",
"'[data-code-id]'",
")",
".",
"get",
"(",
")",
";",
"var",
"codeIds",
"=",
"$codes",
".",
"map",
"(",
"function",
... | /* jshint jquery: true | [
"/",
"*",
"jshint",
"jquery",
":",
"true"
] | 858660e9b37959d96eebf667ea9b8b1273f0d62c | https://github.com/pouchdb/pouchdb/blob/858660e9b37959d96eebf667ea9b8b1273f0d62c/docs/static/js/code.js#L3-L114 | train | Wrap the code block | [
30522,
3853,
3642,
13088,
9331,
1006,
1007,
1063,
1000,
2224,
9384,
1000,
1025,
13075,
12398,
1035,
2828,
1027,
1005,
4872,
1005,
1025,
13075,
1002,
9537,
1027,
1002,
1006,
1005,
1031,
2951,
1011,
3642,
1011,
8909,
1033,
1005,
1007,
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... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (matched)
{
var i;
// Sorting matched mechanisms according to priority.
for (i = 0; i < matched.length - 1; ++i) {
var higher = i;
for (var j = i + 1; j < matched.length; ++j) {
if (matched[j].prototype.priority > matched[higher].prototype.priority) {
higher = j;
}
}
if (higher != i) {
var swap = matched[i];
matched[i] = matched[higher];
matched[higher] = swap;
}
}
// run each mechanism
var mechanism_found = false;
for (i = 0; i < matched.length; ++i) {
if (!matched[i].test(this)) continue;
this._sasl_success_handler = this._addSysHandler(
this._sasl_success_cb.bind(this), null,
"success", null, null);
this._sasl_failure_handler = this._addSysHandler(
this._sasl_failure_cb.bind(this), null,
"failure", null, null);
this._sasl_challenge_handler = this._addSysHandler(
this._sasl_challenge_cb.bind(this), null,
"challenge", null, null);
this._sasl_mechanism = new matched[i]();
this._sasl_mechanism.onStart(this);
var request_auth_exchange = $build("auth", {
xmlns: Strophe.NS.SASL,
mechanism: this._sasl_mechanism.name
});
if (this._sasl_mechanism.isClientFirst) {
var response = this._sasl_mechanism.onChallenge(this, null);
request_auth_exchange.t(Base64.encode(response));
}
this.send(request_auth_exchange.tree());
mechanism_found = true;
break;
}
if (!mechanism_found) {
// if none of the mechanism worked
if (Strophe.getNodeFromJid(this.jid) === null) {
// we don't have a node, which is required for non-anonymous
// client connections
this._changeConnectStatus(Strophe.Status.CONNFAIL,
'x-strophe-bad-non-anon-jid');
this.disconnect('x-strophe-bad-non-anon-jid');
} else {
// fall back to legacy authentication
this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null);
this._addSysHandler(this._auth1_cb.bind(this), null, null,
null, "_auth_1");
this.send($iq({
type: "get",
to: this.domain,
id: "_auth_1"
}).c("query", {
xmlns: Strophe.NS.AUTH
}).c("username", {}).t(Strophe.getNodeFromJid(this.jid)).tree());
}
}
} | javascript | function (matched)
{
var i;
// Sorting matched mechanisms according to priority.
for (i = 0; i < matched.length - 1; ++i) {
var higher = i;
for (var j = i + 1; j < matched.length; ++j) {
if (matched[j].prototype.priority > matched[higher].prototype.priority) {
higher = j;
}
}
if (higher != i) {
var swap = matched[i];
matched[i] = matched[higher];
matched[higher] = swap;
}
}
// run each mechanism
var mechanism_found = false;
for (i = 0; i < matched.length; ++i) {
if (!matched[i].test(this)) continue;
this._sasl_success_handler = this._addSysHandler(
this._sasl_success_cb.bind(this), null,
"success", null, null);
this._sasl_failure_handler = this._addSysHandler(
this._sasl_failure_cb.bind(this), null,
"failure", null, null);
this._sasl_challenge_handler = this._addSysHandler(
this._sasl_challenge_cb.bind(this), null,
"challenge", null, null);
this._sasl_mechanism = new matched[i]();
this._sasl_mechanism.onStart(this);
var request_auth_exchange = $build("auth", {
xmlns: Strophe.NS.SASL,
mechanism: this._sasl_mechanism.name
});
if (this._sasl_mechanism.isClientFirst) {
var response = this._sasl_mechanism.onChallenge(this, null);
request_auth_exchange.t(Base64.encode(response));
}
this.send(request_auth_exchange.tree());
mechanism_found = true;
break;
}
if (!mechanism_found) {
// if none of the mechanism worked
if (Strophe.getNodeFromJid(this.jid) === null) {
// we don't have a node, which is required for non-anonymous
// client connections
this._changeConnectStatus(Strophe.Status.CONNFAIL,
'x-strophe-bad-non-anon-jid');
this.disconnect('x-strophe-bad-non-anon-jid');
} else {
// fall back to legacy authentication
this._changeConnectStatus(Strophe.Status.AUTHENTICATING, null);
this._addSysHandler(this._auth1_cb.bind(this), null, null,
null, "_auth_1");
this.send($iq({
type: "get",
to: this.domain,
id: "_auth_1"
}).c("query", {
xmlns: Strophe.NS.AUTH
}).c("username", {}).t(Strophe.getNodeFromJid(this.jid)).tree());
}
}
} | [
"function",
"(",
"matched",
")",
"{",
"var",
"i",
";",
"// Sorting matched mechanisms according to priority.\r",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"matched",
".",
"length",
"-",
"1",
";",
"++",
"i",
")",
"{",
"var",
"higher",
"=",
"i",
";",
"fo... | Function: authenticate
Set up authentication
Contiunues the initial connection request by setting up authentication
handlers and start the authentication process.
SASL authentication will be attempted if available, otherwise
the code will fall back to legacy authentication. | [
"Function",
":",
"authenticate",
"Set",
"up",
"authentication"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L2992-L3068 | train | Called by the SDK to run the specified mechanism | [
30522,
3853,
1006,
10349,
1007,
1063,
13075,
1045,
1025,
1013,
1013,
22210,
10349,
10595,
2429,
2000,
9470,
1012,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
10349,
1012,
3091,
1011,
1015,
1025,
1009,
1009,
1045,
1007,
1063,
13075,
3020... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/firebaseui-web | gulpfile.js | compile | function compile(srcs, out, args) {
// Get the compiler arguments, using the defaults if not specified.
const combinedArgs = Object.assign({}, COMPILER_DEFAULT_ARGS, args);
return gulp
.src(srcs)
.pipe(closureCompiler({
compilerPath: COMPILER_PATH,
fileName: path.basename(out),
compilerFlags: combinedArgs
}))
.pipe(gulp.dest(path.dirname(out)));
} | javascript | function compile(srcs, out, args) {
// Get the compiler arguments, using the defaults if not specified.
const combinedArgs = Object.assign({}, COMPILER_DEFAULT_ARGS, args);
return gulp
.src(srcs)
.pipe(closureCompiler({
compilerPath: COMPILER_PATH,
fileName: path.basename(out),
compilerFlags: combinedArgs
}))
.pipe(gulp.dest(path.dirname(out)));
} | [
"function",
"compile",
"(",
"srcs",
",",
"out",
",",
"args",
")",
"{",
"// Get the compiler arguments, using the defaults if not specified.",
"const",
"combinedArgs",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"COMPILER_DEFAULT_ARGS",
",",
"args",
")",
";",
... | Invokes Closure Compiler.
@param {!Array<string>} srcs The JS sources to compile.
@param {string} out The path to the output JS file.
@param {!Object} args Additional arguments to Closure compiler.
@return {*} A stream that finishes when compliation finishes. | [
"Invokes",
"Closure",
"Compiler",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/gulpfile.js#L124-L135 | train | Compile the given files using the closure compiler. | [
30522,
3853,
4012,
22090,
1006,
5034,
6169,
1010,
2041,
1010,
12098,
5620,
1007,
1063,
1013,
1013,
2131,
1996,
21624,
9918,
1010,
2478,
1996,
12398,
2015,
2065,
2025,
9675,
1012,
9530,
3367,
4117,
2906,
5620,
1027,
4874,
1012,
23911,
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... |
netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/remarkEscapeMarkdownEntities.js | escapeCommonChars | function escapeCommonChars(text) {
/**
* Generate new non-escape expression (must happen at execution time because
* we use `RegExp.exec`, which tracks it's own state internally).
*/
const nonEscapeExpression = new RegExp(nonEscapePattern, 'gm');
/**
* Use `replaceWhen` to escape markdown entities only within substrings that
* are eligible for escaping.
*/
return replaceWhen(nonEscapeExpression, escapeAll, text, true);
} | javascript | function escapeCommonChars(text) {
/**
* Generate new non-escape expression (must happen at execution time because
* we use `RegExp.exec`, which tracks it's own state internally).
*/
const nonEscapeExpression = new RegExp(nonEscapePattern, 'gm');
/**
* Use `replaceWhen` to escape markdown entities only within substrings that
* are eligible for escaping.
*/
return replaceWhen(nonEscapeExpression, escapeAll, text, true);
} | [
"function",
"escapeCommonChars",
"(",
"text",
")",
"{",
"/**\n * Generate new non-escape expression (must happen at execution time because\n * we use `RegExp.exec`, which tracks it's own state internally).\n */",
"const",
"nonEscapeExpression",
"=",
"new",
"RegExp",
"(",
"nonEscapePa... | escapeCommonChars
Escapes active markdown entities. See escape pattern groups for details on
which entities are replaced. | [
"escapeCommonChars"
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/remarkEscapeMarkdownEntities.js#L180-L192 | train | Escape all common characters in text | [
30522,
3853,
4019,
9006,
8202,
7507,
2869,
1006,
3793,
1007,
1063,
1013,
1008,
1008,
1008,
9699,
2047,
2512,
1011,
4019,
3670,
1006,
2442,
4148,
2012,
7781,
2051,
2138,
1008,
2057,
2224,
1036,
19723,
10288,
2361,
1012,
4654,
8586,
1036,
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... |
facebook/relay | packages/relay-compiler/codegen/deepMergeAssignments.js | deepMergeAssignments | function deepMergeAssignments(objectName: string, properties: Object): string {
const assignments = [];
collectAssignmentsInto(assignments, [], properties);
const jsAssignments = assignments.map(({path, value}) =>
formatJSAssignment(objectName, path, value),
);
return jsAssignments.length === 0 ? '' : jsAssignments.join('\n');
} | javascript | function deepMergeAssignments(objectName: string, properties: Object): string {
const assignments = [];
collectAssignmentsInto(assignments, [], properties);
const jsAssignments = assignments.map(({path, value}) =>
formatJSAssignment(objectName, path, value),
);
return jsAssignments.length === 0 ? '' : jsAssignments.join('\n');
} | [
"function",
"deepMergeAssignments",
"(",
"objectName",
":",
"string",
",",
"properties",
":",
"Object",
")",
":",
"string",
"{",
"const",
"assignments",
"=",
"[",
"]",
";",
"collectAssignmentsInto",
"(",
"assignments",
",",
"[",
"]",
",",
"properties",
")",
... | Given a object of nested properties, return JavaScript text that would merge
in an object named `objectName` by a series of individual assignments. | [
"Given",
"a",
"object",
"of",
"nested",
"properties",
"return",
"JavaScript",
"text",
"that",
"would",
"merge",
"in",
"an",
"object",
"named",
"objectName",
"by",
"a",
"series",
"of",
"individual",
"assignments",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-compiler/codegen/deepMergeAssignments.js#L17-L24 | train | Merge all assignments into a single string | [
30522,
3853,
2784,
5017,
3351,
12054,
24838,
2015,
1006,
4874,
18442,
1024,
5164,
1010,
5144,
1024,
4874,
1007,
1024,
5164,
1063,
9530,
3367,
14799,
1027,
1031,
1033,
1025,
8145,
12054,
24838,
11493,
3406,
1006,
14799,
1010,
1031,
1033,
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... |
facebook/relay | scripts/rewrite-modules.js | mapModule | function mapModule(state, module) {
var moduleMap = state.opts.map || {};
if (moduleMap.hasOwnProperty(module)) {
return moduleMap[module];
}
// Jest understands the haste module system, so leave modules intact.
if (process.env.NODE_ENV === 'test') {
return;
}
return './' + path.basename(module);
} | javascript | function mapModule(state, module) {
var moduleMap = state.opts.map || {};
if (moduleMap.hasOwnProperty(module)) {
return moduleMap[module];
}
// Jest understands the haste module system, so leave modules intact.
if (process.env.NODE_ENV === 'test') {
return;
}
return './' + path.basename(module);
} | [
"function",
"mapModule",
"(",
"state",
",",
"module",
")",
"{",
"var",
"moduleMap",
"=",
"state",
".",
"opts",
".",
"map",
"||",
"{",
"}",
";",
"if",
"(",
"moduleMap",
".",
"hasOwnProperty",
"(",
"module",
")",
")",
"{",
"return",
"moduleMap",
"[",
"... | This file is a fork from fbjs's transform of the same name. It has been
modified to also apply to import statements, and to account for relative
file names in require statements.
Rewrites module string literals according to the `map` and `prefix` options.
This allows other npm packages to be published and used directly without
being a part of the same build. | [
"This",
"file",
"is",
"a",
"fork",
"from",
"fbjs",
"s",
"transform",
"of",
"the",
"same",
"name",
".",
"It",
"has",
"been",
"modified",
"to",
"also",
"apply",
"to",
"import",
"statements",
"and",
"to",
"account",
"for",
"relative",
"file",
"names",
"in",... | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/scripts/rewrite-modules.js#L25-L35 | train | Map a module to a relative path | [
30522,
3853,
4949,
5302,
8566,
2571,
1006,
2110,
1010,
11336,
1007,
1063,
13075,
11336,
2863,
2361,
1027,
2110,
1012,
23569,
2015,
1012,
4949,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
11336,
2863,
2361,
1012,
2038,
12384,
21572,
4842,
3723... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | decompressIndex | function decompressIndex(oIndex) {
function decompressField(sFieldName) {
var tfValues = oIndex.lunr.index[sFieldName].tfValues;
tfValues[0] = NaN; // restore NaN, JSON converts it to null
oIndex.lunr.index[sFieldName].tfValues = undefined;
function decompressArrayItemsByLength(sCompressed) {
var aDocIds = [];
sCompressed.split(",").forEach(function(sCompressedOfLength) {
var aParts = sCompressedOfLength.split(":"),
iKey = parseInt(aParts[0]),
sDocIdsOfLen = aParts[1];
while (sDocIdsOfLen.length > 0) {
aDocIds.push(sDocIdsOfLen.slice(0, iKey));
sDocIdsOfLen = sDocIdsOfLen.slice(iKey);
}
});
return aDocIds;
}
function decompressDocs(oNode) {
var oDocs = oNode.docs,
iCount = 0;
if ( oDocs === undefined ) {
oNode.docs = {};
} else {
Object.keys(oDocs).forEach(function (sDocKey) {
if ( typeof oDocs[sDocKey] === 'number' ) {
oDocs[sDocKey] = {
tf: tfValues[ oDocs[sDocKey] ]
};
}
if ( sDocKey.indexOf(':') >= 0 ) {
var aDocIds = decompressArrayItemsByLength(sDocKey);
aDocIds.forEach( function (docKeyPart) {
oDocs[docKeyPart] = oDocs[sDocKey];
iCount++;
});
oDocs[sDocKey] = undefined;
} else {
iCount++;
}
});
}
if ( oNode.df === undefined ) {
oNode.df = iCount;
}
}
function decompressIndexNode(oNode) {
decompressDocs(oNode);
Object.keys(oNode).forEach( function (sKey) {
if ( sKey !== 'docs' && sKey !== 'df' ) {
var oValue = oNode[sKey];
var iLength = sKey.length;
if ( iLength > 1 ) {
while ( --iLength > 0 ) {
var oTmp = {};
oTmp[ sKey.charAt(iLength) ] = oValue;
oValue = oTmp;
}
oNode[ sKey.charAt(0) ] = oValue;
oNode[sKey] = undefined;
}
decompressIndexNode(oValue);
}
} );
}
decompressIndexNode(oIndex.lunr.index[sFieldName].root);
}
function traverse(oNode,fnProcessNode) {
for (var i in oNode) {
fnProcessNode.apply(oNode,[i,oNode[i]]);
if (oNode[i] !== null && typeof (oNode[i]) == "object") {
//going one step down in the object tree!!
traverse(oNode[i],fnProcessNode);
}
}
}
function deleteUndefinedEntries(sKey, oValue) {
if (oValue === undefined) {
delete this[sKey];
}
}
INDEXED_FIELDS.forEach(function(sFieldName) {
decompressField(sFieldName);
});
// return a deep copy to get rid of properties with value "undefined"
traverse(oIndex, deleteUndefinedEntries);
return oIndex;
} | javascript | function decompressIndex(oIndex) {
function decompressField(sFieldName) {
var tfValues = oIndex.lunr.index[sFieldName].tfValues;
tfValues[0] = NaN; // restore NaN, JSON converts it to null
oIndex.lunr.index[sFieldName].tfValues = undefined;
function decompressArrayItemsByLength(sCompressed) {
var aDocIds = [];
sCompressed.split(",").forEach(function(sCompressedOfLength) {
var aParts = sCompressedOfLength.split(":"),
iKey = parseInt(aParts[0]),
sDocIdsOfLen = aParts[1];
while (sDocIdsOfLen.length > 0) {
aDocIds.push(sDocIdsOfLen.slice(0, iKey));
sDocIdsOfLen = sDocIdsOfLen.slice(iKey);
}
});
return aDocIds;
}
function decompressDocs(oNode) {
var oDocs = oNode.docs,
iCount = 0;
if ( oDocs === undefined ) {
oNode.docs = {};
} else {
Object.keys(oDocs).forEach(function (sDocKey) {
if ( typeof oDocs[sDocKey] === 'number' ) {
oDocs[sDocKey] = {
tf: tfValues[ oDocs[sDocKey] ]
};
}
if ( sDocKey.indexOf(':') >= 0 ) {
var aDocIds = decompressArrayItemsByLength(sDocKey);
aDocIds.forEach( function (docKeyPart) {
oDocs[docKeyPart] = oDocs[sDocKey];
iCount++;
});
oDocs[sDocKey] = undefined;
} else {
iCount++;
}
});
}
if ( oNode.df === undefined ) {
oNode.df = iCount;
}
}
function decompressIndexNode(oNode) {
decompressDocs(oNode);
Object.keys(oNode).forEach( function (sKey) {
if ( sKey !== 'docs' && sKey !== 'df' ) {
var oValue = oNode[sKey];
var iLength = sKey.length;
if ( iLength > 1 ) {
while ( --iLength > 0 ) {
var oTmp = {};
oTmp[ sKey.charAt(iLength) ] = oValue;
oValue = oTmp;
}
oNode[ sKey.charAt(0) ] = oValue;
oNode[sKey] = undefined;
}
decompressIndexNode(oValue);
}
} );
}
decompressIndexNode(oIndex.lunr.index[sFieldName].root);
}
function traverse(oNode,fnProcessNode) {
for (var i in oNode) {
fnProcessNode.apply(oNode,[i,oNode[i]]);
if (oNode[i] !== null && typeof (oNode[i]) == "object") {
//going one step down in the object tree!!
traverse(oNode[i],fnProcessNode);
}
}
}
function deleteUndefinedEntries(sKey, oValue) {
if (oValue === undefined) {
delete this[sKey];
}
}
INDEXED_FIELDS.forEach(function(sFieldName) {
decompressField(sFieldName);
});
// return a deep copy to get rid of properties with value "undefined"
traverse(oIndex, deleteUndefinedEntries);
return oIndex;
} | [
"function",
"decompressIndex",
"(",
"oIndex",
")",
"{",
"function",
"decompressField",
"(",
"sFieldName",
")",
"{",
"var",
"tfValues",
"=",
"oIndex",
".",
"lunr",
".",
"index",
"[",
"sFieldName",
"]",
".",
"tfValues",
";",
"tfValues",
"[",
"0",
"]",
"=",
... | Decompresses the oIndex
@param oIndex
@returns {*} | [
"Decompresses",
"the",
"oIndex"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js#L258-L357 | train | Decompresses an index. | [
30522,
3853,
21933,
8737,
8303,
22254,
10288,
1006,
1051,
22254,
10288,
1007,
1063,
3853,
21933,
8737,
8303,
3790,
1006,
16420,
12891,
18442,
1007,
1063,
13075,
1056,
2546,
10175,
15808,
1027,
1051,
22254,
10288,
1012,
11320,
16118,
1012,
595... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | src/platforms/weex/framework.js | getInstanceTimer | function getInstanceTimer (instanceId, moduleGetter) {
const instance = instances[instanceId]
const timer = moduleGetter('timer')
const timerAPIs = {
setTimeout: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setTimeout(handler, args[1])
return instance.callbackId.toString()
},
setInterval: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setInterval(handler, args[1])
return instance.callbackId.toString()
},
clearTimeout: (n) => {
timer.clearTimeout(n)
},
clearInterval: (n) => {
timer.clearInterval(n)
}
}
return timerAPIs
} | javascript | function getInstanceTimer (instanceId, moduleGetter) {
const instance = instances[instanceId]
const timer = moduleGetter('timer')
const timerAPIs = {
setTimeout: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setTimeout(handler, args[1])
return instance.callbackId.toString()
},
setInterval: (...args) => {
const handler = function () {
args[0](...args.slice(2))
}
timer.setInterval(handler, args[1])
return instance.callbackId.toString()
},
clearTimeout: (n) => {
timer.clearTimeout(n)
},
clearInterval: (n) => {
timer.clearInterval(n)
}
}
return timerAPIs
} | [
"function",
"getInstanceTimer",
"(",
"instanceId",
",",
"moduleGetter",
")",
"{",
"const",
"instance",
"=",
"instances",
"[",
"instanceId",
"]",
"const",
"timer",
"=",
"moduleGetter",
"(",
"'timer'",
")",
"const",
"timerAPIs",
"=",
"{",
"setTimeout",
":",
"(",... | Generate HTML5 Timer APIs. An important point is that the callback
will be converted into callback id when sent to native. So the
framework can make sure no side effect of the callback happened after
an instance destroyed.
@param {[type]} instanceId [description]
@param {[type]} moduleGetter [description]
@return {[type]} [description] | [
"Generate",
"HTML5",
"Timer",
"APIs",
".",
"An",
"important",
"point",
"is",
"that",
"the",
"callback",
"will",
"be",
"converted",
"into",
"callback",
"id",
"when",
"sent",
"to",
"native",
".",
"So",
"the",
"framework",
"can",
"make",
"sure",
"no",
"side",... | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/src/platforms/weex/framework.js#L323-L349 | train | Get timer APIs for a specific instance | [
30522,
3853,
2131,
7076,
26897,
7292,
2099,
1006,
6013,
3593,
1010,
11336,
18150,
3334,
1007,
1063,
9530,
3367,
6013,
1027,
12107,
1031,
6013,
3593,
1033,
9530,
3367,
25309,
1027,
11336,
18150,
3334,
1006,
1005,
25309,
1005,
1007,
9530,
336... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/virtualRepeat/virtual-repeater.js | ForceHeightDirective | function ForceHeightDirective($mdUtil) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var height = scope.$eval(attrs.mdForceHeight) || null;
if (height && element) {
element[0].style.height = height;
}
}
};
} | javascript | function ForceHeightDirective($mdUtil) {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var height = scope.$eval(attrs.mdForceHeight) || null;
if (height && element) {
element[0].style.height = height;
}
}
};
} | [
"function",
"ForceHeightDirective",
"(",
"$mdUtil",
")",
"{",
"return",
"{",
"restrict",
":",
"'A'",
",",
"link",
":",
"function",
"(",
"scope",
",",
"element",
",",
"attrs",
")",
"{",
"var",
"height",
"=",
"scope",
".",
"$eval",
"(",
"attrs",
".",
"md... | @ngdoc directive
@name mdForceHeight
@module material.components.virtualRepeat
@restrict A
@description
Force an element to have a certain `px` height. This is used in place of a style tag in order to
conform to the
<a href="https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy/script-src">
Content Security Policy</a> regarding `unsafe-inline` `<style>` tags.
This directive is related to <a ng-href="api/directive/mdVirtualRepeat">mdVirtualRepeat</a>.
@usage
<hljs lang="html">
<div md-force-height="'100px'"></div>
</hljs> | [
"@ngdoc",
"directive",
"@name",
"mdForceHeight",
"@module",
"material",
".",
"components",
".",
"virtualRepeat",
"@restrict",
"A",
"@description"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/virtualRepeat/virtual-repeater.js#L1036-L1047 | train | Force height directive | [
30522,
3853,
2486,
26036,
13900,
4305,
2890,
15277,
1006,
1002,
9108,
21823,
2140,
1007,
1063,
2709,
1063,
21573,
1024,
1005,
1037,
1005,
1010,
4957,
1024,
3853,
1006,
9531,
1010,
5783,
1010,
2012,
16344,
2015,
1007,
1063,
13075,
4578,
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... |
adobe/brackets | src/search/ScrollTrackMarkers.js | _calcScaling | function _calcScaling() {
var $sb = _getScrollbar(editor);
trackHt = $sb[0].offsetHeight;
if (trackHt > 0) {
trackOffset = getScrollbarTrackOffset();
trackHt -= trackOffset * 2;
} else {
// No scrollbar: use the height of the entire code content
var codeContainer = $(editor.getRootElement()).find("> .CodeMirror-scroll > .CodeMirror-sizer > div > .CodeMirror-lines > div")[0];
trackHt = codeContainer.offsetHeight;
trackOffset = codeContainer.offsetTop;
}
} | javascript | function _calcScaling() {
var $sb = _getScrollbar(editor);
trackHt = $sb[0].offsetHeight;
if (trackHt > 0) {
trackOffset = getScrollbarTrackOffset();
trackHt -= trackOffset * 2;
} else {
// No scrollbar: use the height of the entire code content
var codeContainer = $(editor.getRootElement()).find("> .CodeMirror-scroll > .CodeMirror-sizer > div > .CodeMirror-lines > div")[0];
trackHt = codeContainer.offsetHeight;
trackOffset = codeContainer.offsetTop;
}
} | [
"function",
"_calcScaling",
"(",
")",
"{",
"var",
"$sb",
"=",
"_getScrollbar",
"(",
"editor",
")",
";",
"trackHt",
"=",
"$sb",
"[",
"0",
"]",
".",
"offsetHeight",
";",
"if",
"(",
"trackHt",
">",
"0",
")",
"{",
"trackOffset",
"=",
"getScrollbarTrackOffset... | Measure scrollbar track | [
"Measure",
"scrollbar",
"track"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/ScrollTrackMarkers.js#L109-L123 | train | Calculates the scaling factor | [
30522,
3853,
1035,
10250,
6169,
9289,
2075,
1006,
1007,
1063,
13075,
1002,
24829,
1027,
1035,
4152,
26775,
14511,
8237,
1006,
3559,
1007,
1025,
2650,
11039,
1027,
1002,
24829,
1031,
1014,
1033,
1012,
16396,
26036,
13900,
1025,
2065,
1006,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js | function(oStep){
var bIsTopLevel = oStep.getParent() instanceof sap.ui.commons.RoadMap;
var aSteps = oStep.getParent()[bIsTopLevel ? "getSteps" : "getSubSteps"]();
var iCount = aSteps.length;
for (var i = 0; i < aSteps.length; i++) {
if (!aSteps[i].getVisible()) {
iCount--;
}
}
return iCount;
} | javascript | function(oStep){
var bIsTopLevel = oStep.getParent() instanceof sap.ui.commons.RoadMap;
var aSteps = oStep.getParent()[bIsTopLevel ? "getSteps" : "getSubSteps"]();
var iCount = aSteps.length;
for (var i = 0; i < aSteps.length; i++) {
if (!aSteps[i].getVisible()) {
iCount--;
}
}
return iCount;
} | [
"function",
"(",
"oStep",
")",
"{",
"var",
"bIsTopLevel",
"=",
"oStep",
".",
"getParent",
"(",
")",
"instanceof",
"sap",
".",
"ui",
".",
"commons",
".",
"RoadMap",
";",
"var",
"aSteps",
"=",
"oStep",
".",
"getParent",
"(",
")",
"[",
"bIsTopLevel",
"?",... | Computes how the aria-setsize property should be set for the given step | [
"Computes",
"how",
"the",
"aria",
"-",
"setsize",
"property",
"should",
"be",
"set",
"for",
"the",
"given",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/RoadMapRenderer.js#L704-L714 | train | Returns the number of steps in the given step | [
30522,
3853,
1006,
9808,
2618,
2361,
1007,
1063,
13075,
20377,
14399,
20414,
30524,
1006,
1007,
6013,
11253,
20066,
1012,
21318,
1012,
7674,
1012,
2346,
2863,
2361,
1025,
13075,
2004,
2618,
4523,
1027,
9808,
2618,
2361,
1012,
2131,
19362,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js | function (oContext) {
var sEntityType = oContext.getProperty(""),
oResult = oContext.getModel().getODataEntityType(sEntityType, true);
if (!oResult) {
Log.warning(oContext.getPath() + ": found '" + sEntityType
+ "' which is not a name of an entity type", undefined,
"sap.ui.model.odata.AnnotationHelper");
}
return oResult;
} | javascript | function (oContext) {
var sEntityType = oContext.getProperty(""),
oResult = oContext.getModel().getODataEntityType(sEntityType, true);
if (!oResult) {
Log.warning(oContext.getPath() + ": found '" + sEntityType
+ "' which is not a name of an entity type", undefined,
"sap.ui.model.odata.AnnotationHelper");
}
return oResult;
} | [
"function",
"(",
"oContext",
")",
"{",
"var",
"sEntityType",
"=",
"oContext",
".",
"getProperty",
"(",
"\"\"",
")",
",",
"oResult",
"=",
"oContext",
".",
"getModel",
"(",
")",
".",
"getODataEntityType",
"(",
"sEntityType",
",",
"true",
")",
";",
"if",
"(... | Helper function for a <code>template:with</code> instruction that goes to the
entity type with the qualified name which <code>oContext</code> points at.
Example: Assume that "entitySet" refers to an entity set within an OData meta model;
the helper function is then called on the "entityType" property of that entity set
(which holds the qualified name of the entity type) and in turn the path of that
entity type is assigned to the variable "entityType".
<pre>
<template:with path="entitySet>entityType" helper="sap.ui.model.odata.AnnotationHelper.gotoEntityType" var="entityType">
</pre>
@param {sap.ui.model.Context} oContext
a context which must point to the qualified name of an entity type;
the context's model must be an {@link sap.ui.model.odata.ODataMetaModel}
@returns {string}
the path to the entity type with the given qualified name,
or <code>undefined</code> if no such type is found. In this case, a warning is
logged to the console.
@public | [
"Helper",
"function",
"for",
"a",
"<code",
">",
"template",
":",
"with<",
"/",
"code",
">",
"instruction",
"that",
"goes",
"to",
"the",
"entity",
"type",
"with",
"the",
"qualified",
"name",
"which",
"<code",
">",
"oContext<",
"/",
"code",
">",
"points",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/AnnotationHelper.js#L418-L429 | train | Returns the entity type of the given context | [
30522,
3853,
1006,
1051,
8663,
18209,
1007,
30524,
1007,
1010,
10848,
23722,
2102,
1027,
1051,
8663,
18209,
1012,
2131,
5302,
9247,
1006,
1007,
1012,
2131,
13390,
2696,
4765,
3012,
13874,
1006,
2741,
3012,
13874,
1010,
2995,
1007,
1025,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.rta/src/sap/ui/rta/ControlTreeModifier.js | function (oControl, sPropertyName) {
var mOldBindingInfos = oControl.getBindingInfo(sPropertyName);
JsControlTreeModifier.unbindProperty.apply(this, arguments);
if (mOldBindingInfos){
this._saveUndoOperation("bindProperty", [oControl, sPropertyName, mOldBindingInfos]);
}
} | javascript | function (oControl, sPropertyName) {
var mOldBindingInfos = oControl.getBindingInfo(sPropertyName);
JsControlTreeModifier.unbindProperty.apply(this, arguments);
if (mOldBindingInfos){
this._saveUndoOperation("bindProperty", [oControl, sPropertyName, mOldBindingInfos]);
}
} | [
"function",
"(",
"oControl",
",",
"sPropertyName",
")",
"{",
"var",
"mOldBindingInfos",
"=",
"oControl",
".",
"getBindingInfo",
"(",
"sPropertyName",
")",
";",
"JsControlTreeModifier",
".",
"unbindProperty",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",... | Unbind a property and record bindProperty as undo operation
@param {sap.ui.core.Control} oControl The control containing the property
@param {string} sPropertyName The property to be unbound | [
"Unbind",
"a",
"property",
"and",
"record",
"bindProperty",
"as",
"undo",
"operation"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/ControlTreeModifier.js#L150-L158 | train | Unbinds a property from the control tree. | [
30522,
3853,
1006,
1051,
8663,
13181,
2140,
1010,
11867,
18981,
15010,
18442,
1007,
1063,
13075,
18282,
8428,
4667,
2378,
14876,
2015,
1027,
1051,
8663,
13181,
2140,
1012,
2131,
8428,
4667,
2378,
14876,
1006,
11867,
18981,
15010,
18442,
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... | |
SheetJS/js-xlsx | bits/44_offcrypto.js | parse_EncryptionVerifier | function parse_EncryptionVerifier(blob, length/*:number*/) {
var o = {}, tgt = blob.l + length;
blob.l += 4; // SaltSize must be 0x10
o.Salt = blob.slice(blob.l, blob.l+16); blob.l += 16;
o.Verifier = blob.slice(blob.l, blob.l+16); blob.l += 16;
/*var sz = */blob.read_shift(4);
o.VerifierHash = blob.slice(blob.l, tgt); blob.l = tgt;
return o;
} | javascript | function parse_EncryptionVerifier(blob, length/*:number*/) {
var o = {}, tgt = blob.l + length;
blob.l += 4; // SaltSize must be 0x10
o.Salt = blob.slice(blob.l, blob.l+16); blob.l += 16;
o.Verifier = blob.slice(blob.l, blob.l+16); blob.l += 16;
/*var sz = */blob.read_shift(4);
o.VerifierHash = blob.slice(blob.l, tgt); blob.l = tgt;
return o;
} | [
"function",
"parse_EncryptionVerifier",
"(",
"blob",
",",
"length",
"/*:number*/",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"tgt",
"=",
"blob",
".",
"l",
"+",
"length",
";",
"blob",
".",
"l",
"+=",
"4",
";",
"// SaltSize must be 0x10",
"o",
".",
"Salt... | /* [MS-OFFCRYPTO] 2.3.3 Encryption Verifier | [
"/",
"*",
"[",
"MS",
"-",
"OFFCRYPTO",
"]",
"2",
".",
"3",
".",
"3",
"Encryption",
"Verifier"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/44_offcrypto.js#L110-L118 | train | Parse the Encryption Verifier | [
30522,
3853,
11968,
3366,
1035,
21999,
6299,
18095,
1006,
1038,
4135,
2497,
1010,
3091,
1013,
1008,
1024,
2193,
1008,
1013,
1007,
1063,
13075,
1051,
1027,
1063,
1065,
1010,
1056,
13512,
1027,
1038,
4135,
2497,
1012,
1048,
1009,
3091,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/utils/DeprecationWarning.js | deprecateConstant | function deprecateConstant(obj, oldId, newId) {
var warning = "Use Menus." + newId + " instead of Menus." + oldId,
newValue = obj[newId];
Object.defineProperty(obj, oldId, {
get: function () {
deprecationWarning(warning, true);
return newValue;
}
});
} | javascript | function deprecateConstant(obj, oldId, newId) {
var warning = "Use Menus." + newId + " instead of Menus." + oldId,
newValue = obj[newId];
Object.defineProperty(obj, oldId, {
get: function () {
deprecationWarning(warning, true);
return newValue;
}
});
} | [
"function",
"deprecateConstant",
"(",
"obj",
",",
"oldId",
",",
"newId",
")",
"{",
"var",
"warning",
"=",
"\"Use Menus.\"",
"+",
"newId",
"+",
"\" instead of Menus.\"",
"+",
"oldId",
",",
"newValue",
"=",
"obj",
"[",
"newId",
"]",
";",
"Object",
".",
"defi... | Create a deprecation warning and action for updated constants
@param {!string} old Menu Id
@param {!string} new Menu Id | [
"Create",
"a",
"deprecation",
"warning",
"and",
"action",
"for",
"updated",
"constants"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/DeprecationWarning.js#L132-L142 | train | Deprecate constant | [
30522,
3853,
2139,
28139,
16280,
8663,
12693,
2102,
1006,
27885,
3501,
1010,
2214,
3593,
1010,
2047,
3593,
1007,
1063,
13075,
5432,
1027,
1000,
2224,
12183,
2015,
1012,
1000,
1009,
2047,
3593,
1009,
1000,
2612,
1997,
12183,
2015,
1012,
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/mocha.js | Mocha | function Mocha(options) {
options = utils.assign({}, mocharc, options || {});
this.files = [];
this.options = options;
// root suite
this.suite = new exports.Suite('', new exports.Context(), true);
if ('useColors' in options) {
utils.deprecate(
'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option'
);
options.color = 'color' in options ? options.color : options.useColors;
}
this.grep(options.grep)
.fgrep(options.fgrep)
.ui(options.ui)
.bail(options.bail)
.reporter(options.reporter, options.reporterOptions)
.useColors(options.color)
.slow(options.slow)
.useInlineDiffs(options.inlineDiffs)
.globals(options.globals);
if ('enableTimeouts' in options) {
utils.deprecate(
'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
);
if (options.enableTimeouts === false) {
this.timeout(0);
}
}
// this guard exists because Suite#timeout does not consider `undefined` to be valid input
if (typeof options.timeout !== 'undefined') {
this.timeout(options.timeout === false ? 0 : options.timeout);
}
if ('retries' in options) {
this.retries(options.retries);
}
if ('diff' in options) {
this.hideDiff(!options.diff);
}
[
'allowUncaught',
'asyncOnly',
'checkLeaks',
'delay',
'forbidOnly',
'forbidPending',
'fullTrace',
'growl',
'invert'
].forEach(function(opt) {
if (options[opt]) {
this[opt]();
}
}, this);
} | javascript | function Mocha(options) {
options = utils.assign({}, mocharc, options || {});
this.files = [];
this.options = options;
// root suite
this.suite = new exports.Suite('', new exports.Context(), true);
if ('useColors' in options) {
utils.deprecate(
'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option'
);
options.color = 'color' in options ? options.color : options.useColors;
}
this.grep(options.grep)
.fgrep(options.fgrep)
.ui(options.ui)
.bail(options.bail)
.reporter(options.reporter, options.reporterOptions)
.useColors(options.color)
.slow(options.slow)
.useInlineDiffs(options.inlineDiffs)
.globals(options.globals);
if ('enableTimeouts' in options) {
utils.deprecate(
'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
);
if (options.enableTimeouts === false) {
this.timeout(0);
}
}
// this guard exists because Suite#timeout does not consider `undefined` to be valid input
if (typeof options.timeout !== 'undefined') {
this.timeout(options.timeout === false ? 0 : options.timeout);
}
if ('retries' in options) {
this.retries(options.retries);
}
if ('diff' in options) {
this.hideDiff(!options.diff);
}
[
'allowUncaught',
'asyncOnly',
'checkLeaks',
'delay',
'forbidOnly',
'forbidPending',
'fullTrace',
'growl',
'invert'
].forEach(function(opt) {
if (options[opt]) {
this[opt]();
}
}, this);
} | [
"function",
"Mocha",
"(",
"options",
")",
"{",
"options",
"=",
"utils",
".",
"assign",
"(",
"{",
"}",
",",
"mocharc",
",",
"options",
"||",
"{",
"}",
")",
";",
"this",
".",
"files",
"=",
"[",
"]",
";",
"this",
".",
"options",
"=",
"options",
";",... | Constructs a new Mocha instance with `options`.
@public
@class Mocha
@param {Object} [options] - Settings object.
@param {boolean} [options.allowUncaught] - Propagate uncaught errors?
@param {boolean} [options.asyncOnly] - Force `done` callback or promise?
@param {boolean} [options.bail] - Bail after first test failure?
@param {boolean} [options.checkLeaks] - If true, check leaks.
@param {boolean} [options.delay] - Delay root suite execution?
@param {boolean} [options.enableTimeouts] - Enable timeouts?
@param {string} [options.fgrep] - Test filter given string.
@param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite?
@param {boolean} [options.forbidPending] - Pending tests fail the suite?
@param {boolean} [options.fullStackTrace] - Full stacktrace upon failure?
@param {string[]} [options.global] - Variables expected in global scope.
@param {RegExp|string} [options.grep] - Test filter given regular expression.
@param {boolean} [options.growl] - Enable desktop notifications?
@param {boolean} [options.hideDiff] - Suppress diffs from failures?
@param {boolean} [options.ignoreLeaks] - Ignore global leaks?
@param {boolean} [options.invert] - Invert test filter matches?
@param {boolean} [options.noHighlighting] - Disable syntax highlighting?
@param {string} [options.reporter] - Reporter name.
@param {Object} [options.reporterOption] - Reporter settings object.
@param {number} [options.retries] - Number of times to retry failed tests.
@param {number} [options.slow] - Slow threshold value.
@param {number|string} [options.timeout] - Timeout threshold value.
@param {string} [options.ui] - Interface name.
@param {boolean} [options.color] - Color TTY output from reporter?
@param {boolean} [options.useInlineDiffs] - Use inline diffs? | [
"Constructs",
"a",
"new",
"Mocha",
"instance",
"with",
"options",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/mocha.js#L95-L156 | train | Mocha constructor. | [
30522,
3853,
9587,
7507,
1006,
7047,
1007,
1063,
7047,
1027,
21183,
12146,
1012,
23911,
1006,
1063,
1065,
1010,
9587,
7507,
11890,
1010,
7047,
1064,
1064,
1063,
1065,
1007,
1025,
2023,
1012,
6764,
1027,
1031,
1033,
1025,
2023,
1012,
7047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(id, dateStr) {
var onSelect,
target = $(id),
inst = this._getInst(target[0]);
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
if (inst.input) {
inst.input.val(dateStr);
}
this._updateAlternate(inst);
onSelect = this._get(inst, "onSelect");
if (onSelect) {
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
} else if (inst.input) {
inst.input.trigger("change"); // fire the change event
}
if (inst.inline){
this._updateDatepicker(inst);
} else {
this._hideDatepicker();
this._lastInput = inst.input[0];
if (typeof(inst.input[0]) !== "object") {
inst.input.focus(); // restore focus
}
this._lastInput = null;
}
} | javascript | function(id, dateStr) {
var onSelect,
target = $(id),
inst = this._getInst(target[0]);
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
if (inst.input) {
inst.input.val(dateStr);
}
this._updateAlternate(inst);
onSelect = this._get(inst, "onSelect");
if (onSelect) {
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
} else if (inst.input) {
inst.input.trigger("change"); // fire the change event
}
if (inst.inline){
this._updateDatepicker(inst);
} else {
this._hideDatepicker();
this._lastInput = inst.input[0];
if (typeof(inst.input[0]) !== "object") {
inst.input.focus(); // restore focus
}
this._lastInput = null;
}
} | [
"function",
"(",
"id",
",",
"dateStr",
")",
"{",
"var",
"onSelect",
",",
"target",
"=",
"$",
"(",
"id",
")",
",",
"inst",
"=",
"this",
".",
"_getInst",
"(",
"target",
"[",
"0",
"]",
")",
";",
"dateStr",
"=",
"(",
"dateStr",
"!=",
"null",
"?",
"... | /* Update the input field with the selected date. | [
"/",
"*",
"Update",
"the",
"input",
"field",
"with",
"the",
"selected",
"date",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8603-L8631 | train | Set the datepicker input field | [
30522,
3853,
1006,
8909,
1010,
5246,
16344,
1007,
1063,
13075,
2006,
11246,
22471,
1010,
4539,
1027,
1002,
1006,
8909,
1007,
1010,
16021,
2102,
1027,
2023,
1012,
1035,
2131,
7076,
2102,
1006,
4539,
1031,
1014,
1033,
1007,
1025,
5246,
16344,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 () {
var result = this.props.parentPath + this.props.name;
// Add trailing slash for directories
if (!FileTreeViewModel.isFile(this.props.entry) && _.last(result) !== "/") {
result += "/";
}
return result;
} | javascript | function () {
var result = this.props.parentPath + this.props.name;
// Add trailing slash for directories
if (!FileTreeViewModel.isFile(this.props.entry) && _.last(result) !== "/") {
result += "/";
}
return result;
} | [
"function",
"(",
")",
"{",
"var",
"result",
"=",
"this",
".",
"props",
".",
"parentPath",
"+",
"this",
".",
"props",
".",
"name",
";",
"// Add trailing slash for directories",
"if",
"(",
"!",
"FileTreeViewModel",
".",
"isFile",
"(",
"this",
".",
"props",
"... | Computes the full path of the file represented by this input. | [
"Computes",
"the",
"full",
"path",
"of",
"the",
"file",
"represented",
"by",
"this",
"input",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeView.js#L93-L102 | train | Get the path to the file | [
30522,
3853,
1006,
1007,
1063,
13075,
2765,
1027,
2023,
1012,
24387,
1012,
6687,
15069,
1009,
2023,
1012,
24387,
1012,
2171,
1025,
1013,
1013,
5587,
12542,
18296,
2005,
2472,
3111,
2065,
1006,
999,
5371,
13334,
8584,
5302,
9247,
1012,
2003,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.rta/src/sap/ui/rta/ControlTreeModifier.js | function (sClassName, oAppComponent, oView, oSelector, mSettings, bAsync) {
var oExistingControl = this.bySelector(oSelector, oAppComponent);
var fnCreateUndoOperation = function() {
if (!oExistingControl) {
var oCreatedControl = this.bySelector(oSelector, oAppComponent);
RtaControlTreeModifier._saveUndoOperation("destroy", [oCreatedControl]);
}
}.bind(this);
var vReturnValue = JsControlTreeModifier.createControl.apply(this, arguments);
if (bAsync) {
return vReturnValue.then(function(oReturnedControl) {
fnCreateUndoOperation();
return oReturnedControl;
});
}
fnCreateUndoOperation();
return vReturnValue;
} | javascript | function (sClassName, oAppComponent, oView, oSelector, mSettings, bAsync) {
var oExistingControl = this.bySelector(oSelector, oAppComponent);
var fnCreateUndoOperation = function() {
if (!oExistingControl) {
var oCreatedControl = this.bySelector(oSelector, oAppComponent);
RtaControlTreeModifier._saveUndoOperation("destroy", [oCreatedControl]);
}
}.bind(this);
var vReturnValue = JsControlTreeModifier.createControl.apply(this, arguments);
if (bAsync) {
return vReturnValue.then(function(oReturnedControl) {
fnCreateUndoOperation();
return oReturnedControl;
});
}
fnCreateUndoOperation();
return vReturnValue;
} | [
"function",
"(",
"sClassName",
",",
"oAppComponent",
",",
"oView",
",",
"oSelector",
",",
"mSettings",
",",
"bAsync",
")",
"{",
"var",
"oExistingControl",
"=",
"this",
".",
"bySelector",
"(",
"oSelector",
",",
"oAppComponent",
")",
";",
"var",
"fnCreateUndoOpe... | Record destroy as undo operation
@override | [
"Record",
"destroy",
"as",
"undo",
"operation"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/ControlTreeModifier.js#L208-L228 | train | Creates a new control and saves the undo operation to the DOM. | [
30522,
3853,
1006,
8040,
27102,
18442,
1010,
1051,
29098,
9006,
29513,
3372,
1010,
1051,
8584,
1010,
9808,
12260,
16761,
1010,
5796,
18319,
3070,
2015,
1010,
19021,
6038,
2278,
1007,
1063,
13075,
1051,
10288,
2923,
2075,
8663,
13181,
2140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/editor/EditorStatusBar.js | _updateFileInfo | function _updateFileInfo(editor) {
var lines = editor.lineCount();
$fileInfo.text(_formatCountable(lines, Strings.STATUSBAR_LINE_COUNT_SINGULAR, Strings.STATUSBAR_LINE_COUNT_PLURAL));
} | javascript | function _updateFileInfo(editor) {
var lines = editor.lineCount();
$fileInfo.text(_formatCountable(lines, Strings.STATUSBAR_LINE_COUNT_SINGULAR, Strings.STATUSBAR_LINE_COUNT_PLURAL));
} | [
"function",
"_updateFileInfo",
"(",
"editor",
")",
"{",
"var",
"lines",
"=",
"editor",
".",
"lineCount",
"(",
")",
";",
"$fileInfo",
".",
"text",
"(",
"_formatCountable",
"(",
"lines",
",",
"Strings",
".",
"STATUSBAR_LINE_COUNT_SINGULAR",
",",
"Strings",
".",
... | Update file information
@param {Editor} editor Current editor | [
"Update",
"file",
"information"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorStatusBar.js#L114-L117 | train | Update the file info | [
30522,
3853,
1035,
10651,
8873,
19856,
14876,
1006,
3559,
1007,
1063,
13075,
3210,
1027,
3559,
1012,
2240,
3597,
16671,
1006,
1007,
1025,
1002,
5371,
2378,
14876,
1012,
3793,
1006,
1035,
4289,
3597,
16671,
3085,
1006,
3210,
1010,
7817,
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/jquery.sap.history.js | detectHashChange | function detectHashChange(oEvent, bManual){
//Firefox will decode the hash when it's set to the window.location.hash,
//so we need to parse the href instead of reading the window.location.hash
var sHash = (window.location.href.split("#")[1] || "");
sHash = formatHash(sHash);
if (bManual || !mSkipHandler[sHash]) {
aHashChangeBuffer.push(sHash);
}
if (!bInProcessing) {
bInProcessing = true;
if (aHashChangeBuffer.length > 0) {
var newHash = aHashChangeBuffer.shift();
if (mSkipHandler[newHash]) {
reorganizeHistoryArray(newHash);
delete mSkipHandler[newHash];
} else {
onHashChange(newHash);
}
currentHash = newHash;
}
bInProcessing = false;
}
} | javascript | function detectHashChange(oEvent, bManual){
//Firefox will decode the hash when it's set to the window.location.hash,
//so we need to parse the href instead of reading the window.location.hash
var sHash = (window.location.href.split("#")[1] || "");
sHash = formatHash(sHash);
if (bManual || !mSkipHandler[sHash]) {
aHashChangeBuffer.push(sHash);
}
if (!bInProcessing) {
bInProcessing = true;
if (aHashChangeBuffer.length > 0) {
var newHash = aHashChangeBuffer.shift();
if (mSkipHandler[newHash]) {
reorganizeHistoryArray(newHash);
delete mSkipHandler[newHash];
} else {
onHashChange(newHash);
}
currentHash = newHash;
}
bInProcessing = false;
}
} | [
"function",
"detectHashChange",
"(",
"oEvent",
",",
"bManual",
")",
"{",
"//Firefox will decode the hash when it's set to the window.location.hash,",
"//so we need to parse the href instead of reading the window.location.hash",
"var",
"sHash",
"=",
"(",
"window",
".",
"location",
"... | This function is bound to the window's hashchange event, and it detects the change of the hash.
When history is added by calling the addHistory or addVirtualHistory function, it will not call the real onHashChange function
because changes are already done. Only when a hash is navigated by clicking the back or forward buttons in the browser,
the onHashChange will be called.
@private | [
"This",
"function",
"is",
"bound",
"to",
"the",
"window",
"s",
"hashchange",
"event",
"and",
"it",
"detects",
"the",
"change",
"of",
"the",
"hash",
".",
"When",
"history",
"is",
"added",
"by",
"calling",
"the",
"addHistory",
"or",
"addVirtualHistory",
"funct... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/jquery.sap.history.js#L425-L450 | train | Detects the hashchange event | [
30522,
3853,
11487,
14949,
16257,
18003,
2063,
1006,
1051,
18697,
3372,
1010,
1038,
2386,
8787,
1007,
1063,
1013,
1013,
2543,
14876,
2595,
2097,
21933,
3207,
1996,
23325,
2043,
2009,
1005,
1055,
2275,
2000,
1996,
3332,
1012,
3295,
1012,
233... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FileViewController.js | openFileAndAddToWorkingSet | function openFileAndAddToWorkingSet(fullPath, paneId) {
var result = new $.Deferred(),
promise = CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, {fullPath: fullPath,
paneId: paneId});
// This properly handles sending the right nofications in cases where the document
// is already the current one. In that case we will want to notify with
// documentSelectionFocusChange so the views change their selection
promise.done(function (file) {
// CMD_ADD_TO_WORKINGSET_AND_OPEN command sets the current document. Update the
// selection focus only if doc is not null. When double-clicking on an
// image file, we get a null doc here but we still want to keep _fileSelectionFocus
// as PROJECT_MANAGER. Regardless of doc is null or not, call _activatePane
// to trigger documentSelectionFocusChange event.
_fileSelectionFocus = WORKING_SET_VIEW;
_activatePane(paneId);
result.resolve(file);
}).fail(function (err) {
result.reject(err);
});
return result.promise();
} | javascript | function openFileAndAddToWorkingSet(fullPath, paneId) {
var result = new $.Deferred(),
promise = CommandManager.execute(Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN, {fullPath: fullPath,
paneId: paneId});
// This properly handles sending the right nofications in cases where the document
// is already the current one. In that case we will want to notify with
// documentSelectionFocusChange so the views change their selection
promise.done(function (file) {
// CMD_ADD_TO_WORKINGSET_AND_OPEN command sets the current document. Update the
// selection focus only if doc is not null. When double-clicking on an
// image file, we get a null doc here but we still want to keep _fileSelectionFocus
// as PROJECT_MANAGER. Regardless of doc is null or not, call _activatePane
// to trigger documentSelectionFocusChange event.
_fileSelectionFocus = WORKING_SET_VIEW;
_activatePane(paneId);
result.resolve(file);
}).fail(function (err) {
result.reject(err);
});
return result.promise();
} | [
"function",
"openFileAndAddToWorkingSet",
"(",
"fullPath",
",",
"paneId",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"promise",
"=",
"CommandManager",
".",
"execute",
"(",
"Commands",
".",
"CMD_ADD_TO_WORKINGSET_AND_OPEN",
",",
... | Opens the specified document if it's not already open, adds it to the working set,
and selects it in the WorkingSetView
@param {!fullPath}
@param {string=} paneId - Pane in which to add the view. If omitted, the command default is to use the ACTIVE_PANE
@return {!$.Promise} | [
"Opens",
"the",
"specified",
"document",
"if",
"it",
"s",
"not",
"already",
"open",
"adds",
"it",
"to",
"the",
"working",
"set",
"and",
"selects",
"it",
"in",
"the",
"WorkingSetView"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileViewController.js#L204-L227 | train | Opens the file and adds it to the workingset | [
30522,
3853,
2330,
8873,
20898,
14697,
11927,
5004,
2953,
6834,
13462,
1006,
2440,
15069,
1010,
6090,
7416,
2094,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
4872,
1027,
3094,
24805,
4590,
1012,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js | function( ua ) {
ua = ua.toLowerCase();
var match = rwebkit.exec( ua ) ||
ropera.exec( ua ) ||
rmsie.exec( ua ) ||
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
[];
return { browser: match[1] || "", version: match[2] || "0" };
} | javascript | function( ua ) {
ua = ua.toLowerCase();
var match = rwebkit.exec( ua ) ||
ropera.exec( ua ) ||
rmsie.exec( ua ) ||
ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
[];
return { browser: match[1] || "", version: match[2] || "0" };
} | [
"function",
"(",
"ua",
")",
"{",
"ua",
"=",
"ua",
".",
"toLowerCase",
"(",
")",
";",
"var",
"match",
"=",
"rwebkit",
".",
"exec",
"(",
"ua",
")",
"||",
"ropera",
".",
"exec",
"(",
"ua",
")",
"||",
"rmsie",
".",
"exec",
"(",
"ua",
")",
"||",
"... | Use of jQuery.browser is frowned upon. More details: http://docs.jquery.com/Utilities/jQuery.browser | [
"Use",
"of",
"jQuery",
".",
"browser",
"is",
"frowned",
"upon",
".",
"More",
"details",
":",
"http",
":",
"//",
"docs",
".",
"jquery",
".",
"com",
"/",
"Utilities",
"/",
"jQuery",
".",
"browser"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js#L858-L868 | train | Returns the browser name version and browser version from the user agent string. | [
30522,
3853,
1006,
25423,
1007,
1063,
25423,
1027,
25423,
1012,
2000,
27663,
18992,
3366,
1006,
1007,
1025,
13075,
2674,
1027,
1054,
8545,
2497,
23615,
1012,
4654,
8586,
1006,
25423,
1007,
1064,
1064,
8164,
2527,
1012,
4654,
8586,
1006,
254... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/widgets/Dialogs.js | function (e, autoDismiss) {
var $primaryBtn = this.find(".primary"),
buttonId = null,
which = String.fromCharCode(e.which),
$focusedElement = this.find(".dialog-button:focus, a:focus");
function stopEvent() {
e.preventDefault();
e.stopPropagation();
}
// There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal
var inTextArea = (e.target.tagName === "TEXTAREA"),
inTypingField = inTextArea || ($(e.target).filter(":text, :password").length > 0);
if (e.which === KeyEvent.DOM_VK_TAB) {
// We don't want to stopEvent() in this case since we might want the default behavior.
// _handleTab takes care of stopping/preventing default as necessary.
_handleTab(e, this);
} else if (e.which === KeyEvent.DOM_VK_ESCAPE) {
buttonId = DIALOG_BTN_CANCEL;
} else if (e.which === KeyEvent.DOM_VK_RETURN && (!inTextArea || e.ctrlKey)) {
// Enter key in single-line text input always dismisses; in text area, only Ctrl+Enter dismisses
// Click primary
stopEvent();
if (e.target.tagName === "BUTTON") {
this.find(e.target).click();
} else if (e.target.tagName !== "INPUT") {
// If the target element is not BUTTON or INPUT, click the primary button
// We're making an exception for INPUT element because of this issue: GH-11416
$primaryBtn.click();
}
} else if (e.which === KeyEvent.DOM_VK_SPACE) {
if ($focusedElement.length) {
// Space bar on focused button or link
stopEvent();
$focusedElement.click();
}
} else if (brackets.platform === "mac") {
// CMD+Backspace Don't Save
if (e.metaKey && (e.which === KeyEvent.DOM_VK_BACK_SPACE)) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
// FIXME (issue #418) CMD+. Cancel swallowed by native shell
} else if (e.metaKey && (e.which === KeyEvent.DOM_VK_PERIOD)) {
buttonId = DIALOG_BTN_CANCEL;
}
} else { // if (brackets.platform === "win") {
// 'N' Don't Save
if (which === "N" && !inTypingField) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
}
}
if (buttonId) {
stopEvent();
_processButton(this, buttonId, autoDismiss);
}
// Stop any other global hooks from processing the event (but
// allow it to continue bubbling if we haven't otherwise stopped it).
return true;
} | javascript | function (e, autoDismiss) {
var $primaryBtn = this.find(".primary"),
buttonId = null,
which = String.fromCharCode(e.which),
$focusedElement = this.find(".dialog-button:focus, a:focus");
function stopEvent() {
e.preventDefault();
e.stopPropagation();
}
// There might be a textfield in the dialog's UI; don't want to mistake normal typing for dialog dismissal
var inTextArea = (e.target.tagName === "TEXTAREA"),
inTypingField = inTextArea || ($(e.target).filter(":text, :password").length > 0);
if (e.which === KeyEvent.DOM_VK_TAB) {
// We don't want to stopEvent() in this case since we might want the default behavior.
// _handleTab takes care of stopping/preventing default as necessary.
_handleTab(e, this);
} else if (e.which === KeyEvent.DOM_VK_ESCAPE) {
buttonId = DIALOG_BTN_CANCEL;
} else if (e.which === KeyEvent.DOM_VK_RETURN && (!inTextArea || e.ctrlKey)) {
// Enter key in single-line text input always dismisses; in text area, only Ctrl+Enter dismisses
// Click primary
stopEvent();
if (e.target.tagName === "BUTTON") {
this.find(e.target).click();
} else if (e.target.tagName !== "INPUT") {
// If the target element is not BUTTON or INPUT, click the primary button
// We're making an exception for INPUT element because of this issue: GH-11416
$primaryBtn.click();
}
} else if (e.which === KeyEvent.DOM_VK_SPACE) {
if ($focusedElement.length) {
// Space bar on focused button or link
stopEvent();
$focusedElement.click();
}
} else if (brackets.platform === "mac") {
// CMD+Backspace Don't Save
if (e.metaKey && (e.which === KeyEvent.DOM_VK_BACK_SPACE)) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
// FIXME (issue #418) CMD+. Cancel swallowed by native shell
} else if (e.metaKey && (e.which === KeyEvent.DOM_VK_PERIOD)) {
buttonId = DIALOG_BTN_CANCEL;
}
} else { // if (brackets.platform === "win") {
// 'N' Don't Save
if (which === "N" && !inTypingField) {
if (_hasButton(this, DIALOG_BTN_DONTSAVE)) {
buttonId = DIALOG_BTN_DONTSAVE;
}
}
}
if (buttonId) {
stopEvent();
_processButton(this, buttonId, autoDismiss);
}
// Stop any other global hooks from processing the event (but
// allow it to continue bubbling if we haven't otherwise stopped it).
return true;
} | [
"function",
"(",
"e",
",",
"autoDismiss",
")",
"{",
"var",
"$primaryBtn",
"=",
"this",
".",
"find",
"(",
"\".primary\"",
")",
",",
"buttonId",
"=",
"null",
",",
"which",
"=",
"String",
".",
"fromCharCode",
"(",
"e",
".",
"which",
")",
",",
"$focusedEle... | Handles the keyDown event for the dialogs
@param {$.Event} e
@param {boolean} autoDismiss
@return {boolean} | [
"Handles",
"the",
"keyDown",
"event",
"for",
"the",
"dialogs"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/Dialogs.js#L142-L207 | train | Handle keydown events | [
30522,
3853,
1006,
1041,
1010,
8285,
10521,
15630,
2015,
1007,
1063,
13075,
1002,
3078,
19279,
2078,
1027,
2023,
1012,
2424,
1006,
1000,
1012,
3078,
1000,
1007,
1010,
6462,
3593,
1027,
19701,
1010,
2029,
1027,
5164,
1012,
2013,
7507,
29566,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function () {
var entities = this.entities;
return entities.literal() || entities.variable() || entities.url() ||
entities.call() || entities.keyword() || entities.javascript() ||
this.comment();
} | javascript | function () {
var entities = this.entities;
return entities.literal() || entities.variable() || entities.url() ||
entities.call() || entities.keyword() || entities.javascript() ||
this.comment();
} | [
"function",
"(",
")",
"{",
"var",
"entities",
"=",
"this",
".",
"entities",
";",
"return",
"entities",
".",
"literal",
"(",
")",
"||",
"entities",
".",
"variable",
"(",
")",
"||",
"entities",
".",
"url",
"(",
")",
"||",
"entities",
".",
"call",
"(",
... | Entities are the smallest recognized token, and can be found inside a rule's value. | [
"Entities",
"are",
"the",
"smallest",
"recognized",
"token",
"and",
"can",
"be",
"found",
"inside",
"a",
"rule",
"s",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L1311-L1317 | train | Returns the string representation of the grammar. | [
30522,
3853,
1006,
1007,
1063,
13075,
11422,
1027,
2023,
1012,
11422,
1025,
2709,
11422,
1012,
18204,
1006,
1007,
1064,
1064,
11422,
1012,
8023,
1006,
1007,
1064,
1064,
11422,
1012,
24471,
2140,
1006,
1007,
1064,
1064,
11422,
1012,
2655,
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... | |
chartjs/Chart.js | src/scales/scale.radialLinear.js | fitWithPointLabels | function fitWithPointLabels(scale) {
// Right, this is really confusing and there is a lot of maths going on here
// The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
//
// Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
//
// Solution:
//
// We assume the radius of the polygon is half the size of the canvas at first
// at each index we check if the text overlaps.
//
// Where it does, we store that angle and that index.
//
// After finding the largest index and angle we calculate how much we need to remove
// from the shape radius to move the point inwards by that x.
//
// We average the left and right distances to get the maximum shape radius that can fit in the box
// along with labels.
//
// Once we have that, we can find the centre point for the chart, by taking the x text protrusion
// on each side, removing that from the size, halving it and adding the left x protrusion width.
//
// This will mean we have a shape fitted to the canvas, as large as it can be with the labels
// and position it in the most space efficient manner
//
// https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
var plFont = helpers.options._parseFont(scale.options.pointLabels);
// Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
// Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
var furthestLimits = {
l: 0,
r: scale.width,
t: 0,
b: scale.height - scale.paddingTop
};
var furthestAngles = {};
var i, textSize, pointPosition;
scale.ctx.font = plFont.string;
scale._pointLabelSizes = [];
var valueCount = getValueCount(scale);
for (i = 0; i < valueCount; i++) {
pointPosition = scale.getPointPosition(i, scale.drawingArea + 5);
textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i] || '');
scale._pointLabelSizes[i] = textSize;
// Add quarter circle to make degree 0 mean top of circle
var angleRadians = scale.getIndexAngle(i);
var angle = helpers.toDegrees(angleRadians) % 360;
var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
if (hLimits.start < furthestLimits.l) {
furthestLimits.l = hLimits.start;
furthestAngles.l = angleRadians;
}
if (hLimits.end > furthestLimits.r) {
furthestLimits.r = hLimits.end;
furthestAngles.r = angleRadians;
}
if (vLimits.start < furthestLimits.t) {
furthestLimits.t = vLimits.start;
furthestAngles.t = angleRadians;
}
if (vLimits.end > furthestLimits.b) {
furthestLimits.b = vLimits.end;
furthestAngles.b = angleRadians;
}
}
scale.setReductions(scale.drawingArea, furthestLimits, furthestAngles);
} | javascript | function fitWithPointLabels(scale) {
// Right, this is really confusing and there is a lot of maths going on here
// The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
//
// Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
//
// Solution:
//
// We assume the radius of the polygon is half the size of the canvas at first
// at each index we check if the text overlaps.
//
// Where it does, we store that angle and that index.
//
// After finding the largest index and angle we calculate how much we need to remove
// from the shape radius to move the point inwards by that x.
//
// We average the left and right distances to get the maximum shape radius that can fit in the box
// along with labels.
//
// Once we have that, we can find the centre point for the chart, by taking the x text protrusion
// on each side, removing that from the size, halving it and adding the left x protrusion width.
//
// This will mean we have a shape fitted to the canvas, as large as it can be with the labels
// and position it in the most space efficient manner
//
// https://dl.dropboxusercontent.com/u/34601363/yeahscience.gif
var plFont = helpers.options._parseFont(scale.options.pointLabels);
// Get maximum radius of the polygon. Either half the height (minus the text width) or half the width.
// Use this to calculate the offset + change. - Make sure L/R protrusion is at least 0 to stop issues with centre points
var furthestLimits = {
l: 0,
r: scale.width,
t: 0,
b: scale.height - scale.paddingTop
};
var furthestAngles = {};
var i, textSize, pointPosition;
scale.ctx.font = plFont.string;
scale._pointLabelSizes = [];
var valueCount = getValueCount(scale);
for (i = 0; i < valueCount; i++) {
pointPosition = scale.getPointPosition(i, scale.drawingArea + 5);
textSize = measureLabelSize(scale.ctx, plFont.lineHeight, scale.pointLabels[i] || '');
scale._pointLabelSizes[i] = textSize;
// Add quarter circle to make degree 0 mean top of circle
var angleRadians = scale.getIndexAngle(i);
var angle = helpers.toDegrees(angleRadians) % 360;
var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);
var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);
if (hLimits.start < furthestLimits.l) {
furthestLimits.l = hLimits.start;
furthestAngles.l = angleRadians;
}
if (hLimits.end > furthestLimits.r) {
furthestLimits.r = hLimits.end;
furthestAngles.r = angleRadians;
}
if (vLimits.start < furthestLimits.t) {
furthestLimits.t = vLimits.start;
furthestAngles.t = angleRadians;
}
if (vLimits.end > furthestLimits.b) {
furthestLimits.b = vLimits.end;
furthestAngles.b = angleRadians;
}
}
scale.setReductions(scale.drawingArea, furthestLimits, furthestAngles);
} | [
"function",
"fitWithPointLabels",
"(",
"scale",
")",
"{",
"// Right, this is really confusing and there is a lot of maths going on here",
"// The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9",
"//",
"// Reaction: https://dl.dropboxusercontent.com/u/34601363/toom... | Helper function to fit a radial linear scale with point labels | [
"Helper",
"function",
"to",
"fit",
"a",
"radial",
"linear",
"scale",
"with",
"point",
"labels"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/scales/scale.radialLinear.js#L112-L190 | train | This function is called when the chart is drawn with a point label | [
30522,
3853,
4906,
24415,
8400,
20470,
9050,
1006,
4094,
1007,
1063,
1013,
1013,
2157,
1010,
2023,
2003,
2428,
16801,
1998,
2045,
2003,
1037,
2843,
1997,
8785,
2015,
2183,
2006,
2182,
1013,
1013,
1996,
21025,
3367,
1997,
1996,
3291,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | showOpenDialog | function showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, callback) {
appshell.fs.showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, _wrap(callback));
} | javascript | function showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, callback) {
appshell.fs.showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, _wrap(callback));
} | [
"function",
"showOpenDialog",
"(",
"allowMultipleSelection",
",",
"chooseDirectories",
",",
"title",
",",
"initialPath",
",",
"fileTypes",
",",
"callback",
")",
"{",
"appshell",
".",
"fs",
".",
"showOpenDialog",
"(",
"allowMultipleSelection",
",",
"chooseDirectories",... | Display an open-files dialog to the user and call back asynchronously with
either a FileSystmError string or an array of path strings, which indicate
the entry or entries selected.
@param {boolean} allowMultipleSelection
@param {boolean} chooseDirectories
@param {string} title
@param {string} initialPath
@param {Array.<string>=} fileTypes
@param {function(?string, Array.<string>=)} callback | [
"Display",
"an",
"open",
"-",
"files",
"dialog",
"to",
"the",
"user",
"and",
"call",
"back",
"asynchronously",
"with",
"either",
"a",
"FileSystmError",
"string",
"or",
"an",
"array",
"of",
"path",
"strings",
"which",
"indicate",
"the",
"entry",
"or",
"entrie... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/AppshellFileSystem.js#L201-L203 | train | showOpenDialog - Shows the open file system dialog | [
30522,
3853,
2265,
26915,
27184,
8649,
1006,
3499,
12274,
7096,
11514,
24527,
2571,
7542,
1010,
5454,
4305,
2890,
16761,
3111,
1010,
2516,
1010,
3988,
15069,
1010,
5371,
13874,
2015,
1010,
2655,
5963,
1007,
1063,
18726,
18223,
1012,
1042,
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... |
Freeboard/freeboard | js/freeboard.thirdparty.js | function( inst ) {
return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
} | javascript | function( inst ) {
return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
} | [
"function",
"(",
"inst",
")",
"{",
"return",
"inst",
".",
"input",
"&&",
"inst",
".",
"input",
".",
"is",
"(",
"\":visible\"",
")",
"&&",
"!",
"inst",
".",
"input",
".",
"is",
"(",
"\":disabled\"",
")",
"&&",
"!",
"inst",
".",
"input",
".",
"is",
... | #6694 - don't focus the input if it's already focused this breaks the change event in IE Support: IE and jQuery <1.9 | [
"#6694",
"-",
"don",
"t",
"focus",
"the",
"input",
"if",
"it",
"s",
"already",
"focused",
"this",
"breaks",
"the",
"change",
"event",
"in",
"IE",
"Support",
":",
"IE",
"and",
"jQuery",
"<1",
".",
"9"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L8420-L8422 | train | Returns true if the input element is visible false otherwise. | [
30522,
3853,
1006,
16021,
2102,
1007,
1063,
2709,
16021,
2102,
1012,
7953,
1004,
1004,
16021,
2102,
1012,
7953,
1012,
2003,
1006,
1000,
1024,
5710,
1000,
1007,
1004,
1004,
999,
16021,
2102,
1012,
7953,
1012,
2003,
1006,
1000,
1024,
9776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
facebook/relay | packages/babel-plugin-relay/createClassicNode.js | createClassicNode | function createClassicNode(
t: $FlowFixMe,
path: Object,
graphqlDefinition: DefinitionNode,
state: BabelState,
): Object {
if (graphqlDefinition.kind === 'FragmentDefinition') {
return createFragmentConcreteNode(t, path, graphqlDefinition, state);
}
if (graphqlDefinition.kind === 'OperationDefinition') {
return createOperationConcreteNode(t, path, graphqlDefinition, state);
}
throw new Error(
'BabelPluginRelay: Expected a fragment, mutation, query, or ' +
'subscription, got `' +
graphqlDefinition.kind +
'`.',
);
} | javascript | function createClassicNode(
t: $FlowFixMe,
path: Object,
graphqlDefinition: DefinitionNode,
state: BabelState,
): Object {
if (graphqlDefinition.kind === 'FragmentDefinition') {
return createFragmentConcreteNode(t, path, graphqlDefinition, state);
}
if (graphqlDefinition.kind === 'OperationDefinition') {
return createOperationConcreteNode(t, path, graphqlDefinition, state);
}
throw new Error(
'BabelPluginRelay: Expected a fragment, mutation, query, or ' +
'subscription, got `' +
graphqlDefinition.kind +
'`.',
);
} | [
"function",
"createClassicNode",
"(",
"t",
":",
"$FlowFixMe",
",",
"path",
":",
"Object",
",",
"graphqlDefinition",
":",
"DefinitionNode",
",",
"state",
":",
"BabelState",
",",
")",
":",
"Object",
"{",
"if",
"(",
"graphqlDefinition",
".",
"kind",
"===",
"'Fr... | Relay Classic transforms to inline generated content. | [
"Relay",
"Classic",
"transforms",
"to",
"inline",
"generated",
"content",
"."
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/babel-plugin-relay/createClassicNode.js#L26-L46 | train | Creates a classic node | [
30522,
3853,
3443,
26266,
2594,
3630,
3207,
1006,
1056,
1024,
1002,
4834,
30524,
2065,
1006,
10629,
4160,
17920,
16294,
22753,
1012,
2785,
1027,
1027,
1027,
1005,
15778,
3207,
16294,
22753,
1005,
1007,
1063,
2709,
3443,
27843,
21693,
4765,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | function() {
var me = this;
helpers$1.each(me.data.datasets, function(dataset, datasetIndex) {
me.getDatasetMeta(datasetIndex).controller.reset();
}, me);
} | javascript | function() {
var me = this;
helpers$1.each(me.data.datasets, function(dataset, datasetIndex) {
me.getDatasetMeta(datasetIndex).controller.reset();
}, me);
} | [
"function",
"(",
")",
"{",
"var",
"me",
"=",
"this",
";",
"helpers$1",
".",
"each",
"(",
"me",
".",
"data",
".",
"datasets",
",",
"function",
"(",
"dataset",
",",
"datasetIndex",
")",
"{",
"me",
".",
"getDatasetMeta",
"(",
"datasetIndex",
")",
".",
"... | Reset the elements of all datasets
@private | [
"Reset",
"the",
"elements",
"of",
"all",
"datasets"
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L8686-L8691 | train | Reset all the controllers | [
30522,
3853,
1006,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
2393,
2545,
1002,
1015,
1012,
2169,
1006,
2033,
1012,
2951,
1012,
2951,
13462,
2015,
1010,
3853,
1006,
2951,
13462,
1010,
2951,
13462,
22254,
10288,
1007,
1063,
2033,
1012,
2131,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
GitbookIO/gitbook | lib/json/encodeBookWithPage.js | encodeBookWithPage | function encodeBookWithPage(book, page) {
var file = page.getFile();
var result = encodeBook(book);
result.page = encodePage(page, book.getSummary());
result.file = encodeFile(file);
return result;
} | javascript | function encodeBookWithPage(book, page) {
var file = page.getFile();
var result = encodeBook(book);
result.page = encodePage(page, book.getSummary());
result.file = encodeFile(file);
return result;
} | [
"function",
"encodeBookWithPage",
"(",
"book",
",",
"page",
")",
"{",
"var",
"file",
"=",
"page",
".",
"getFile",
"(",
")",
";",
"var",
"result",
"=",
"encodeBook",
"(",
"book",
")",
";",
"result",
".",
"page",
"=",
"encodePage",
"(",
"page",
",",
"b... | Return a JSON representation of a book with a specific file
@param {Book} output
@param {Page} page
@return {Object} | [
"Return",
"a",
"JSON",
"representation",
"of",
"a",
"book",
"with",
"a",
"specific",
"file"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeBookWithPage.js#L12-L20 | train | Encode a book with a page | [
30522,
3853,
4372,
16044,
8654,
24415,
13704,
1006,
2338,
1010,
3931,
1007,
1063,
13075,
5371,
1027,
3931,
1012,
2131,
8873,
2571,
1006,
1007,
1025,
13075,
2765,
1027,
4372,
16044,
8654,
1006,
2338,
1007,
1025,
2765,
1012,
3931,
1027,
4372,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jaywcjlove/linux-command | build/build.js | emptyDir | function emptyDir(dir) {
return new Promise((resolve, reject) => {
FS.emptyDir(dir, err => {
err ? reject(err) : resolve(dir);
})
});
} | javascript | function emptyDir(dir) {
return new Promise((resolve, reject) => {
FS.emptyDir(dir, err => {
err ? reject(err) : resolve(dir);
})
});
} | [
"function",
"emptyDir",
"(",
"dir",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"FS",
".",
"emptyDir",
"(",
"dir",
",",
"err",
"=>",
"{",
"err",
"?",
"reject",
"(",
"err",
")",
":",
"resolve",
"(",
"d... | Empty a directory
@param {String} dir | [
"Empty",
"a",
"directory"
] | 7d6c8c6b3468a0dd5311ee68934c9b8db64469f7 | https://github.com/jaywcjlove/linux-command/blob/7d6c8c6b3468a0dd5311ee68934c9b8db64469f7/build/build.js#L158-L164 | train | Empty the specified directory | [
30522,
3853,
4064,
4305,
2099,
1006,
16101,
1007,
1063,
2709,
2047,
4872,
1006,
1006,
10663,
1010,
15454,
1007,
1027,
1028,
1063,
1042,
2015,
1012,
4064,
4305,
2099,
1006,
16101,
1010,
9413,
2099,
1027,
1028,
1063,
9413,
2099,
1029,
15454,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-useless-rename.js | checkExport | function checkExport(node) {
if (ignoreExport) {
return;
}
if (node.local.name === node.exported.name &&
node.local.range[0] !== node.exported.range[0]) {
reportError(node, node.local, node.exported, "Export");
}
} | javascript | function checkExport(node) {
if (ignoreExport) {
return;
}
if (node.local.name === node.exported.name &&
node.local.range[0] !== node.exported.range[0]) {
reportError(node, node.local, node.exported, "Export");
}
} | [
"function",
"checkExport",
"(",
"node",
")",
"{",
"if",
"(",
"ignoreExport",
")",
"{",
"return",
";",
"}",
"if",
"(",
"node",
".",
"local",
".",
"name",
"===",
"node",
".",
"exported",
".",
"name",
"&&",
"node",
".",
"local",
".",
"range",
"[",
"0"... | Checks whether an export is unnecessarily renamed
@param {ASTNode} node - node to check
@returns {void} | [
"Checks",
"whether",
"an",
"export",
"is",
"unnecessarily",
"renamed"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-rename.js#L130-L140 | train | Check if export node is valid | [
30522,
3853,
4638,
10288,
6442,
1006,
13045,
1007,
1063,
2065,
1006,
8568,
10288,
6442,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
13045,
1012,
2334,
1012,
2171,
1027,
1027,
1027,
13045,
1012,
15612,
1012,
2171,
1004,
1004,
13045,
1012,
2334... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/props.js | diffUpdateTriggers | function diffUpdateTriggers(props, oldProps) {
if (oldProps === null) {
return 'oldProps is null, initial diff';
}
// If the 'all' updateTrigger fires, ignore testing others
if ('all' in props.updateTriggers) {
const diffReason = diffUpdateTrigger(props, oldProps, 'all');
if (diffReason) {
return {all: true};
}
}
const triggerChanged = {};
let reason = false;
// If the 'all' updateTrigger didn't fire, need to check all others
for (const triggerName in props.updateTriggers) {
if (triggerName !== 'all') {
const diffReason = diffUpdateTrigger(props, oldProps, triggerName);
if (diffReason) {
triggerChanged[triggerName] = true;
reason = triggerChanged;
}
}
}
return reason;
} | javascript | function diffUpdateTriggers(props, oldProps) {
if (oldProps === null) {
return 'oldProps is null, initial diff';
}
// If the 'all' updateTrigger fires, ignore testing others
if ('all' in props.updateTriggers) {
const diffReason = diffUpdateTrigger(props, oldProps, 'all');
if (diffReason) {
return {all: true};
}
}
const triggerChanged = {};
let reason = false;
// If the 'all' updateTrigger didn't fire, need to check all others
for (const triggerName in props.updateTriggers) {
if (triggerName !== 'all') {
const diffReason = diffUpdateTrigger(props, oldProps, triggerName);
if (diffReason) {
triggerChanged[triggerName] = true;
reason = triggerChanged;
}
}
}
return reason;
} | [
"function",
"diffUpdateTriggers",
"(",
"props",
",",
"oldProps",
")",
"{",
"if",
"(",
"oldProps",
"===",
"null",
")",
"{",
"return",
"'oldProps is null, initial diff'",
";",
"}",
"// If the 'all' updateTrigger fires, ignore testing others",
"if",
"(",
"'all'",
"in",
"... | Checks if any update triggers have changed also calls callback to invalidate attributes accordingly. | [
"Checks",
"if",
"any",
"update",
"triggers",
"have",
"changed",
"also",
"calls",
"callback",
"to",
"invalidate",
"attributes",
"accordingly",
"."
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/core/src/lifecycle/props.js#L143-L170 | train | diffUpdateTriggers - returns a string that indicates if the update triggers changed | [
30522,
3853,
4487,
4246,
6279,
13701,
18886,
13327,
2015,
1006,
24387,
1010,
2214,
21572,
4523,
1007,
1063,
2065,
1006,
2214,
21572,
4523,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
1005,
2214,
21572,
4523,
2003,
19701,
1010,
3988,
4487,
42... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/IssueManager.js | function(aIssues) {
var iHighIssues = 0,
iMediumIssues = 0,
iLowIssues = 0;
aIssues.forEach(function(element) {
switch (element.severity) {
case constants.SUPPORT_ASSISTANT_ISSUE_SEVERITY_LOW:
iLowIssues++;
break;
case constants.SUPPORT_ASSISTANT_ISSUE_SEVERITY_MEDIUM:
iMediumIssues++;
break;
case constants.SUPPORT_ASSISTANT_ISSUE_SEVERITY_HIGH:
iHighIssues++;
break;
}
});
return {high: iHighIssues, medium: iMediumIssues, low: iLowIssues};
} | javascript | function(aIssues) {
var iHighIssues = 0,
iMediumIssues = 0,
iLowIssues = 0;
aIssues.forEach(function(element) {
switch (element.severity) {
case constants.SUPPORT_ASSISTANT_ISSUE_SEVERITY_LOW:
iLowIssues++;
break;
case constants.SUPPORT_ASSISTANT_ISSUE_SEVERITY_MEDIUM:
iMediumIssues++;
break;
case constants.SUPPORT_ASSISTANT_ISSUE_SEVERITY_HIGH:
iHighIssues++;
break;
}
});
return {high: iHighIssues, medium: iMediumIssues, low: iLowIssues};
} | [
"function",
"(",
"aIssues",
")",
"{",
"var",
"iHighIssues",
"=",
"0",
",",
"iMediumIssues",
"=",
"0",
",",
"iLowIssues",
"=",
"0",
";",
"aIssues",
".",
"forEach",
"(",
"function",
"(",
"element",
")",
"{",
"switch",
"(",
"element",
".",
"severity",
")"... | Sorts number of severity issues e.g. 1 High, 0 Medium, 0 Low.
@private
@param {array} aIssues
@name sap.ui.support.IssueManager._sortSeverityIssuesByPriority
@returns {object} Object containing the number of issues sorted by severity. | [
"Sorts",
"number",
"of",
"severity",
"issues",
"e",
".",
"g",
".",
"1",
"High",
"0",
"Medium",
"0",
"Low",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/IssueManager.js#L369-L388 | train | Returns an object with the number of issues | [
30522,
3853,
1006,
9932,
4757,
15808,
1007,
1063,
13075,
1045,
4048,
28891,
4757,
15808,
1027,
1014,
1010,
10047,
2098,
5007,
14643,
15808,
1027,
1014,
1010,
6335,
5004,
14643,
15808,
1027,
1014,
1025,
9932,
4757,
15808,
1012,
18921,
6776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
serverless/serverless | lib/utils/userStatsValidation.js | isValidObject | function isValidObject(key) {
const isValid = VALID_TRACKING_OBJECTS.indexOf(key) !== -1;
if (!isValid) {
console.log(chalk.red('Tracking Error:'));
console.log(`"${key}" is invalid tracking object. Must be one of`, VALID_TRACKING_OBJECTS);
}
return isValid;
} | javascript | function isValidObject(key) {
const isValid = VALID_TRACKING_OBJECTS.indexOf(key) !== -1;
if (!isValid) {
console.log(chalk.red('Tracking Error:'));
console.log(`"${key}" is invalid tracking object. Must be one of`, VALID_TRACKING_OBJECTS);
}
return isValid;
} | [
"function",
"isValidObject",
"(",
"key",
")",
"{",
"const",
"isValid",
"=",
"VALID_TRACKING_OBJECTS",
".",
"indexOf",
"(",
"key",
")",
"!==",
"-",
"1",
";",
"if",
"(",
"!",
"isValid",
")",
"{",
"console",
".",
"log",
"(",
"chalk",
".",
"red",
"(",
"'... | Validate tracking objects for clean events | [
"Validate",
"tracking",
"objects",
"for",
"clean",
"events"
] | 0626d5b5df06e4ed68969e324f1cb6b1b499c443 | https://github.com/serverless/serverless/blob/0626d5b5df06e4ed68969e324f1cb6b1b499c443/lib/utils/userStatsValidation.js#L41-L48 | train | Check if tracking object is valid | [
30522,
3853,
2003,
10175,
13820,
2497,
20614,
1006,
3145,
1007,
1063,
9530,
3367,
2003,
10175,
3593,
1027,
9398,
1035,
9651,
1035,
5200,
1012,
5950,
11253,
1006,
3145,
1007,
999,
1027,
1027,
1011,
1015,
1025,
2065,
1006,
999,
2003,
10175,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | findPage | function findPage(unfilteredOptions) {
var options = this.filterOptions(unfilteredOptions, 'findPage'),
itemCollection = this.forge(),
requestedColumns = options.columns;
// Set this to true or pass ?debug=true as an API option to get output
itemCollection.debug = options.debug && config.get('env') !== 'production';
// Add Filter behaviour
itemCollection.applyDefaultAndCustomFilters(options);
// Ensure only valid fields/columns are added to query
// and append default columns to fetch
if (options.columns) {
options.columns = _.intersection(options.columns, this.prototype.permittedAttributes());
options.columns = _.union(options.columns, this.prototype.defaultColumnsToFetch());
}
if (options.order) {
options.order = this.parseOrderOption(options.order, options.withRelated);
} else if (this.orderDefaultRaw) {
options.orderRaw = this.orderDefaultRaw(options);
} else if (this.orderDefaultOptions) {
options.order = this.orderDefaultOptions();
}
return itemCollection.fetchPage(options).then(function formatResponse(response) {
// Attributes are being filtered here, so they are not leaked into calling layer
// where models are serialized to json and do not do more filtering.
// Re-add and pick any computed properties that were stripped before fetchPage call.
const data = response.collection.models.map((model) => {
if (requestedColumns) {
model.attributes = _.pick(model.attributes, requestedColumns);
model._previousAttributes = _.pick(model._previousAttributes, requestedColumns);
}
return model;
});
return {
data: data,
meta: {pagination: response.pagination}
};
});
} | javascript | function findPage(unfilteredOptions) {
var options = this.filterOptions(unfilteredOptions, 'findPage'),
itemCollection = this.forge(),
requestedColumns = options.columns;
// Set this to true or pass ?debug=true as an API option to get output
itemCollection.debug = options.debug && config.get('env') !== 'production';
// Add Filter behaviour
itemCollection.applyDefaultAndCustomFilters(options);
// Ensure only valid fields/columns are added to query
// and append default columns to fetch
if (options.columns) {
options.columns = _.intersection(options.columns, this.prototype.permittedAttributes());
options.columns = _.union(options.columns, this.prototype.defaultColumnsToFetch());
}
if (options.order) {
options.order = this.parseOrderOption(options.order, options.withRelated);
} else if (this.orderDefaultRaw) {
options.orderRaw = this.orderDefaultRaw(options);
} else if (this.orderDefaultOptions) {
options.order = this.orderDefaultOptions();
}
return itemCollection.fetchPage(options).then(function formatResponse(response) {
// Attributes are being filtered here, so they are not leaked into calling layer
// where models are serialized to json and do not do more filtering.
// Re-add and pick any computed properties that were stripped before fetchPage call.
const data = response.collection.models.map((model) => {
if (requestedColumns) {
model.attributes = _.pick(model.attributes, requestedColumns);
model._previousAttributes = _.pick(model._previousAttributes, requestedColumns);
}
return model;
});
return {
data: data,
meta: {pagination: response.pagination}
};
});
} | [
"function",
"findPage",
"(",
"unfilteredOptions",
")",
"{",
"var",
"options",
"=",
"this",
".",
"filterOptions",
"(",
"unfilteredOptions",
",",
"'findPage'",
")",
",",
"itemCollection",
"=",
"this",
".",
"forge",
"(",
")",
",",
"requestedColumns",
"=",
"option... | ### Find Page
Find results by page - returns an object containing the
information about the request (page, limit), along with the
info needed for pagination (pages, total).
**response:**
{
data: [
{...}, ...
],
meta: {
pagination: {
page: __,
limit: __,
pages: __,
total: __
}
}
}
@param {Object} unfilteredOptions | [
"###",
"Find",
"Page",
"Find",
"results",
"by",
"page",
"-",
"returns",
"an",
"object",
"containing",
"the",
"information",
"about",
"the",
"request",
"(",
"page",
"limit",
")",
"along",
"with",
"the",
"info",
"needed",
"for",
"pagination",
"(",
"pages",
"... | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/base/index.js#L871-L915 | train | Find a page of records in the database. | [
30522,
3853,
2424,
13704,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1007,
1063,
13075,
7047,
1027,
2023,
1012,
11307,
7361,
9285,
1006,
4895,
8873,
21928,
26010,
16790,
2015,
1010,
1005,
2424,
13704,
1005,
1007,
1010,
8875,
26895,
18491,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/language/JSUtils.js | findAllMatchingFunctionsInText | function findAllMatchingFunctionsInText(text, searchName) {
var allFunctions = _findAllFunctionsInText(text);
var result = [];
var lines = text.split("\n");
_.forEach(allFunctions, function (functions, functionName) {
if (functionName === searchName || searchName === "*") {
functions.forEach(function (funcEntry) {
var endOffset = _getFunctionEndOffset(text, funcEntry.offsetStart);
result.push({
name: functionName,
label: funcEntry.label,
lineStart: StringUtils.offsetToLineNum(lines, funcEntry.offsetStart),
lineEnd: StringUtils.offsetToLineNum(lines, endOffset),
nameLineStart: funcEntry.location.start.line - 1,
nameLineEnd: funcEntry.location.end.line - 1,
columnStart: funcEntry.location.start.column,
columnEnd: funcEntry.location.end.column
});
});
}
});
return result;
} | javascript | function findAllMatchingFunctionsInText(text, searchName) {
var allFunctions = _findAllFunctionsInText(text);
var result = [];
var lines = text.split("\n");
_.forEach(allFunctions, function (functions, functionName) {
if (functionName === searchName || searchName === "*") {
functions.forEach(function (funcEntry) {
var endOffset = _getFunctionEndOffset(text, funcEntry.offsetStart);
result.push({
name: functionName,
label: funcEntry.label,
lineStart: StringUtils.offsetToLineNum(lines, funcEntry.offsetStart),
lineEnd: StringUtils.offsetToLineNum(lines, endOffset),
nameLineStart: funcEntry.location.start.line - 1,
nameLineEnd: funcEntry.location.end.line - 1,
columnStart: funcEntry.location.start.column,
columnEnd: funcEntry.location.end.column
});
});
}
});
return result;
} | [
"function",
"findAllMatchingFunctionsInText",
"(",
"text",
",",
"searchName",
")",
"{",
"var",
"allFunctions",
"=",
"_findAllFunctionsInText",
"(",
"text",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\... | Finds all instances of the specified searchName in "text".
Returns an Array of Objects with start and end properties.
@param text {!String} JS text to search
@param searchName {!String} function name to search for
@return {Array.<{offset:number, functionName:string}>}
Array of objects containing the start offset for each matched function name. | [
"Finds",
"all",
"instances",
"of",
"the",
"specified",
"searchName",
"in",
"text",
".",
"Returns",
"an",
"Array",
"of",
"Objects",
"with",
"start",
"and",
"end",
"properties",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSUtils.js#L488-L512 | train | Find all matching functions in text | [
30522,
3853,
2424,
8095,
18900,
8450,
11263,
27989,
11493,
18209,
1006,
3793,
1010,
3945,
18442,
1007,
1063,
13075,
2035,
11263,
27989,
2015,
1027,
1035,
2424,
8095,
11263,
27989,
11493,
18209,
1006,
3793,
1007,
1025,
13075,
2765,
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... |
ecomfe/zrender | src/mixin/Eventful.js | function (type) {
var _h = this._$handlers[type];
var eventProcessor = this._$eventProcessor;
if (_h) {
var args = arguments;
var argLen = args.length;
if (argLen > 3) {
args = arrySlice.call(args, 1);
}
var len = _h.length;
for (var i = 0; i < len;) {
var hItem = _h[i];
if (eventProcessor
&& eventProcessor.filter
&& hItem.query != null
&& !eventProcessor.filter(type, hItem.query)
) {
i++;
continue;
}
// Optimize advise from backbone
switch (argLen) {
case 1:
hItem.h.call(hItem.ctx);
break;
case 2:
hItem.h.call(hItem.ctx, args[1]);
break;
case 3:
hItem.h.call(hItem.ctx, args[1], args[2]);
break;
default:
// have more than 2 given arguments
hItem.h.apply(hItem.ctx, args);
break;
}
if (hItem.one) {
_h.splice(i, 1);
len--;
}
else {
i++;
}
}
}
eventProcessor && eventProcessor.afterTrigger
&& eventProcessor.afterTrigger(type);
return this;
} | javascript | function (type) {
var _h = this._$handlers[type];
var eventProcessor = this._$eventProcessor;
if (_h) {
var args = arguments;
var argLen = args.length;
if (argLen > 3) {
args = arrySlice.call(args, 1);
}
var len = _h.length;
for (var i = 0; i < len;) {
var hItem = _h[i];
if (eventProcessor
&& eventProcessor.filter
&& hItem.query != null
&& !eventProcessor.filter(type, hItem.query)
) {
i++;
continue;
}
// Optimize advise from backbone
switch (argLen) {
case 1:
hItem.h.call(hItem.ctx);
break;
case 2:
hItem.h.call(hItem.ctx, args[1]);
break;
case 3:
hItem.h.call(hItem.ctx, args[1], args[2]);
break;
default:
// have more than 2 given arguments
hItem.h.apply(hItem.ctx, args);
break;
}
if (hItem.one) {
_h.splice(i, 1);
len--;
}
else {
i++;
}
}
}
eventProcessor && eventProcessor.afterTrigger
&& eventProcessor.afterTrigger(type);
return this;
} | [
"function",
"(",
"type",
")",
"{",
"var",
"_h",
"=",
"this",
".",
"_$handlers",
"[",
"type",
"]",
";",
"var",
"eventProcessor",
"=",
"this",
".",
"_$eventProcessor",
";",
"if",
"(",
"_h",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"var",
"argLen... | Dispatch a event.
@param {string} type The event name. | [
"Dispatch",
"a",
"event",
"."
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/mixin/Eventful.js#L113-L168 | train | Trigger an event | [
30522,
3853,
1006,
2828,
1007,
1063,
13075,
1035,
1044,
1027,
2023,
1012,
1035,
1002,
28213,
2015,
1031,
2828,
1033,
1025,
13075,
2724,
21572,
9623,
21748,
1027,
2023,
1012,
1035,
1002,
2724,
21572,
9623,
21748,
1025,
2065,
1006,
1035,
1044... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
apache/incubator-echarts | src/chart/treemap/treemapLayout.js | filterByThreshold | function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
// visibleMin is not supported yet when no option.sort.
if (!orderBy) {
return sum;
}
var visibleMin = nodeModel.get('visibleMin');
var len = orderedChildren.length;
var deletePoint = len;
// Always travel from little value to big value.
for (var i = len - 1; i >= 0; i--) {
var value = orderedChildren[
orderBy === 'asc' ? len - i - 1 : i
].getValue();
if (value / sum * totalArea < visibleMin) {
deletePoint = i;
sum -= value;
}
}
orderBy === 'asc'
? orderedChildren.splice(0, len - deletePoint)
: orderedChildren.splice(deletePoint, len - deletePoint);
return sum;
} | javascript | function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
// visibleMin is not supported yet when no option.sort.
if (!orderBy) {
return sum;
}
var visibleMin = nodeModel.get('visibleMin');
var len = orderedChildren.length;
var deletePoint = len;
// Always travel from little value to big value.
for (var i = len - 1; i >= 0; i--) {
var value = orderedChildren[
orderBy === 'asc' ? len - i - 1 : i
].getValue();
if (value / sum * totalArea < visibleMin) {
deletePoint = i;
sum -= value;
}
}
orderBy === 'asc'
? orderedChildren.splice(0, len - deletePoint)
: orderedChildren.splice(deletePoint, len - deletePoint);
return sum;
} | [
"function",
"filterByThreshold",
"(",
"nodeModel",
",",
"totalArea",
",",
"sum",
",",
"orderBy",
",",
"orderedChildren",
")",
"{",
"// visibleMin is not supported yet when no option.sort.",
"if",
"(",
"!",
"orderBy",
")",
"{",
"return",
"sum",
";",
"}",
"var",
"vi... | Consider 'visibleMin'. Modify viewChildren and get new sum. | [
"Consider",
"visibleMin",
".",
"Modify",
"viewChildren",
"and",
"get",
"new",
"sum",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/treemapLayout.js#L311-L339 | train | Filter by Threshold | [
30522,
3853,
11307,
3762,
2705,
21898,
11614,
1006,
13045,
5302,
9247,
1010,
2561,
12069,
2050,
1010,
7680,
1010,
2344,
3762,
1010,
3641,
19339,
7389,
1007,
1063,
1013,
1013,
5710,
10020,
2003,
2025,
3569,
2664,
2043,
2053,
5724,
1012,
4066... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/MainViewManager.js | _doFindInWorkingSet | function _doFindInWorkingSet(paneId, fullPath, method) {
var result = -1;
_forEachPaneOrPanes(paneId, function (pane) {
var index = pane[method].call(pane, fullPath);
if (index >= 0) {
result = index;
return false;
}
});
return result;
} | javascript | function _doFindInWorkingSet(paneId, fullPath, method) {
var result = -1;
_forEachPaneOrPanes(paneId, function (pane) {
var index = pane[method].call(pane, fullPath);
if (index >= 0) {
result = index;
return false;
}
});
return result;
} | [
"function",
"_doFindInWorkingSet",
"(",
"paneId",
",",
"fullPath",
",",
"method",
")",
"{",
"var",
"result",
"=",
"-",
"1",
";",
"_forEachPaneOrPanes",
"(",
"paneId",
",",
"function",
"(",
"pane",
")",
"{",
"var",
"index",
"=",
"pane",
"[",
"method",
"]"... | Helper to abastract the common working set search functions
@param {!string} paneId - id of the pane to search or ALL_PANES to search all panes
@param {!string} fullPath - path of the file to locate
@param {!string} method - name of the method to use for searching
"findInViewList", "findInViewListAddedOrder" or "FindInViewListMRUOrder"
@private | [
"Helper",
"to",
"abastract",
"the",
"common",
"working",
"set",
"search",
"functions",
"@param",
"{",
"!string",
"}",
"paneId",
"-",
"id",
"of",
"the",
"pane",
"to",
"search",
"or",
"ALL_PANES",
"to",
"search",
"all",
"panes",
"@param",
"{",
"!string",
"}"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L605-L615 | train | Find the file in the working set | [
30522,
3853,
1035,
2079,
16294,
8718,
21398,
13462,
1006,
6090,
7416,
2094,
1010,
2440,
15069,
1010,
4118,
1007,
1063,
13075,
2765,
1027,
1011,
1015,
1025,
1035,
18921,
6776,
9739,
8780,
14536,
7231,
2015,
1006,
6090,
7416,
2094,
1010,
3853... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/events/isSpecialKey.js | isModifierKey | function isModifierKey(oEvent) {
var sKey = oEvent.key; // based on KeyBoardEvent.key (https://www.w3.org/TR/uievents/) and (https://www.w3.org/TR/uievents-key/)
return (sKey === 'Shift') ||
(sKey === 'Control') ||
(sKey === 'Alt') || // Chrome uses 'Alt' and 'AltGraph, IE only use 'Alt'
(sKey === 'AltGraph') || // see above -^
(sKey === 'CapsLock') ||
(sKey === 'NumLock');
} | javascript | function isModifierKey(oEvent) {
var sKey = oEvent.key; // based on KeyBoardEvent.key (https://www.w3.org/TR/uievents/) and (https://www.w3.org/TR/uievents-key/)
return (sKey === 'Shift') ||
(sKey === 'Control') ||
(sKey === 'Alt') || // Chrome uses 'Alt' and 'AltGraph, IE only use 'Alt'
(sKey === 'AltGraph') || // see above -^
(sKey === 'CapsLock') ||
(sKey === 'NumLock');
} | [
"function",
"isModifierKey",
"(",
"oEvent",
")",
"{",
"var",
"sKey",
"=",
"oEvent",
".",
"key",
";",
"// based on KeyBoardEvent.key (https://www.w3.org/TR/uievents/) and (https://www.w3.org/TR/uievents-key/)",
"return",
"(",
"sKey",
"===",
"'Shift'",
")",
"||",
"(",
"sKey... | Detect whether the pressed key is a modifier.
Modifier keys are considered:
SHIFT, CONTROL, ALT, ALTGRAPH, CAPS_LOCK, NUM_LOCK
These keys don't send characters, but modify the characters sent by other keys.
@param {jQuery.Event} oEvent The event object of the <code>keydown</code>, <code>keyup</code> or <code>keypress</code> events.
@static
@returns {boolean} True if a modifier key was pressed | [
"Detect",
"whether",
"the",
"pressed",
"key",
"is",
"a",
"modifier",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/isSpecialKey.js#L40-L48 | train | Checks if the event is a modifier key | [
30522,
3853,
2003,
5302,
4305,
8873,
2121,
14839,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
15315,
3240,
1027,
1051,
18697,
3372,
1012,
3145,
1025,
1013,
1013,
2241,
2006,
9019,
18697,
3372,
1012,
3145,
1006,
16770,
1024,
1013,
1013,
7479... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 () {
// calculate text
var sFilterText = "";
jQuery.each(this._oViewSettings.filter, function (sProperty, aValues) {
jQuery.each(aValues, function (i, aValue) {
sFilterText += aValue + ", ";
});
});
if (sFilterText.length > 0) {
var iIndex = sFilterText.lastIndexOf(", ");
sFilterText = sFilterText.substring(0, iIndex);
}
// update view
var oView = this.getView();
oView.byId("vsFilterBar").setVisible(sFilterText.length > 0);
oView.byId("vsFilterLabel").setText(sFilterText);
} | javascript | function () {
// calculate text
var sFilterText = "";
jQuery.each(this._oViewSettings.filter, function (sProperty, aValues) {
jQuery.each(aValues, function (i, aValue) {
sFilterText += aValue + ", ";
});
});
if (sFilterText.length > 0) {
var iIndex = sFilterText.lastIndexOf(", ");
sFilterText = sFilterText.substring(0, iIndex);
}
// update view
var oView = this.getView();
oView.byId("vsFilterBar").setVisible(sFilterText.length > 0);
oView.byId("vsFilterLabel").setText(sFilterText);
} | [
"function",
"(",
")",
"{",
"// calculate text",
"var",
"sFilterText",
"=",
"\"\"",
";",
"jQuery",
".",
"each",
"(",
"this",
".",
"_oViewSettings",
".",
"filter",
",",
"function",
"(",
"sProperty",
",",
"aValues",
")",
"{",
"jQuery",
".",
"each",
"(",
"aV... | Updates the filter bar in the view | [
"Updates",
"the",
"filter",
"bar",
"in",
"the",
"view"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/explored/view/master.controller.js#L294-L312 | train | Updates the filter text | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
18422,
3793,
13075,
16420,
4014,
3334,
18209,
1027,
1000,
1000,
1025,
1046,
4226,
2854,
1012,
2169,
1006,
2023,
30524,
1006,
10927,
7630,
2229,
1010,
3853,
1006,
1045,
1010,
10927,
7630,
2063,
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... | |
jquery/jquery | build/release/dist.js | editReadme | function editReadme( readme ) {
var rprev = new RegExp( Release.prevVersion, "g" );
return readme.replace( rprev, Release.newVersion );
} | javascript | function editReadme( readme ) {
var rprev = new RegExp( Release.prevVersion, "g" );
return readme.replace( rprev, Release.newVersion );
} | [
"function",
"editReadme",
"(",
"readme",
")",
"{",
"var",
"rprev",
"=",
"new",
"RegExp",
"(",
"Release",
".",
"prevVersion",
",",
"\"g\"",
")",
";",
"return",
"readme",
".",
"replace",
"(",
"rprev",
",",
"Release",
".",
"newVersion",
")",
";",
"}"
] | Replace the version in the README
@param {string} readme | [
"Replace",
"the",
"version",
"in",
"the",
"README"
] | ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3 | https://github.com/jquery/jquery/blob/ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3/build/release/dist.js#L56-L59 | train | Edit the readme with the latest release version | [
30522,
3853,
10086,
16416,
22117,
2063,
1006,
3191,
4168,
1007,
1063,
13075,
1054,
28139,
2615,
1027,
2047,
19723,
10288,
2361,
1006,
2713,
1012,
3653,
2615,
27774,
1010,
1000,
1043,
1000,
1007,
1025,
2709,
3191,
4168,
1012,
5672,
1006,
105... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function (env) {
var args = this.args.map(function (a) { return a.eval(env); }),
nameLC = this.name.toLowerCase(),
result, func;
if (nameLC in tree.functions) { // 1.
try {
func = new tree.functionCall(env, this.currentFileInfo);
result = func[nameLC].apply(func, args);
if (result != null) {
return result;
}
} catch (e) {
throw { type: e.type || "Runtime",
message: "error evaluating function `" + this.name + "`" +
(e.message ? ': ' + e.message : ''),
index: this.index, filename: this.currentFileInfo.filename };
}
}
return new tree.Call(this.name, args, this.index, this.currentFileInfo);
} | javascript | function (env) {
var args = this.args.map(function (a) { return a.eval(env); }),
nameLC = this.name.toLowerCase(),
result, func;
if (nameLC in tree.functions) { // 1.
try {
func = new tree.functionCall(env, this.currentFileInfo);
result = func[nameLC].apply(func, args);
if (result != null) {
return result;
}
} catch (e) {
throw { type: e.type || "Runtime",
message: "error evaluating function `" + this.name + "`" +
(e.message ? ': ' + e.message : ''),
index: this.index, filename: this.currentFileInfo.filename };
}
}
return new tree.Call(this.name, args, this.index, this.currentFileInfo);
} | [
"function",
"(",
"env",
")",
"{",
"var",
"args",
"=",
"this",
".",
"args",
".",
"map",
"(",
"function",
"(",
"a",
")",
"{",
"return",
"a",
".",
"eval",
"(",
"env",
")",
";",
"}",
")",
",",
"nameLC",
"=",
"this",
".",
"name",
".",
"toLowerCase",... | When evaluating a function call, we either find the function in `tree.functions` [1], in which case we call it, passing the evaluated arguments, if this returns null or we cannot find the function, we simply print it out as it appeared originally [2]. The *functions.js* file contains the built-in functions. The reason why we evaluate the arguments, is in the case where we try to pass a variable to a function, like: `saturate(@color)`. The function should receive the value, not the variable. | [
"When",
"evaluating",
"a",
"function",
"call",
"we",
"either",
"find",
"the",
"function",
"in",
"tree",
".",
"functions",
"[",
"1",
"]",
"in",
"which",
"case",
"we",
"call",
"it",
"passing",
"the",
"evaluated",
"arguments",
"if",
"this",
"returns",
"null",... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L3124-L3145 | train | eval this function | [
30522,
3853,
1006,
4372,
2615,
1007,
1063,
13075,
12098,
5620,
1027,
2023,
1012,
12098,
5620,
1012,
4949,
1006,
3853,
1006,
1037,
1007,
1063,
2709,
1037,
1012,
9345,
2140,
1006,
4372,
2615,
1007,
1025,
1065,
1007,
1010,
2171,
15472,
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... | |
SeleniumHQ/selenium | javascript/selenium-core/xpath/util.js | mapExpr | function mapExpr(array, func) {
var ret = [];
for (var i = 0; i < array.length; ++i) {
ret.push(func(array[i]));
}
return ret;
} | javascript | function mapExpr(array, func) {
var ret = [];
for (var i = 0; i < array.length; ++i) {
ret.push(func(array[i]));
}
return ret;
} | [
"function",
"mapExpr",
"(",
"array",
",",
"func",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
".",
"push",
"(",
"func",
"(",
"array",
... | Returns an array that contains the return value of the given function applied to every element of the input array. | [
"Returns",
"an",
"array",
"that",
"contains",
"the",
"return",
"value",
"of",
"the",
"given",
"function",
"applied",
"to",
"every",
"element",
"of",
"the",
"input",
"array",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/util.js#L188-L194 | train | Map an array of expressions to an array of expressions | [
30522,
3853,
4949,
10288,
18098,
1006,
9140,
1010,
4569,
2278,
1007,
1063,
13075,
2128,
2102,
1027,
1031,
1033,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
9140,
1012,
3091,
1025,
1009,
1009,
1045,
1007,
1063,
2128,
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... |
google/code-prettify | js-modules/prettify.js | appendDecorations | function appendDecorations(
sourceNode, basePos, sourceCode, langHandler, out) {
if (!sourceCode) { return; }
/** @type {JobT} */
var job = {
sourceNode: sourceNode,
pre: 1,
langExtension: null,
numberLines: null,
sourceCode: sourceCode,
spans: null,
basePos: basePos,
decorations: null
};
langHandler(job);
out.push.apply(out, job.decorations);
} | javascript | function appendDecorations(
sourceNode, basePos, sourceCode, langHandler, out) {
if (!sourceCode) { return; }
/** @type {JobT} */
var job = {
sourceNode: sourceNode,
pre: 1,
langExtension: null,
numberLines: null,
sourceCode: sourceCode,
spans: null,
basePos: basePos,
decorations: null
};
langHandler(job);
out.push.apply(out, job.decorations);
} | [
"function",
"appendDecorations",
"(",
"sourceNode",
",",
"basePos",
",",
"sourceCode",
",",
"langHandler",
",",
"out",
")",
"{",
"if",
"(",
"!",
"sourceCode",
")",
"{",
"return",
";",
"}",
"/** @type {JobT} */",
"var",
"job",
"=",
"{",
"sourceNode",
":",
"... | /* @include extractSourceSpans.js
Apply the given language handler to sourceCode and add the resulting
decorations to out.
@param {!Element} sourceNode
@param {number} basePos the index of sourceCode within the chunk of source
whose decorations are already present on out.
@param {string} sourceCode
@param {function(JobT)} langHandler
@param {DecorationsT} out | [
"/",
"*"
] | e14ed1c3c40f78fca2a11af4cb0fa251f6f997fc | https://github.com/google/code-prettify/blob/e14ed1c3c40f78fca2a11af4cb0fa251f6f997fc/js-modules/prettify.js#L258-L274 | train | Append decorations to the output array | [
30522,
3853,
10439,
10497,
3207,
27108,
10708,
1006,
3120,
3630,
3207,
1010,
2918,
6873,
2015,
1010,
3120,
16044,
1010,
11374,
11774,
3917,
1010,
2041,
1007,
1063,
2065,
1006,
999,
3120,
16044,
1007,
1063,
2709,
1025,
1065,
1013,
1008,
1008... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js | function (oModelData, oPage, sContentSuffix, oData) {
var that = this;
return LRepConnector.getContent(oModelData.layer, sContentSuffix, true).then(
function (oMetadata) {
oModelData.data = DataUtils.formatData(oData, oModelData.fileType);
oModelData.metadata = oMetadata;
that.oSelectedContentModel.setData(oModelData);
oPage.setBusy(false);
}, function () {
oPage.setBusy(false);
}
);
} | javascript | function (oModelData, oPage, sContentSuffix, oData) {
var that = this;
return LRepConnector.getContent(oModelData.layer, sContentSuffix, true).then(
function (oMetadata) {
oModelData.data = DataUtils.formatData(oData, oModelData.fileType);
oModelData.metadata = oMetadata;
that.oSelectedContentModel.setData(oModelData);
oPage.setBusy(false);
}, function () {
oPage.setBusy(false);
}
);
} | [
"function",
"(",
"oModelData",
",",
"oPage",
",",
"sContentSuffix",
",",
"oData",
")",
"{",
"var",
"that",
"=",
"this",
";",
"return",
"LRepConnector",
".",
"getContent",
"(",
"oModelData",
".",
"layer",
",",
"sContentSuffix",
",",
"true",
")",
".",
"then"... | Handler if content data was received;
Formats the received data into the correct file type and requests the file metadata.
@param {Object} oModelData - model data of current page
@param {Object} oPage - current page used to set display busy mode on/off
@param {Object} sContentSuffix - content suffix to send metadata request
@param {Object} oData - data which is received from <code>LRepConnector</code> "getContent" promise
@returns {Promise} - <code>LRepConnector</code> "getContent" promise
@private | [
"Handler",
"if",
"content",
"data",
"was",
"received",
";",
"Formats",
"the",
"received",
"data",
"into",
"the",
"correct",
"file",
"type",
"and",
"requests",
"the",
"file",
"metadata",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js#L99-L111 | train | This function is called when the content is selected | [
30522,
3853,
1006,
18168,
10244,
15150,
2696,
1010,
6728,
4270,
1010,
8040,
28040,
7666,
16093,
8873,
2595,
1010,
1051,
2850,
2696,
1007,
1063,
13075,
2008,
1027,
2023,
1025,
2709,
1048,
2890,
15042,
18256,
16761,
1012,
2131,
8663,
6528,
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... | |
TryGhost/Ghost | core/server/data/importer/index.js | function () {
var self = this;
if (self.fileToDelete === null) {
return;
}
fs.remove(self.fileToDelete, function (err) {
if (err) {
common.logging.error(new common.errors.GhostError({
err: err,
context: common.i18n.t('errors.data.importer.index.couldNotCleanUpFile.error'),
help: common.i18n.t('errors.data.importer.index.couldNotCleanUpFile.context')
}));
}
self.fileToDelete = null;
});
} | javascript | function () {
var self = this;
if (self.fileToDelete === null) {
return;
}
fs.remove(self.fileToDelete, function (err) {
if (err) {
common.logging.error(new common.errors.GhostError({
err: err,
context: common.i18n.t('errors.data.importer.index.couldNotCleanUpFile.error'),
help: common.i18n.t('errors.data.importer.index.couldNotCleanUpFile.context')
}));
}
self.fileToDelete = null;
});
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"fileToDelete",
"===",
"null",
")",
"{",
"return",
";",
"}",
"fs",
".",
"remove",
"(",
"self",
".",
"fileToDelete",
",",
"function",
"(",
"err",
")",
"{",
"if",
"... | Remove files after we're done (abstracted into a function for easier testing)
@returns {Function} | [
"Remove",
"files",
"after",
"we",
"re",
"done",
"(",
"abstracted",
"into",
"a",
"function",
"for",
"easier",
"testing",
")"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/data/importer/index.js#L104-L122 | train | Delete the file | [
30522,
3853,
1006,
1007,
30524,
1063,
2709,
1025,
1065,
1042,
2015,
1012,
6366,
1006,
2969,
1012,
5371,
3406,
9247,
12870,
1010,
3853,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
1063,
2691,
1012,
15899,
1012,
7561,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/space-unary-ops.js | verifyNonWordsHaveSpaces | function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
if (node.prefix) {
if (isFirstBangInBangBangExpression(node)) {
return;
}
if (firstToken.range[1] === secondToken.range[0]) {
context.report({
node,
messageId: "operator",
data: {
operator: firstToken.value
},
fix(fixer) {
return fixer.insertTextAfter(firstToken, " ");
}
});
}
} else {
if (firstToken.range[1] === secondToken.range[0]) {
context.report({
node,
messageId: "beforeUnaryExpressions",
data: {
token: secondToken.value
},
fix(fixer) {
return fixer.insertTextBefore(secondToken, " ");
}
});
}
}
} | javascript | function verifyNonWordsHaveSpaces(node, firstToken, secondToken) {
if (node.prefix) {
if (isFirstBangInBangBangExpression(node)) {
return;
}
if (firstToken.range[1] === secondToken.range[0]) {
context.report({
node,
messageId: "operator",
data: {
operator: firstToken.value
},
fix(fixer) {
return fixer.insertTextAfter(firstToken, " ");
}
});
}
} else {
if (firstToken.range[1] === secondToken.range[0]) {
context.report({
node,
messageId: "beforeUnaryExpressions",
data: {
token: secondToken.value
},
fix(fixer) {
return fixer.insertTextBefore(secondToken, " ");
}
});
}
}
} | [
"function",
"verifyNonWordsHaveSpaces",
"(",
"node",
",",
"firstToken",
",",
"secondToken",
")",
"{",
"if",
"(",
"node",
".",
"prefix",
")",
"{",
"if",
"(",
"isFirstBangInBangBangExpression",
"(",
"node",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"firs... | Verifies UnaryExpression, UpdateExpression and NewExpression have spaces before or after the operator
@param {ASTnode} node AST node
@param {Object} firstToken First token in the expression
@param {Object} secondToken Second token in the expression
@returns {void} | [
"Verifies",
"UnaryExpression",
"UpdateExpression",
"and",
"NewExpression",
"have",
"spaces",
"before",
"or",
"after",
"the",
"operator"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L203-L234 | train | Verify that the first token and second token have spaces | [
30522,
3853,
20410,
8540,
22104,
3270,
6961,
15327,
2015,
1006,
13045,
1010,
2034,
18715,
2368,
1010,
2117,
18715,
2368,
1007,
1063,
2065,
1006,
13045,
1012,
17576,
1007,
1063,
2065,
1006,
2003,
8873,
12096,
25153,
2378,
25153,
25153,
10288,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | countDeclarations | function countDeclarations(declarations) {
const counts = { uninitialized: 0, initialized: 0 };
for (let i = 0; i < declarations.length; i++) {
if (declarations[i].init === null) {
counts.uninitialized++;
} else {
counts.initialized++;
}
}
return counts;
} | javascript | function countDeclarations(declarations) {
const counts = { uninitialized: 0, initialized: 0 };
for (let i = 0; i < declarations.length; i++) {
if (declarations[i].init === null) {
counts.uninitialized++;
} else {
counts.initialized++;
}
}
return counts;
} | [
"function",
"countDeclarations",
"(",
"declarations",
")",
"{",
"const",
"counts",
"=",
"{",
"uninitialized",
":",
"0",
",",
"initialized",
":",
"0",
"}",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"declarations",
".",
"length",
";",
"i",
... | Counts the number of initialized and uninitialized declarations in a list of declarations
@param {ASTNode[]} declarations List of declarations
@returns {Object} Counts of 'uninitialized' and 'initialized' declarations
@private | [
"Counts",
"the",
"number",
"of",
"initialized",
"and",
"uninitialized",
"declarations",
"in",
"a",
"list",
"of",
"declarations"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L205-L216 | train | count the number of initialization of a sequence of declarations | [
30522,
3853,
4175,
3207,
20464,
25879,
8496,
1006,
8170,
2015,
1007,
1063,
9530,
3367,
9294,
1027,
1063,
4895,
5498,
20925,
3550,
1024,
30524,
3550,
1009,
1009,
1025,
1065,
2842,
1063,
9294,
1012,
3988,
3550,
1009,
1009,
1025,
1065,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function(aArray, oObject) {
var iObjectIndex = -1;
aArray.some(function(oArrayObject, iIndex) {
var aKeysArray, aKeysObject;
if (!oArrayObject) {
aKeysArray = [];
} else {
aKeysArray = Object.keys(oArrayObject);
}
if (!oObject) {
aKeysObject = [];
} else {
aKeysObject = Object.keys(oObject);
}
var bSameNumberOfAttributes = aKeysArray.length === aKeysObject.length;
var bContains = bSameNumberOfAttributes && !aKeysArray.some(function(sKey) {
return oArrayObject[sKey] !== oObject[sKey];
});
if (bContains) {
iObjectIndex = iIndex;
}
return bContains;
});
return iObjectIndex;
} | javascript | function(aArray, oObject) {
var iObjectIndex = -1;
aArray.some(function(oArrayObject, iIndex) {
var aKeysArray, aKeysObject;
if (!oArrayObject) {
aKeysArray = [];
} else {
aKeysArray = Object.keys(oArrayObject);
}
if (!oObject) {
aKeysObject = [];
} else {
aKeysObject = Object.keys(oObject);
}
var bSameNumberOfAttributes = aKeysArray.length === aKeysObject.length;
var bContains = bSameNumberOfAttributes && !aKeysArray.some(function(sKey) {
return oArrayObject[sKey] !== oObject[sKey];
});
if (bContains) {
iObjectIndex = iIndex;
}
return bContains;
});
return iObjectIndex;
} | [
"function",
"(",
"aArray",
",",
"oObject",
")",
"{",
"var",
"iObjectIndex",
"=",
"-",
"1",
";",
"aArray",
".",
"some",
"(",
"function",
"(",
"oArrayObject",
",",
"iIndex",
")",
"{",
"var",
"aKeysArray",
",",
"aKeysObject",
";",
"if",
"(",
"!",
"oArrayO... | Checks if an object is in an array or not and returns the index or -1
@param {object[]} aArray Array of objects
@param {object} oObject object that should be part of the array
@returns {int} Returns the index of the object in the array, -1 if it is not in the array
@public | [
"Checks",
"if",
"an",
"object",
"is",
"in",
"an",
"array",
"or",
"not",
"and",
"returns",
"the",
"index",
"or",
"-",
"1"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L1248-L1275 | train | Returns true if the given object is not in the array | [
30522,
3853,
1006,
9779,
11335,
2100,
1010,
1051,
16429,
20614,
1007,
1063,
13075,
22834,
2497,
20614,
22254,
10288,
1027,
1011,
1015,
1025,
9779,
11335,
2100,
1012,
2070,
1006,
3853,
1006,
1051,
2906,
9447,
16429,
20614,
1010,
2462,
13629,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js | condenseNodesReducer | function condenseNodesReducer(acc, node, idx, nodes) {
/**
* Skip any nodes that are being processed as children of an MDAST node
* through recursive calls.
*/
if (typeof acc.nextIndex === 'number' && acc.nextIndex > idx) {
return acc;
}
/**
* Processing for nodes with marks.
*/
if (node.marks && node.marks.length > 0) {
/**
* For each mark on the current node, get the number of consecutive nodes
* (starting with this one) that have the mark. Whichever mark covers the
* most nodes is used as the parent node, and the nodes with that mark are
* processed as children. If the greatest number of consecutive nodes is
* tied between multiple marks, there is no priority as to which goes
* first.
*/
const markLengths = node.marks.map(mark => getMarkLength(mark, nodes.slice(idx)));
const parentMarkLength = last(sortBy(markLengths, 'length'));
const { markType: parentType, length: parentLength } = parentMarkLength;
/**
* Since this and any consecutive nodes with the parent mark are going to
* be processed as children of the parent mark, this reducer should simply
* return the accumulator until after the last node to be covered by the
* new parent node. Here we set the next index that should be processed,
* if any.
*/
const newNextIndex = idx + parentLength;
/**
* Get the set of nodes that should be processed as children of the new
* parent mark node, run each through the reducer as children of the
* parent node, and create the parent MDAST node with the resulting
* children.
*/
const children = nodes.slice(idx, newNextIndex);
const denestedChildren = children.map(child => ({
...child,
marks: without(child.marks, parentType),
}));
const mdastChildren = denestedChildren.reduce(condenseNodesReducer, { nodes: [], parentType })
.nodes;
const mdastNode = u(parentType, mdastChildren);
return { ...acc, nodes: [...acc.nodes, mdastNode], nextIndex: newNextIndex };
}
/**
* Create the base text node, and pass in the array of mark types as data
* (helpful when optimizing/condensing the final structure).
*/
const baseNode =
typeof node.text === 'string'
? u(node.textNodeType, { marks: node.marks }, node.text)
: transform(node.node);
/**
* Recursively wrap the base text node in the individual mark nodes, if
* any exist.
*/
return { ...acc, nodes: [...acc.nodes, baseNode] };
} | javascript | function condenseNodesReducer(acc, node, idx, nodes) {
/**
* Skip any nodes that are being processed as children of an MDAST node
* through recursive calls.
*/
if (typeof acc.nextIndex === 'number' && acc.nextIndex > idx) {
return acc;
}
/**
* Processing for nodes with marks.
*/
if (node.marks && node.marks.length > 0) {
/**
* For each mark on the current node, get the number of consecutive nodes
* (starting with this one) that have the mark. Whichever mark covers the
* most nodes is used as the parent node, and the nodes with that mark are
* processed as children. If the greatest number of consecutive nodes is
* tied between multiple marks, there is no priority as to which goes
* first.
*/
const markLengths = node.marks.map(mark => getMarkLength(mark, nodes.slice(idx)));
const parentMarkLength = last(sortBy(markLengths, 'length'));
const { markType: parentType, length: parentLength } = parentMarkLength;
/**
* Since this and any consecutive nodes with the parent mark are going to
* be processed as children of the parent mark, this reducer should simply
* return the accumulator until after the last node to be covered by the
* new parent node. Here we set the next index that should be processed,
* if any.
*/
const newNextIndex = idx + parentLength;
/**
* Get the set of nodes that should be processed as children of the new
* parent mark node, run each through the reducer as children of the
* parent node, and create the parent MDAST node with the resulting
* children.
*/
const children = nodes.slice(idx, newNextIndex);
const denestedChildren = children.map(child => ({
...child,
marks: without(child.marks, parentType),
}));
const mdastChildren = denestedChildren.reduce(condenseNodesReducer, { nodes: [], parentType })
.nodes;
const mdastNode = u(parentType, mdastChildren);
return { ...acc, nodes: [...acc.nodes, mdastNode], nextIndex: newNextIndex };
}
/**
* Create the base text node, and pass in the array of mark types as data
* (helpful when optimizing/condensing the final structure).
*/
const baseNode =
typeof node.text === 'string'
? u(node.textNodeType, { marks: node.marks }, node.text)
: transform(node.node);
/**
* Recursively wrap the base text node in the individual mark nodes, if
* any exist.
*/
return { ...acc, nodes: [...acc.nodes, baseNode] };
} | [
"function",
"condenseNodesReducer",
"(",
"acc",
",",
"node",
",",
"idx",
",",
"nodes",
")",
"{",
"/**\n * Skip any nodes that are being processed as children of an MDAST node\n * through recursive calls.\n */",
"if",
"(",
"typeof",
"acc",
".",
"nextIndex",
"===",
"'numb... | Slate's AST doesn't group adjacent text nodes with the same marks - a
change in marks from letter to letter, even if some are in common, results
in a separate leaf. For example, given "**a_b_**", transformation to and
from Slate's AST will result in "**a****_b_**".
MDAST treats styling entities as distinct nodes that contain children, so a
"strong" node can contain a plain text node with a sibling "emphasis" node,
which contains more text. This reducer serves to create an optimized nested
MDAST without the typical redundancies that Slate's AST would produce if
transformed as-is. The reducer can be called recursively to produce nested
structures. | [
"Slate",
"s",
"AST",
"doesn",
"t",
"group",
"adjacent",
"text",
"nodes",
"with",
"the",
"same",
"marks",
"-",
"a",
"change",
"in",
"marks",
"from",
"letter",
"to",
"letter",
"even",
"if",
"some",
"are",
"in",
"common",
"results",
"in",
"a",
"separate",
... | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/slateRemark.js#L301-L367 | train | Reduce the nodes into a single node that is a child of the current node. | [
30522,
3853,
24707,
29428,
19847,
5596,
18796,
2099,
1006,
16222,
1010,
13045,
1010,
8909,
2595,
1010,
14164,
1007,
1063,
1013,
1008,
1008,
1008,
13558,
2151,
14164,
2008,
2024,
2108,
13995,
2004,
2336,
1997,
2019,
9108,
14083,
13045,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (mQueryOptions, oType) {
if (oType && oType.$Key) {
_Helper.addToSelect(mQueryOptions, oType.$Key.map(function (vKey) {
if (typeof vKey === "object") {
return vKey[Object.keys(vKey)[0]];
}
return vKey;
}));
}
} | javascript | function (mQueryOptions, oType) {
if (oType && oType.$Key) {
_Helper.addToSelect(mQueryOptions, oType.$Key.map(function (vKey) {
if (typeof vKey === "object") {
return vKey[Object.keys(vKey)[0]];
}
return vKey;
}));
}
} | [
"function",
"(",
"mQueryOptions",
",",
"oType",
")",
"{",
"if",
"(",
"oType",
"&&",
"oType",
".",
"$Key",
")",
"{",
"_Helper",
".",
"addToSelect",
"(",
"mQueryOptions",
",",
"oType",
".",
"$Key",
".",
"map",
"(",
"function",
"(",
"vKey",
")",
"{",
"i... | Adds the key properties of the given entity type to $select of the given query options.
@param {object} mQueryOptions
The query options
@param {object} oType
The entity type's metadata "JSON" | [
"Adds",
"the",
"key",
"properties",
"of",
"the",
"given",
"entity",
"type",
"to",
"$select",
"of",
"the",
"given",
"query",
"options",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L1027-L1036 | train | Adds the key to the select query | [
30522,
3853,
1006,
1049,
4226,
2854,
7361,
9285,
1010,
27178,
18863,
1007,
1063,
2065,
1006,
27178,
18863,
1004,
1004,
27178,
18863,
1012,
1002,
3145,
1007,
1063,
1035,
2393,
2121,
1012,
5587,
22282,
2571,
6593,
1006,
1049,
4226,
2854,
7361... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/config/config-rule.js | generateConfigsFromSchema | function generateConfigsFromSchema(schema) {
const configSet = new RuleConfigSet();
if (Array.isArray(schema)) {
for (const opt of schema) {
if (opt.enum) {
configSet.addEnums(opt.enum);
} else if (opt.type && opt.type === "object") {
if (!configSet.addObject(opt)) {
break;
}
// TODO (IanVS): support oneOf
} else {
// If we don't know how to fill in this option, don't fill in any of the following options.
break;
}
}
}
configSet.addErrorSeverity();
return configSet.ruleConfigs;
} | javascript | function generateConfigsFromSchema(schema) {
const configSet = new RuleConfigSet();
if (Array.isArray(schema)) {
for (const opt of schema) {
if (opt.enum) {
configSet.addEnums(opt.enum);
} else if (opt.type && opt.type === "object") {
if (!configSet.addObject(opt)) {
break;
}
// TODO (IanVS): support oneOf
} else {
// If we don't know how to fill in this option, don't fill in any of the following options.
break;
}
}
}
configSet.addErrorSeverity();
return configSet.ruleConfigs;
} | [
"function",
"generateConfigsFromSchema",
"(",
"schema",
")",
"{",
"const",
"configSet",
"=",
"new",
"RuleConfigSet",
"(",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"schema",
")",
")",
"{",
"for",
"(",
"const",
"opt",
"of",
"schema",
")",
"{",
... | Generate valid rule configurations based on a schema object
@param {Object} schema A rule's schema object
@returns {Array[]} Valid rule configurations | [
"Generate",
"valid",
"rule",
"configurations",
"based",
"on",
"a",
"schema",
"object"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/config/config-rule.js#L273-L295 | train | Generate a RuleConfigSet from a schema | [
30522,
3853,
9699,
8663,
8873,
5620,
19699,
22225,
5403,
2863,
1006,
8040,
28433,
1007,
1063,
9530,
3367,
9530,
8873,
5620,
3388,
1027,
2047,
3627,
8663,
8873,
5620,
3388,
1006,
1007,
1025,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
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... |
jgraph/mxgraph | javascript/mxClient.js | mxRhombus | function mxRhombus(bounds, fill, stroke, strokewidth)
{
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | javascript | function mxRhombus(bounds, fill, stroke, strokewidth)
{
mxShape.call(this);
this.bounds = bounds;
this.fill = fill;
this.stroke = stroke;
this.strokewidth = (strokewidth != null) ? strokewidth : 1;
} | [
"function",
"mxRhombus",
"(",
"bounds",
",",
"fill",
",",
"stroke",
",",
"strokewidth",
")",
"{",
"mxShape",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"bounds",
"=",
"bounds",
";",
"this",
".",
"fill",
"=",
"fill",
";",
"this",
".",
"stroke",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxRhombus
Extends <mxShape> to implement a rhombus (aka diamond) shape.
This shape is registered under <mxConstants.SHAPE_RHOMBUS>
in <mxCellRenderer>.
Constructor: mxRhombus
Constructs a new rhombus shape.
Parameters:
bounds - <mxRectangle> that defines the bounds. This is stored in
<mxShape.bounds>.
fill - String that defines the fill color. This is stored in <fill>.
stroke - String that defines the stroke color. This is stored in <stroke>.
strokewidth - Optional integer that defines the stroke width. Default is
1. This is stored in <strokewidth>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxRhombus"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L25266-L25273 | train | This class represents a rhombus shape. | [
30522,
3853,
25630,
25032,
5358,
8286,
1006,
19202,
1010,
6039,
1010,
6909,
1010,
6909,
9148,
11927,
2232,
1007,
1063,
25630,
7377,
5051,
1012,
2655,
1006,
2023,
1007,
1025,
2023,
1012,
19202,
1027,
19202,
1025,
2023,
1012,
6039,
1027,
6039... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
pixijs/pixi.js | packages/text/src/TextStyle.js | getColor | function getColor(color)
{
if (!Array.isArray(color))
{
return getSingleColor(color);
}
else
{
for (let i = 0; i < color.length; ++i)
{
color[i] = getSingleColor(color[i]);
}
return color;
}
} | javascript | function getColor(color)
{
if (!Array.isArray(color))
{
return getSingleColor(color);
}
else
{
for (let i = 0; i < color.length; ++i)
{
color[i] = getSingleColor(color[i]);
}
return color;
}
} | [
"function",
"getColor",
"(",
"color",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"color",
")",
")",
"{",
"return",
"getSingleColor",
"(",
"color",
")",
";",
"}",
"else",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"color",
... | Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string.
This version can also convert array of colors
@private
@param {number|number[]} color
@return {string} The color as a string. | [
"Utility",
"function",
"to",
"convert",
"hexadecimal",
"colors",
"to",
"strings",
"and",
"simply",
"return",
"the",
"color",
"if",
"it",
"s",
"a",
"string",
".",
"This",
"version",
"can",
"also",
"convert",
"array",
"of",
"colors"
] | 99ae03b7565ae7ca5a6de633b0a277f7128fa4d0 | https://github.com/pixijs/pixi.js/blob/99ae03b7565ae7ca5a6de633b0a277f7128fa4d0/packages/text/src/TextStyle.js#L751-L766 | train | getColor returns the color of the node | [
30522,
3853,
2131,
18717,
1006,
3609,
1007,
1063,
2065,
1006,
999,
9140,
1012,
18061,
11335,
2100,
1006,
3609,
1007,
1007,
1063,
2709,
4152,
2075,
2571,
18717,
1006,
3609,
1007,
1025,
1065,
2842,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/angular | tools/gulp-tasks/tools-build.js | tsc | function tsc(projectPath, done) {
const path = require('path');
const platformScriptPath = require('./platform-script-path');
const childProcess = require('child_process');
childProcess
.spawn(
path.join(__dirname, platformScriptPath('../../node_modules/.bin/tsc')),
['-p', path.join(__dirname, '../..', projectPath)], {stdio: 'inherit'})
.on('close', done);
} | javascript | function tsc(projectPath, done) {
const path = require('path');
const platformScriptPath = require('./platform-script-path');
const childProcess = require('child_process');
childProcess
.spawn(
path.join(__dirname, platformScriptPath('../../node_modules/.bin/tsc')),
['-p', path.join(__dirname, '../..', projectPath)], {stdio: 'inherit'})
.on('close', done);
} | [
"function",
"tsc",
"(",
"projectPath",
",",
"done",
")",
"{",
"const",
"path",
"=",
"require",
"(",
"'path'",
")",
";",
"const",
"platformScriptPath",
"=",
"require",
"(",
"'./platform-script-path'",
")",
";",
"const",
"childProcess",
"=",
"require",
"(",
"'... | @license
Copyright Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE file at https://angular.io/license | [
"@license",
"Copyright",
"Google",
"Inc",
".",
"All",
"Rights",
"Reserved",
"."
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/tools/gulp-tasks/tools-build.js#L9-L19 | train | tsc - p projectPath | [
30522,
3853,
24529,
2278,
1006,
2622,
15069,
1010,
2589,
1007,
1063,
9530,
3367,
4130,
1027,
5478,
1006,
1005,
4130,
1005,
1007,
1025,
9530,
3367,
7248,
23235,
15069,
1027,
5478,
1006,
1005,
1012,
1013,
4132,
1011,
5896,
1011,
4130,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | bits/73_wbbin.js | write_BrtFileVersion | function write_BrtFileVersion(data, o) {
if(!o) o = new_buf(127);
for(var i = 0; i != 4; ++i) o.write_shift(4, 0);
write_XLWideString("SheetJS", o);
write_XLWideString(XLSX.version, o);
write_XLWideString(XLSX.version, o);
write_XLWideString("7262", o);
o.length = o.l;
return o.length > o.l ? o.slice(0, o.l) : o;
} | javascript | function write_BrtFileVersion(data, o) {
if(!o) o = new_buf(127);
for(var i = 0; i != 4; ++i) o.write_shift(4, 0);
write_XLWideString("SheetJS", o);
write_XLWideString(XLSX.version, o);
write_XLWideString(XLSX.version, o);
write_XLWideString("7262", o);
o.length = o.l;
return o.length > o.l ? o.slice(0, o.l) : o;
} | [
"function",
"write_BrtFileVersion",
"(",
"data",
",",
"o",
")",
"{",
"if",
"(",
"!",
"o",
")",
"o",
"=",
"new_buf",
"(",
"127",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"!=",
"4",
";",
"++",
"i",
")",
"o",
".",
"write_shift",
"("... | /* [MS-XLSB] 2.4.649 BrtFileVersion | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"4",
".",
"649",
"BrtFileVersion"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/73_wbbin.js#L202-L211 | train | write BrtFileVersion - Write BrtFile version | [
30522,
3853,
4339,
1035,
7987,
24475,
9463,
27774,
1006,
2951,
1010,
1051,
1007,
1063,
2065,
1006,
999,
1051,
1007,
1051,
1027,
2047,
1035,
20934,
2546,
1006,
13029,
1007,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
999,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/interimElement/interimElement.js | configureScopeAndTransitions | function configureScopeAndTransitions(options) {
options = options || { };
if (options.template) {
options.template = $mdUtil.processTemplate(options.template);
}
return angular.extend({
preserveScope: false,
cancelAutoHide : angular.noop,
scope: options.scope || $rootScope.$new(options.isolateScope),
/**
* Default usage to enable $animate to transition-in; can be easily overridden via 'options'
*/
onShow: function transitionIn(scope, element, options) {
return $animate.enter(element, options.parent);
},
/**
* Default usage to enable $animate to transition-out; can be easily overridden via 'options'
*/
onRemove: function transitionOut(scope, element) {
// Element could be undefined if a new element is shown before
// the old one finishes compiling.
return element && $animate.leave(element) || $q.when();
}
}, options);
} | javascript | function configureScopeAndTransitions(options) {
options = options || { };
if (options.template) {
options.template = $mdUtil.processTemplate(options.template);
}
return angular.extend({
preserveScope: false,
cancelAutoHide : angular.noop,
scope: options.scope || $rootScope.$new(options.isolateScope),
/**
* Default usage to enable $animate to transition-in; can be easily overridden via 'options'
*/
onShow: function transitionIn(scope, element, options) {
return $animate.enter(element, options.parent);
},
/**
* Default usage to enable $animate to transition-out; can be easily overridden via 'options'
*/
onRemove: function transitionOut(scope, element) {
// Element could be undefined if a new element is shown before
// the old one finishes compiling.
return element && $animate.leave(element) || $q.when();
}
}, options);
} | [
"function",
"configureScopeAndTransitions",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"options",
".",
"template",
")",
"{",
"options",
".",
"template",
"=",
"$mdUtil",
".",
"processTemplate",
"(",
"options",
".",
... | Prepare optional isolated scope and prepare $animate with default enter and leave
transitions for the new element instance. | [
"Prepare",
"optional",
"isolated",
"scope",
"and",
"prepare",
"$animate",
"with",
"default",
"enter",
"and",
"leave",
"transitions",
"for",
"the",
"new",
"element",
"instance",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interimElement/interimElement.js#L572-L600 | train | Configure the scope and transitions | [
30522,
3853,
9530,
8873,
27390,
2229,
16186,
5685,
6494,
3619,
22753,
2015,
1006,
7047,
1007,
1063,
7047,
1027,
7047,
1064,
1064,
1063,
1065,
1025,
2065,
1006,
7047,
1012,
23561,
1007,
1063,
7047,
1012,
23561,
1027,
1002,
9108,
21823,
2140,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/registry/componentRegistry.js | resolveWhen | function resolveWhen() {
var dfd = pendings[handle];
if (dfd) {
dfd.forEach(function (promise) {
promise.resolve(instance);
});
delete pendings[handle];
}
} | javascript | function resolveWhen() {
var dfd = pendings[handle];
if (dfd) {
dfd.forEach(function (promise) {
promise.resolve(instance);
});
delete pendings[handle];
}
} | [
"function",
"resolveWhen",
"(",
")",
"{",
"var",
"dfd",
"=",
"pendings",
"[",
"handle",
"]",
";",
"if",
"(",
"dfd",
")",
"{",
"dfd",
".",
"forEach",
"(",
"function",
"(",
"promise",
")",
"{",
"promise",
".",
"resolve",
"(",
"instance",
")",
";",
"}... | Resolve any pending promises for this instance | [
"Resolve",
"any",
"pending",
"promises",
"for",
"this",
"instance"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L83-L91 | train | resolve when the handle is not in pendings | [
30522,
3853,
10663,
2860,
10222,
1006,
1007,
1063,
13075,
1040,
2546,
2094,
1027,
14223,
2015,
1031,
5047,
1033,
1025,
2065,
1006,
1040,
2546,
2094,
1007,
1063,
1040,
2546,
2094,
1012,
18921,
6776,
1006,
3853,
1006,
4872,
1007,
1063,
4872,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | parse | function parse(elementOrHtml, config) {
wysihtml5.lang.object(currentRules).merge(defaultRules).merge(config.rules).get();
var context = config.context || elementOrHtml.ownerDocument || document,
fragment = context.createDocumentFragment(),
isString = typeof(elementOrHtml) === "string",
clearInternals = false,
element,
newNode,
firstChild;
if (config.clearInternals === true) {
clearInternals = true;
}
if (isString) {
element = wysihtml5.dom.getAsDom(elementOrHtml, context);
} else {
element = elementOrHtml;
}
if (currentRules.selectors) {
_applySelectorRules(element, currentRules.selectors);
}
while (element.firstChild) {
firstChild = element.firstChild;
newNode = _convert(firstChild, config.cleanUp, clearInternals, config.uneditableClass);
if (newNode) {
fragment.appendChild(newNode);
}
if (firstChild !== newNode) {
element.removeChild(firstChild);
}
}
if (config.unjoinNbsps) {
// replace joined non-breakable spaces with unjoined
var txtnodes = wysihtml5.dom.getTextNodes(fragment);
for (var n = txtnodes.length; n--;) {
txtnodes[n].nodeValue = txtnodes[n].nodeValue.replace(/([\S\u00A0])\u00A0/gi, "$1 ");
}
}
// Clear element contents
element.innerHTML = "";
// Insert new DOM tree
element.appendChild(fragment);
return isString ? wysihtml5.quirks.getCorrectInnerHTML(element) : element;
} | javascript | function parse(elementOrHtml, config) {
wysihtml5.lang.object(currentRules).merge(defaultRules).merge(config.rules).get();
var context = config.context || elementOrHtml.ownerDocument || document,
fragment = context.createDocumentFragment(),
isString = typeof(elementOrHtml) === "string",
clearInternals = false,
element,
newNode,
firstChild;
if (config.clearInternals === true) {
clearInternals = true;
}
if (isString) {
element = wysihtml5.dom.getAsDom(elementOrHtml, context);
} else {
element = elementOrHtml;
}
if (currentRules.selectors) {
_applySelectorRules(element, currentRules.selectors);
}
while (element.firstChild) {
firstChild = element.firstChild;
newNode = _convert(firstChild, config.cleanUp, clearInternals, config.uneditableClass);
if (newNode) {
fragment.appendChild(newNode);
}
if (firstChild !== newNode) {
element.removeChild(firstChild);
}
}
if (config.unjoinNbsps) {
// replace joined non-breakable spaces with unjoined
var txtnodes = wysihtml5.dom.getTextNodes(fragment);
for (var n = txtnodes.length; n--;) {
txtnodes[n].nodeValue = txtnodes[n].nodeValue.replace(/([\S\u00A0])\u00A0/gi, "$1 ");
}
}
// Clear element contents
element.innerHTML = "";
// Insert new DOM tree
element.appendChild(fragment);
return isString ? wysihtml5.quirks.getCorrectInnerHTML(element) : element;
} | [
"function",
"parse",
"(",
"elementOrHtml",
",",
"config",
")",
"{",
"wysihtml5",
".",
"lang",
".",
"object",
"(",
"currentRules",
")",
".",
"merge",
"(",
"defaultRules",
")",
".",
"merge",
"(",
"config",
".",
"rules",
")",
".",
"get",
"(",
")",
";",
... | Iterates over all childs of the element, recreates them, appends them into a document fragment
which later replaces the entire body content | [
"Iterates",
"over",
"all",
"childs",
"of",
"the",
"element",
"recreates",
"them",
"appends",
"them",
"into",
"a",
"document",
"fragment",
"which",
"later",
"replaces",
"the",
"entire",
"body",
"content"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L5888-L5939 | train | Parses the given element or html using the given rules. | [
30522,
3853,
11968,
3366,
1006,
5783,
2953,
11039,
19968,
1010,
9530,
8873,
2290,
1007,
1063,
1059,
7274,
19190,
21246,
2140,
2629,
1012,
11374,
1012,
4874,
1006,
2783,
6820,
4244,
1007,
1012,
13590,
1006,
12398,
6820,
4244,
1007,
1012,
135... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Manifest.js | function(bAsync) {
// extract the i18n URI from the manifest
var oManifest = this._oRawManifest,
sI18n = (oManifest["sap.app"] && oManifest["sap.app"]["i18n"]) || "i18n/i18n.properties",
oI18nURI = new URI(sI18n);
// load the ResourceBundle relative to the manifest
return ResourceBundle.create({
url: this._resolveUri(oI18nURI, "manifest").toString(),
async: bAsync
});
} | javascript | function(bAsync) {
// extract the i18n URI from the manifest
var oManifest = this._oRawManifest,
sI18n = (oManifest["sap.app"] && oManifest["sap.app"]["i18n"]) || "i18n/i18n.properties",
oI18nURI = new URI(sI18n);
// load the ResourceBundle relative to the manifest
return ResourceBundle.create({
url: this._resolveUri(oI18nURI, "manifest").toString(),
async: bAsync
});
} | [
"function",
"(",
"bAsync",
")",
"{",
"// extract the i18n URI from the manifest",
"var",
"oManifest",
"=",
"this",
".",
"_oRawManifest",
",",
"sI18n",
"=",
"(",
"oManifest",
"[",
"\"sap.app\"",
"]",
"&&",
"oManifest",
"[",
"\"sap.app\"",
"]",
"[",
"\"i18n\"",
"]... | Loads the ResourceBundle which is defined in the manifest
in "sap.app/i18n".
@param {boolean} bAsync flag, whether to load the ResourceBundle async or not
@return {Promise|ResourceBundle} Promise which resolves with the ResourceBundle (async) or the ResourceBundle itself (sync)
@private | [
"Loads",
"the",
"ResourceBundle",
"which",
"is",
"defined",
"in",
"the",
"manifest",
"in",
"sap",
".",
"app",
"/",
"i18n",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Manifest.js#L270-L283 | train | Returns a ResourceBundle object for the given i18n URI | [
30522,
3853,
1006,
19021,
6038,
2278,
1007,
1063,
1013,
1013,
14817,
1996,
1045,
15136,
2078,
24471,
2072,
2013,
1996,
19676,
13075,
16640,
29323,
3367,
1027,
2023,
1012,
1035,
2030,
10376,
20799,
14081,
1010,
9033,
15136,
2078,
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... | |
aframevr/aframe | src/components/animation.js | function (cb) {
var componentName;
var data = this.data;
var el = this.el;
var self = this;
if (data.from !== '') { return false; }
if (!data.property.startsWith(STRING_COMPONENTS)) { return false; }
componentName = splitDot(data.property)[1];
if (el.components[componentName]) { return false; }
el.addEventListener('componentinitialized', function wait (evt) {
if (evt.detail.name !== componentName) { return; }
cb();
// Since the config was created async, create the animation now since we missed it
// earlier.
self.animation = anime(self.config);
el.removeEventListener('componentinitialized', wait);
});
return true;
} | javascript | function (cb) {
var componentName;
var data = this.data;
var el = this.el;
var self = this;
if (data.from !== '') { return false; }
if (!data.property.startsWith(STRING_COMPONENTS)) { return false; }
componentName = splitDot(data.property)[1];
if (el.components[componentName]) { return false; }
el.addEventListener('componentinitialized', function wait (evt) {
if (evt.detail.name !== componentName) { return; }
cb();
// Since the config was created async, create the animation now since we missed it
// earlier.
self.animation = anime(self.config);
el.removeEventListener('componentinitialized', wait);
});
return true;
} | [
"function",
"(",
"cb",
")",
"{",
"var",
"componentName",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"data",
".",
"from",
"!==",
"''",
")",
"{",
"retur... | Wait for component to initialize. | [
"Wait",
"for",
"component",
"to",
"initialize",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L439-L461 | train | Returns true if the component is already initialized | [
30522,
3853,
1006,
17324,
1007,
1063,
13075,
6922,
18442,
1025,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
3449,
1027,
2023,
1012,
3449,
1025,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
2951,
1012,
2013,
999,
1027,
1027,
1005,
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... | |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | BoundedCache | function BoundedCache(newMaxSize) {
var maxSize = newMaxSize;
var map = {};
var size = 0;
var counter = -1;
/**
* Adds a key-value pair to the cache. If the cache is at its size limit,
* the least-recently used entry is evicted.
*/
this.put = function(key, value) {
if (map[key]) {
// entry already exists
map[key] = { usage: ++counter, value: value };
}
else {
map[key] = { usage: ++counter, value: value };
++size;
if (size > maxSize) {
// remove the least recently used item
var minUsage = counter;
var keyToRemove = key;
for (var key in map) {
if (map[key].usage < minUsage) {
minUsage = map[key].usage;
keyToRemove = key;
}
}
this.remove(keyToRemove);
}
}
};
/**
* Returns a cache item by its key, and updates its use status.
*/
this.get = function(key) {
if (map[key]) {
map[key].usage = ++counter;
return map[key].value;
}
return null;
};
/**
* Removes a cache item by its key.
*/
this.remove = function(key) {
if (map[key]) {
delete map[key];
--size;
if (size == 0) {
counter = -1;
}
}
}
/**
* Clears all entries in the cache.
*/
this.clear = function() {
map = {};
size = 0;
counter = -1;
};
} | javascript | function BoundedCache(newMaxSize) {
var maxSize = newMaxSize;
var map = {};
var size = 0;
var counter = -1;
/**
* Adds a key-value pair to the cache. If the cache is at its size limit,
* the least-recently used entry is evicted.
*/
this.put = function(key, value) {
if (map[key]) {
// entry already exists
map[key] = { usage: ++counter, value: value };
}
else {
map[key] = { usage: ++counter, value: value };
++size;
if (size > maxSize) {
// remove the least recently used item
var minUsage = counter;
var keyToRemove = key;
for (var key in map) {
if (map[key].usage < minUsage) {
minUsage = map[key].usage;
keyToRemove = key;
}
}
this.remove(keyToRemove);
}
}
};
/**
* Returns a cache item by its key, and updates its use status.
*/
this.get = function(key) {
if (map[key]) {
map[key].usage = ++counter;
return map[key].value;
}
return null;
};
/**
* Removes a cache item by its key.
*/
this.remove = function(key) {
if (map[key]) {
delete map[key];
--size;
if (size == 0) {
counter = -1;
}
}
}
/**
* Clears all entries in the cache.
*/
this.clear = function() {
map = {};
size = 0;
counter = -1;
};
} | [
"function",
"BoundedCache",
"(",
"newMaxSize",
")",
"{",
"var",
"maxSize",
"=",
"newMaxSize",
";",
"var",
"map",
"=",
"{",
"}",
";",
"var",
"size",
"=",
"0",
";",
"var",
"counter",
"=",
"-",
"1",
";",
"/**\n * Adds a key-value pair to the cache. If the cac... | Cache class.
@param newMaxSize the maximum number of entries to keep in the cache. | [
"Cache",
"class",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L1292-L1362 | train | A cache that is a cache of cache items. | [
30522,
3853,
10351,
3540,
5403,
1006,
2047,
17848,
5332,
4371,
1007,
1063,
13075,
4098,
5332,
4371,
1027,
2047,
17848,
5332,
4371,
1025,
13075,
4949,
1027,
1063,
1065,
1025,
13075,
2946,
1027,
1014,
1025,
13075,
4675,
1027,
1011,
1015,
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... |
jgraph/mxgraph | javascript/mxClient.js | function(bounds, p1, p2)
{
var top = bounds.y;
var left = bounds.x;
var bottom = top + bounds.height;
var right = left + bounds.width;
// Find min and max X for the segment
var minX = p1.x;
var maxX = p2.x;
if (p1.x > p2.x)
{
minX = p2.x;
maxX = p1.x;
}
// Find the intersection of the segment's and rectangle's x-projections
if (maxX > right)
{
maxX = right;
}
if (minX < left)
{
minX = left;
}
if (minX > maxX) // If their projections do not intersect return false
{
return false;
}
// Find corresponding min and max Y for min and max X we found before
var minY = p1.y;
var maxY = p2.y;
var dx = p2.x - p1.x;
if (Math.abs(dx) > 0.0000001)
{
var a = (p2.y - p1.y) / dx;
var b = p1.y - a * p1.x;
minY = a * minX + b;
maxY = a * maxX + b;
}
if (minY > maxY)
{
var tmp = maxY;
maxY = minY;
minY = tmp;
}
// Find the intersection of the segment's and rectangle's y-projections
if (maxY > bottom)
{
maxY = bottom;
}
if (minY < top)
{
minY = top;
}
if (minY > maxY) // If Y-projections do not intersect return false
{
return false;
}
return true;
} | javascript | function(bounds, p1, p2)
{
var top = bounds.y;
var left = bounds.x;
var bottom = top + bounds.height;
var right = left + bounds.width;
// Find min and max X for the segment
var minX = p1.x;
var maxX = p2.x;
if (p1.x > p2.x)
{
minX = p2.x;
maxX = p1.x;
}
// Find the intersection of the segment's and rectangle's x-projections
if (maxX > right)
{
maxX = right;
}
if (minX < left)
{
minX = left;
}
if (minX > maxX) // If their projections do not intersect return false
{
return false;
}
// Find corresponding min and max Y for min and max X we found before
var minY = p1.y;
var maxY = p2.y;
var dx = p2.x - p1.x;
if (Math.abs(dx) > 0.0000001)
{
var a = (p2.y - p1.y) / dx;
var b = p1.y - a * p1.x;
minY = a * minX + b;
maxY = a * maxX + b;
}
if (minY > maxY)
{
var tmp = maxY;
maxY = minY;
minY = tmp;
}
// Find the intersection of the segment's and rectangle's y-projections
if (maxY > bottom)
{
maxY = bottom;
}
if (minY < top)
{
minY = top;
}
if (minY > maxY) // If Y-projections do not intersect return false
{
return false;
}
return true;
} | [
"function",
"(",
"bounds",
",",
"p1",
",",
"p2",
")",
"{",
"var",
"top",
"=",
"bounds",
".",
"y",
";",
"var",
"left",
"=",
"bounds",
".",
"x",
";",
"var",
"bottom",
"=",
"top",
"+",
"bounds",
".",
"height",
";",
"var",
"right",
"=",
"left",
"+"... | Function: rectangleIntersectsSegment
Returns true if the given rectangle intersects the given segment.
Parameters:
bounds - <mxRectangle> that represents the rectangle.
p1 - <mxPoint> that represents the first point of the segment.
p2 - <mxPoint> that represents the second point of the segment. | [
"Function",
":",
"rectangleIntersectsSegment"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L4547-L4617 | train | Finds the intersection of two points of the given rectangle | [
30522,
3853,
1006,
19202,
1010,
1052,
2487,
1010,
1052,
2475,
1007,
1063,
13075,
2327,
1027,
19202,
1012,
1061,
1025,
13075,
2187,
1027,
19202,
1012,
1060,
1025,
13075,
3953,
1027,
2327,
1009,
19202,
1012,
4578,
1025,
13075,
2157,
1027,
218... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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_PtgName | function parse_PtgName(blob, length, opts) {
var type = (blob.read_shift(1) >>> 5) & 0x03;
var w = (!opts || (opts.biff >= 8)) ? 4 : 2;
var nameindex = blob.read_shift(w);
switch(opts.biff) {
case 2: blob.l += 5; break;
case 3: case 4: blob.l += 8; break;
case 5: blob.l += 12; break;
}
return [type, 0, nameindex];
} | javascript | function parse_PtgName(blob, length, opts) {
var type = (blob.read_shift(1) >>> 5) & 0x03;
var w = (!opts || (opts.biff >= 8)) ? 4 : 2;
var nameindex = blob.read_shift(w);
switch(opts.biff) {
case 2: blob.l += 5; break;
case 3: case 4: blob.l += 8; break;
case 5: blob.l += 12; break;
}
return [type, 0, nameindex];
} | [
"function",
"parse_PtgName",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"type",
"=",
"(",
"blob",
".",
"read_shift",
"(",
"1",
")",
">>>",
"5",
")",
"&",
"0x03",
";",
"var",
"w",
"=",
"(",
"!",
"opts",
"||",
"(",
"opts",
".",
"bi... | /* [MS-XLS] 2.5.198.76 ; [MS-XLSB] 2.5.97.60 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"198",
".",
"76",
";",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"5",
".",
"97",
".",
"60"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L10552-L10562 | train | Parse a PTG name | [
30522,
3853,
11968,
3366,
1035,
13866,
16989,
4168,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
2828,
1027,
1006,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1015,
1007,
1028,
1028,
1028,
1019,
1007,
1004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/animation.js | function () {
this.updateConfig();
this.animation.began = true;
this.time = 0;
this.animationIsPlaying = true;
this.stopRelatedAnimations();
this.el.emit('animationbegin', this.eventDetail, false);
} | javascript | function () {
this.updateConfig();
this.animation.began = true;
this.time = 0;
this.animationIsPlaying = true;
this.stopRelatedAnimations();
this.el.emit('animationbegin', this.eventDetail, false);
} | [
"function",
"(",
")",
"{",
"this",
".",
"updateConfig",
"(",
")",
";",
"this",
".",
"animation",
".",
"began",
"=",
"true",
";",
"this",
".",
"time",
"=",
"0",
";",
"this",
".",
"animationIsPlaying",
"=",
"true",
";",
"this",
".",
"stopRelatedAnimation... | This is before animation start (including from startEvents).
Set to initial state (config.from, time = 0, seekTime = 0). | [
"This",
"is",
"before",
"animation",
"start",
"(",
"including",
"from",
"startEvents",
")",
".",
"Set",
"to",
"initial",
"state",
"(",
"config",
".",
"from",
"time",
"=",
"0",
"seekTime",
"=",
"0",
")",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L190-L197 | train | Animation begin | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
10651,
8663,
8873,
2290,
1006,
1007,
1025,
2023,
1012,
7284,
1012,
2211,
1027,
2995,
1025,
2023,
1012,
2051,
1027,
1014,
1025,
2023,
1012,
7284,
2483,
13068,
2075,
1027,
2995,
1025,
2023,
1012,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/CloseOthers/main.js | initializeCommands | function initializeCommands() {
var prefs = getPreferences();
CommandManager.register(Strings.CMD_FILE_CLOSE_BELOW, closeBelow, function () {
handleClose(closeBelow);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_OTHERS, closeOthers, function () {
handleClose(closeOthers);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_ABOVE, closeAbove, function () {
handleClose(closeAbove);
});
if (prefs.closeBelow) {
workingSetListCmenu.addMenuItem(closeBelow, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeOthers) {
workingSetListCmenu.addMenuItem(closeOthers, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeAbove) {
workingSetListCmenu.addMenuItem(closeAbove, "", Menus.AFTER, Commands.FILE_CLOSE);
}
menuEntriesShown = prefs;
} | javascript | function initializeCommands() {
var prefs = getPreferences();
CommandManager.register(Strings.CMD_FILE_CLOSE_BELOW, closeBelow, function () {
handleClose(closeBelow);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_OTHERS, closeOthers, function () {
handleClose(closeOthers);
});
CommandManager.register(Strings.CMD_FILE_CLOSE_ABOVE, closeAbove, function () {
handleClose(closeAbove);
});
if (prefs.closeBelow) {
workingSetListCmenu.addMenuItem(closeBelow, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeOthers) {
workingSetListCmenu.addMenuItem(closeOthers, "", Menus.AFTER, Commands.FILE_CLOSE);
}
if (prefs.closeAbove) {
workingSetListCmenu.addMenuItem(closeAbove, "", Menus.AFTER, Commands.FILE_CLOSE);
}
menuEntriesShown = prefs;
} | [
"function",
"initializeCommands",
"(",
")",
"{",
"var",
"prefs",
"=",
"getPreferences",
"(",
")",
";",
"CommandManager",
".",
"register",
"(",
"Strings",
".",
"CMD_FILE_CLOSE_BELOW",
",",
"closeBelow",
",",
"function",
"(",
")",
"{",
"handleClose",
"(",
"close... | Register the Commands and add the Menu Items, if required | [
"Register",
"the",
"Commands",
"and",
"add",
"the",
"Menu",
"Items",
"if",
"required"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CloseOthers/main.js#L157-L180 | train | Initializes the Commands | [
30522,
3853,
3988,
4697,
9006,
2386,
5104,
1006,
1007,
1063,
13075,
3653,
10343,
1027,
2131,
28139,
25523,
2015,
1006,
1007,
1025,
3094,
24805,
4590,
1012,
4236,
1006,
7817,
1012,
4642,
2094,
1035,
5371,
1035,
2485,
1035,
2917,
1010,
2485,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/keyword-spacing.js | checkSpacingAroundFirstToken | function checkSpacingAroundFirstToken(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken && firstToken.type === "Keyword") {
checkSpacingAround(firstToken);
}
} | javascript | function checkSpacingAroundFirstToken(node) {
const firstToken = node && sourceCode.getFirstToken(node);
if (firstToken && firstToken.type === "Keyword") {
checkSpacingAround(firstToken);
}
} | [
"function",
"checkSpacingAroundFirstToken",
"(",
"node",
")",
"{",
"const",
"firstToken",
"=",
"node",
"&&",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
";",
"if",
"(",
"firstToken",
"&&",
"firstToken",
".",
"type",
"===",
"\"Keyword\"",
")",
"{",
... | Reports the first token of a given node if the first token is a keyword
and usage of spacing around the token is invalid.
@param {ASTNode|null} node - A node to report.
@returns {void} | [
"Reports",
"the",
"first",
"token",
"of",
"a",
"given",
"node",
"if",
"the",
"first",
"token",
"is",
"a",
"keyword",
"and",
"usage",
"of",
"spacing",
"around",
"the",
"token",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L307-L313 | train | Check spacing around first token | [
30522,
3853,
14148,
19498,
28234,
22494,
4859,
8873,
12096,
18715,
2368,
1006,
13045,
1007,
1063,
9530,
3367,
2034,
18715,
2368,
1027,
13045,
1004,
1004,
3120,
16044,
1012,
2131,
8873,
12096,
18715,
2368,
1006,
13045,
1007,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
swimlane/ngx-datatable | release/utils/math.js | getContentWidth | function getContentWidth(allColumns, defaultColWidth) {
if (defaultColWidth === void 0) { defaultColWidth = 300; }
var contentWidth = 0;
for (var _i = 0, allColumns_1 = allColumns; _i < allColumns_1.length; _i++) {
var column = allColumns_1[_i];
contentWidth += (column.width || defaultColWidth);
}
return contentWidth;
} | javascript | function getContentWidth(allColumns, defaultColWidth) {
if (defaultColWidth === void 0) { defaultColWidth = 300; }
var contentWidth = 0;
for (var _i = 0, allColumns_1 = allColumns; _i < allColumns_1.length; _i++) {
var column = allColumns_1[_i];
contentWidth += (column.width || defaultColWidth);
}
return contentWidth;
} | [
"function",
"getContentWidth",
"(",
"allColumns",
",",
"defaultColWidth",
")",
"{",
"if",
"(",
"defaultColWidth",
"===",
"void",
"0",
")",
"{",
"defaultColWidth",
"=",
"300",
";",
"}",
"var",
"contentWidth",
"=",
"0",
";",
"for",
"(",
"var",
"_i",
"=",
"... | Gets the width of the columns | [
"Gets",
"the",
"width",
"of",
"the",
"columns"
] | d7df15a070282a169524dba51d9572008b74804c | https://github.com/swimlane/ngx-datatable/blob/d7df15a070282a169524dba51d9572008b74804c/release/utils/math.js#L152-L160 | train | Get content width of the table | [
30522,
3853,
2131,
8663,
6528,
2102,
9148,
11927,
2232,
1006,
2035,
25778,
2819,
3619,
1010,
12398,
25778,
9148,
11927,
2232,
1007,
1063,
2065,
1006,
12398,
25778,
9148,
11927,
2232,
1027,
1027,
1027,
11675,
1014,
1007,
1063,
12398,
25778,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/addons.js | addonsManager_getAddonChildElement | function addonsManager_getAddonChildElement(aSpec) {
var spec = aSpec || { };
var addon = spec.addon;
var attribute = spec.attribute;
var value = spec.value;
var type = spec.type;
if (!addon)
throw new Error(arguments.callee.name + ": Add-on not specified.");
// If no type has been set retrieve a general element which needs an
// attribute and value
if (!type) {
type = "element";
if (!attribute)
throw new Error(arguments.callee.name + ": DOM attribute not specified.");
if (!value)
throw new Error(arguments.callee.name + ": Value not specified.");
}
// For the details view the elements don't have anonymous nodes
if (this.selectedView.getNode().id == "detail-view") {
return this.getElement({
type: "detailView_" + type,
subtype: attribute,
value: value
});
} else {
return this.getElement({
type: "listView_" + type,
subtype: attribute,
value: value,
parent: addon
});
}
} | javascript | function addonsManager_getAddonChildElement(aSpec) {
var spec = aSpec || { };
var addon = spec.addon;
var attribute = spec.attribute;
var value = spec.value;
var type = spec.type;
if (!addon)
throw new Error(arguments.callee.name + ": Add-on not specified.");
// If no type has been set retrieve a general element which needs an
// attribute and value
if (!type) {
type = "element";
if (!attribute)
throw new Error(arguments.callee.name + ": DOM attribute not specified.");
if (!value)
throw new Error(arguments.callee.name + ": Value not specified.");
}
// For the details view the elements don't have anonymous nodes
if (this.selectedView.getNode().id == "detail-view") {
return this.getElement({
type: "detailView_" + type,
subtype: attribute,
value: value
});
} else {
return this.getElement({
type: "listView_" + type,
subtype: attribute,
value: value,
parent: addon
});
}
} | [
"function",
"addonsManager_getAddonChildElement",
"(",
"aSpec",
")",
"{",
"var",
"spec",
"=",
"aSpec",
"||",
"{",
"}",
";",
"var",
"addon",
"=",
"spec",
".",
"addon",
";",
"var",
"attribute",
"=",
"spec",
".",
"attribute",
";",
"var",
"value",
"=",
"spec... | Retrieve the given child element of the specified add-on
@param {object} aSpec
Information for getting the add-ons child node
Elements: addon - Add-on element
type - Type of the element
[optional - default: use attribute/value]
attribute - DOM attribute of the node
value - Value of the DOM attribute
@returns Element
@type {ElemBase} | [
"Retrieve",
"the",
"given",
"child",
"element",
"of",
"the",
"specified",
"add",
"-",
"on"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/addons.js#L532-L568 | train | Retrieve the child element of the specified add - on | [
30522,
3853,
5587,
5644,
24805,
4590,
1035,
2131,
4215,
5280,
19339,
12260,
3672,
1006,
2004,
5051,
2278,
1007,
1063,
13075,
28699,
1027,
2004,
5051,
2278,
1064,
1064,
30524,
2065,
1006,
999,
5587,
2239,
1007,
5466,
2047,
7561,
1006,
9918,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws-amplify/amplify-js | docs/amplify-theme/assets/js/scripts.js | function() {
this.scrollToCurrent();
window.addEventListener('hashchange', this.scrollToCurrent.bind(this));
document.body.addEventListener('click', this.delegateAnchors.bind(this));
} | javascript | function() {
this.scrollToCurrent();
window.addEventListener('hashchange', this.scrollToCurrent.bind(this));
document.body.addEventListener('click', this.delegateAnchors.bind(this));
} | [
"function",
"(",
")",
"{",
"this",
".",
"scrollToCurrent",
"(",
")",
";",
"window",
".",
"addEventListener",
"(",
"'hashchange'",
",",
"this",
".",
"scrollToCurrent",
".",
"bind",
"(",
"this",
")",
")",
";",
"document",
".",
"body",
".",
"addEventListener"... | Establish events, and fix initial scroll position if a hash is provided. | [
"Establish",
"events",
"and",
"fix",
"initial",
"scroll",
"position",
"if",
"a",
"hash",
"is",
"provided",
"."
] | db55ff3dff31c64a246180f39eb0a04a89fd16e1 | https://github.com/aws-amplify/amplify-js/blob/db55ff3dff31c64a246180f39eb0a04a89fd16e1/docs/amplify-theme/assets/js/scripts.js#L15-L19 | train | Add event listeners to the window and the document | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
17186,
3406,
10841,
14343,
3372,
1006,
1007,
1025,
3332,
1012,
5587,
18697,
3372,
9863,
24454,
1006,
1005,
23325,
22305,
2063,
1005,
1010,
2023,
1012,
17186,
3406,
10841,
14343,
3372,
1012,
14187,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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(oEvent){
var iCurrentX = oEvent.pageX;
var iDiff = this._bRTL ? (this._iStartDragX - iCurrentX) : (iCurrentX - this._iStartDragX);
setWidth(this, this._iStartWidth + iDiff);
} | javascript | function(oEvent){
var iCurrentX = oEvent.pageX;
var iDiff = this._bRTL ? (this._iStartDragX - iCurrentX) : (iCurrentX - this._iStartDragX);
setWidth(this, this._iStartWidth + iDiff);
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"iCurrentX",
"=",
"oEvent",
".",
"pageX",
";",
"var",
"iDiff",
"=",
"this",
".",
"_bRTL",
"?",
"(",
"this",
".",
"_iStartDragX",
"-",
"iCurrentX",
")",
":",
"(",
"iCurrentX",
"-",
"this",
".",
"_iStartDragX",... | Handles the MouseMove event during resizing @see sap.ui.ux3.ExactList.prototype.onmousedown | [
"Handles",
"the",
"MouseMove",
"event",
"during",
"resizing"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js#L1171-L1175 | train | Dragging is done by the mouse move event | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
24582,
29264,
2595,
1027,
1051,
18697,
3372,
1012,
3931,
2595,
1025,
13075,
8909,
13355,
1027,
2023,
1012,
1035,
7987,
19646,
1029,
1006,
2023,
1012,
1035,
21541,
8445,
7265,
2290,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(inst) {
var onChange = this._get(inst, "onChangeMonthYear");
if (onChange) {
onChange.apply((inst.input ? inst.input[0] : null),
[inst.selectedYear, inst.selectedMonth + 1, inst]);
}
} | javascript | function(inst) {
var onChange = this._get(inst, "onChangeMonthYear");
if (onChange) {
onChange.apply((inst.input ? inst.input[0] : null),
[inst.selectedYear, inst.selectedMonth + 1, inst]);
}
} | [
"function",
"(",
"inst",
")",
"{",
"var",
"onChange",
"=",
"this",
".",
"_get",
"(",
"inst",
",",
"\"onChangeMonthYear\"",
")",
";",
"if",
"(",
"onChange",
")",
"{",
"onChange",
".",
"apply",
"(",
"(",
"inst",
".",
"input",
"?",
"inst",
".",
"input",... | /* Notify change of month/year. | [
"/",
"*",
"Notify",
"change",
"of",
"month",
"/",
"year",
"."
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L9476-L9482 | train | Called when the month of the calendar is changed. | [
30522,
3853,
1006,
16021,
2102,
1007,
1063,
13075,
2006,
22305,
2063,
1027,
2023,
1012,
1035,
2131,
1006,
16021,
2102,
1010,
1000,
2006,
22305,
26941,
16921,
14644,
1000,
1007,
1025,
2065,
1006,
2006,
22305,
2063,
1007,
1063,
2006,
22305,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js | Event | function Event(oClass, name, info) {
this.name = name;
this.allowPreventDefault = info.allowPreventDefault || false;
this.deprecated = info.deprecated || false;
this.visibility = 'public';
this.allowPreventDefault = !!info.allowPreventDefault;
this.enableEventBubbling = !!info.enableEventBubbling;
this.appData = remainder(this, info);
this._oParent = oClass;
this._sUID = 'event:' + name;
this._iKind = Kind.EVENT;
var N = capitalize(name);
this._sMutator = 'attach' + N;
this._sDetachMutator = 'detach' + N;
this._sTrigger = 'fire' + N;
} | javascript | function Event(oClass, name, info) {
this.name = name;
this.allowPreventDefault = info.allowPreventDefault || false;
this.deprecated = info.deprecated || false;
this.visibility = 'public';
this.allowPreventDefault = !!info.allowPreventDefault;
this.enableEventBubbling = !!info.enableEventBubbling;
this.appData = remainder(this, info);
this._oParent = oClass;
this._sUID = 'event:' + name;
this._iKind = Kind.EVENT;
var N = capitalize(name);
this._sMutator = 'attach' + N;
this._sDetachMutator = 'detach' + N;
this._sTrigger = 'fire' + N;
} | [
"function",
"Event",
"(",
"oClass",
",",
"name",
",",
"info",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"allowPreventDefault",
"=",
"info",
".",
"allowPreventDefault",
"||",
"false",
";",
"this",
".",
"deprecated",
"=",
"info",
".",
... | ---- Event -----------------------------------------------------------------------------
Event info object
@private
@since 1.27.1 | [
"----",
"Event",
"-----------------------------------------------------------------------------",
"Event",
"info",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js#L752-L767 | train | Event constructor. | [
30522,
3853,
2724,
1006,
1051,
26266,
1010,
2171,
1010,
18558,
1007,
1063,
2023,
1012,
2171,
1027,
2171,
1025,
2023,
1012,
3499,
28139,
15338,
3207,
7011,
11314,
1027,
18558,
1012,
3499,
28139,
15338,
3207,
7011,
11314,
1064,
1064,
6270,
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... |
badges/shields | services/pypi/pypi-helpers.js | parseDjangoVersionString | function parseDjangoVersionString(str) {
if (typeof str !== 'string') {
return false
}
const x = str.split('.')
const maj = parseInt(x[0]) || 0
const min = parseInt(x[1]) || 0
return {
major: maj,
minor: min,
}
} | javascript | function parseDjangoVersionString(str) {
if (typeof str !== 'string') {
return false
}
const x = str.split('.')
const maj = parseInt(x[0]) || 0
const min = parseInt(x[1]) || 0
return {
major: maj,
minor: min,
}
} | [
"function",
"parseDjangoVersionString",
"(",
"str",
")",
"{",
"if",
"(",
"typeof",
"str",
"!==",
"'string'",
")",
"{",
"return",
"false",
"}",
"const",
"x",
"=",
"str",
".",
"split",
"(",
"'.'",
")",
"const",
"maj",
"=",
"parseInt",
"(",
"x",
"[",
"0... | /*
Django versions will be specified in the form major.minor
trying to sort with `semver.compare` will throw e.g:
TypeError: Invalid Version: 1.11
because no patch release is specified, so we will define
our own functions to parse and sort django versions | [
"/",
"*",
"Django",
"versions",
"will",
"be",
"specified",
"in",
"the",
"form",
"major",
".",
"minor",
"trying",
"to",
"sort",
"with",
"semver",
".",
"compare",
"will",
"throw",
"e",
".",
"g",
":",
"TypeError",
":",
"Invalid",
"Version",
":",
"1",
".",... | 283601423f3d1a19aae83bf62032d40683948636 | https://github.com/badges/shields/blob/283601423f3d1a19aae83bf62032d40683948636/services/pypi/pypi-helpers.js#L11-L22 | train | Parse a django version string | [
30522,
3853,
11968,
6924,
8405,
3995,
27774,
3367,
4892,
1006,
2358,
2099,
1007,
1063,
2065,
1006,
2828,
11253,
2358,
2099,
999,
1027,
1027,
1005,
5164,
1005,
1007,
1063,
2709,
6270,
1065,
9530,
3367,
1060,
1027,
2358,
2099,
1012,
3975,
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... |
NetEase/pomelo | lib/components/remote.js | function(app) {
var paths = [];
var role;
// master server should not come here
if(app.isFrontend()) {
role = 'frontend';
} else {
role = 'backend';
}
var sysPath = pathUtil.getSysRemotePath(role), serverType = app.getServerType();
if(fs.existsSync(sysPath)) {
paths.push(pathUtil.remotePathRecord('sys', serverType, sysPath));
}
var userPath = pathUtil.getUserRemotePath(app.getBase(), serverType);
if(fs.existsSync(userPath)) {
paths.push(pathUtil.remotePathRecord('user', serverType, userPath));
}
return paths;
} | javascript | function(app) {
var paths = [];
var role;
// master server should not come here
if(app.isFrontend()) {
role = 'frontend';
} else {
role = 'backend';
}
var sysPath = pathUtil.getSysRemotePath(role), serverType = app.getServerType();
if(fs.existsSync(sysPath)) {
paths.push(pathUtil.remotePathRecord('sys', serverType, sysPath));
}
var userPath = pathUtil.getUserRemotePath(app.getBase(), serverType);
if(fs.existsSync(userPath)) {
paths.push(pathUtil.remotePathRecord('user', serverType, userPath));
}
return paths;
} | [
"function",
"(",
"app",
")",
"{",
"var",
"paths",
"=",
"[",
"]",
";",
"var",
"role",
";",
"// master server should not come here",
"if",
"(",
"app",
".",
"isFrontend",
"(",
")",
")",
"{",
"role",
"=",
"'frontend'",
";",
"}",
"else",
"{",
"role",
"=",
... | Get remote paths from application
@param {Object} app current application context
@return {Array} paths | [
"Get",
"remote",
"paths",
"from",
"application"
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/components/remote.js#L77-L98 | train | Get remote paths for a given app | [
30522,
3853,
1006,
10439,
1007,
1063,
13075,
10425,
1027,
1031,
1033,
1025,
13075,
2535,
1025,
1013,
1013,
3040,
8241,
2323,
2025,
2272,
2182,
2065,
1006,
10439,
1012,
2003,
12792,
10497,
1006,
1007,
1007,
1063,
2535,
1027,
1005,
2392,
1049... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
wix/Detox | detox/local-cli/utils/collectExtraArgs.js | collectExtraArgs | function collectExtraArgs(argv) {
const parsed = parseArgv(argv, {
configuration: {
'boolean-negation': false,
'camel-case-expansion': false,
'dot-notation': false,
'parse-numbers': false,
'duplicate-arguments-array': false
}
});
const passthrough = _.chain(parsed)
.omitBy((_value, key) => blacklistedArgs.has(key))
.entries()
.map(([key, value]) => {
return value === true ? `--${key}` : `--${key} ${value}`;
})
.concat(parsed['_'])
.value();
return passthrough;
} | javascript | function collectExtraArgs(argv) {
const parsed = parseArgv(argv, {
configuration: {
'boolean-negation': false,
'camel-case-expansion': false,
'dot-notation': false,
'parse-numbers': false,
'duplicate-arguments-array': false
}
});
const passthrough = _.chain(parsed)
.omitBy((_value, key) => blacklistedArgs.has(key))
.entries()
.map(([key, value]) => {
return value === true ? `--${key}` : `--${key} ${value}`;
})
.concat(parsed['_'])
.value();
return passthrough;
} | [
"function",
"collectExtraArgs",
"(",
"argv",
")",
"{",
"const",
"parsed",
"=",
"parseArgv",
"(",
"argv",
",",
"{",
"configuration",
":",
"{",
"'boolean-negation'",
":",
"false",
",",
"'camel-case-expansion'",
":",
"false",
",",
"'dot-notation'",
":",
"false",
... | *
@param {Object} argv
@returns {string[]} | [
"*"
] | 0ed5e8c7ba279a3a409130b4d4bad3f9a9c2f1f9 | https://github.com/wix/Detox/blob/0ed5e8c7ba279a3a409130b4d4bad3f9a9c2f1f9/detox/local-cli/utils/collectExtraArgs.js#L30-L51 | train | Collect extra arguments from the command line. | [
30522,
3853,
8145,
10288,
6494,
2906,
5620,
1006,
12098,
2290,
2615,
1007,
1063,
9530,
3367,
11968,
6924,
1027,
11968,
17310,
10623,
2615,
1006,
12098,
2290,
2615,
1010,
1063,
9563,
1024,
1063,
1005,
22017,
20898,
1011,
11265,
12540,
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... |
eslint/eslint | lib/rules/comma-dangle.js | forceTrailingComma | function forceTrailingComma(node) {
const lastItem = getLastItem(node);
if (!lastItem || (node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier")) {
return;
}
if (!isTrailingCommaAllowed(lastItem)) {
forbidTrailingComma(node);
return;
}
const trailingToken = getTrailingToken(node, lastItem);
if (trailingToken.value !== ",") {
context.report({
node: lastItem,
loc: trailingToken.loc.end,
messageId: "missing",
fix(fixer) {
return fixer.insertTextAfter(trailingToken, ",");
}
});
}
} | javascript | function forceTrailingComma(node) {
const lastItem = getLastItem(node);
if (!lastItem || (node.type === "ImportDeclaration" && lastItem.type !== "ImportSpecifier")) {
return;
}
if (!isTrailingCommaAllowed(lastItem)) {
forbidTrailingComma(node);
return;
}
const trailingToken = getTrailingToken(node, lastItem);
if (trailingToken.value !== ",") {
context.report({
node: lastItem,
loc: trailingToken.loc.end,
messageId: "missing",
fix(fixer) {
return fixer.insertTextAfter(trailingToken, ",");
}
});
}
} | [
"function",
"forceTrailingComma",
"(",
"node",
")",
"{",
"const",
"lastItem",
"=",
"getLastItem",
"(",
"node",
")",
";",
"if",
"(",
"!",
"lastItem",
"||",
"(",
"node",
".",
"type",
"===",
"\"ImportDeclaration\"",
"&&",
"lastItem",
".",
"type",
"!==",
"\"Im... | Reports the last element of a given node if it does not have a trailing
comma.
If a given node is `ArrayPattern` which has `RestElement`, the trailing
comma is disallowed, so report if it exists.
@param {ASTNode} node - A node to check. Its type is one of
ObjectExpression, ObjectPattern, ArrayExpression, ArrayPattern,
ImportDeclaration, and ExportNamedDeclaration.
@returns {void} | [
"Reports",
"the",
"last",
"element",
"of",
"a",
"given",
"node",
"if",
"it",
"does",
"not",
"have",
"a",
"trailing",
"comma",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/comma-dangle.js#L260-L283 | train | Force trailing comma if not allowed | [
30522,
3853,
2486,
6494,
16281,
9006,
2863,
1006,
13045,
1007,
1063,
9530,
30524,
20464,
25879,
3258,
1000,
1004,
1004,
2197,
4221,
2213,
1012,
2828,
999,
1027,
1027,
1000,
17589,
5051,
6895,
8873,
2121,
1000,
1007,
1007,
1063,
2709,
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... |
dcloudio/mui | js/mui.jsonp.js | function(url) {
url = url || location.search;
var splitIndex = url.indexOf('?');
var queryString = url.substr(splitIndex + 1);
var paramArray = queryString.split('&');
var result = {};
for (var i in paramArray) {
var params = paramArray[i].split('=');
result[params[0]] = params[1];
}
return result;
} | javascript | function(url) {
url = url || location.search;
var splitIndex = url.indexOf('?');
var queryString = url.substr(splitIndex + 1);
var paramArray = queryString.split('&');
var result = {};
for (var i in paramArray) {
var params = paramArray[i].split('=');
result[params[0]] = params[1];
}
return result;
} | [
"function",
"(",
"url",
")",
"{",
"url",
"=",
"url",
"||",
"location",
".",
"search",
";",
"var",
"splitIndex",
"=",
"url",
".",
"indexOf",
"(",
"'?'",
")",
";",
"var",
"queryString",
"=",
"url",
".",
"substr",
"(",
"splitIndex",
"+",
"1",
")",
";"... | 获取 QueryString | [
"获取",
"QueryString"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/js/mui.jsonp.js#L44-L55 | train | Get the query parameters from the URL | [
30522,
3853,
1006,
24471,
2140,
1007,
1063,
24471,
2140,
1027,
24471,
2140,
1064,
1064,
3295,
1012,
3945,
1025,
13075,
3975,
22254,
10288,
1027,
24471,
2140,
1012,
5950,
11253,
1006,
1005,
1029,
1005,
1007,
1025,
13075,
23032,
3367,
4892,
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... | |
NetEase/pomelo | lib/server/server.js | function(cron, crons, server) {
if(!containCron(cron.id, crons)) {
server.crons.push(cron);
} else {
logger.warn('cron is duplicated: %j', cron);
}
} | javascript | function(cron, crons, server) {
if(!containCron(cron.id, crons)) {
server.crons.push(cron);
} else {
logger.warn('cron is duplicated: %j', cron);
}
} | [
"function",
"(",
"cron",
",",
"crons",
",",
"server",
")",
"{",
"if",
"(",
"!",
"containCron",
"(",
"cron",
".",
"id",
",",
"crons",
")",
")",
"{",
"server",
".",
"crons",
".",
"push",
"(",
"cron",
")",
";",
"}",
"else",
"{",
"logger",
".",
"wa... | If cron is not in crons then put it in the array. | [
"If",
"cron",
"is",
"not",
"in",
"crons",
"then",
"put",
"it",
"in",
"the",
"array",
"."
] | defcf019631ed399cc4dad932d3b028a04a039a4 | https://github.com/NetEase/pomelo/blob/defcf019631ed399cc4dad932d3b028a04a039a4/lib/server/server.js#L434-L440 | train | Add a cron to the server | [
30522,
3853,
1006,
13675,
2239,
1010,
13675,
5644,
1010,
8241,
1007,
1063,
2065,
1006,
999,
5383,
26775,
2239,
1006,
13675,
2239,
1012,
8909,
1010,
13675,
5644,
1007,
1007,
1063,
8241,
1012,
13675,
5644,
1012,
5245,
1006,
13675,
2239,
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... | |
catapult-project/catapult | common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js | function() {
if ( list ) {
var length = list.length;
add( arguments );
// Do we need to add the callbacks to the
// current firing batch?
if ( firing ) {
firingLength = list.length;
// With memory, if we're not firing then
// we should call right away, unless previous
// firing was halted (stopOnFalse)
} else if ( memory && memory !== true ) {
firingStart = length;
fire( memory[ 0 ], memory[ 1 ] );
}
}
return this;
} | javascript | function() {
if ( list ) {
var length = list.length;
add( arguments );
// Do we need to add the callbacks to the
// current firing batch?
if ( firing ) {
firingLength = list.length;
// With memory, if we're not firing then
// we should call right away, unless previous
// firing was halted (stopOnFalse)
} else if ( memory && memory !== true ) {
firingStart = length;
fire( memory[ 0 ], memory[ 1 ] );
}
}
return this;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"list",
")",
"{",
"var",
"length",
"=",
"list",
".",
"length",
";",
"add",
"(",
"arguments",
")",
";",
"// Do we need to add the callbacks to the",
"// current firing batch?",
"if",
"(",
"firing",
")",
"{",
"firingLength",... | Add a callback or a collection of callbacks to the list | [
"Add",
"a",
"callback",
"or",
"a",
"collection",
"of",
"callbacks",
"to",
"the",
"list"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rjsmin/bench/jquery-1.7.1.js#L1068-L1085 | train | This function is called by the constructor when the constructor is called. | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
2862,
1007,
1063,
13075,
3091,
1027,
2862,
1012,
3091,
1025,
5587,
1006,
9918,
1007,
1025,
1013,
1013,
2079,
2057,
2342,
2000,
5587,
1996,
2655,
12221,
2000,
1996,
1013,
1013,
2783,
7493,
14108,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | function ( e ){
if ( scope_Target.hasAttribute('disabled') ) {
return false;
}
// Stop if an active 'tap' transition is taking place.
if ( hasClass(scope_Target, options.cssClasses.tap) ) {
return false;
}
e = fixEvent(e, data.pageOffset);
// Handle reject of multitouch
if ( !e ) {
return false;
}
// Ignore right or middle clicks on start #454
if ( events === actions.start && e.buttons !== undefined && e.buttons > 1 ) {
return false;
}
// Ignore right or middle clicks on start #454
if ( data.hover && e.buttons ) {
return false;
}
e.calcPoint = e.points[ options.ort ];
// Call the event handler with the event [ and additional data ].
callback ( e, data );
} | javascript | function ( e ){
if ( scope_Target.hasAttribute('disabled') ) {
return false;
}
// Stop if an active 'tap' transition is taking place.
if ( hasClass(scope_Target, options.cssClasses.tap) ) {
return false;
}
e = fixEvent(e, data.pageOffset);
// Handle reject of multitouch
if ( !e ) {
return false;
}
// Ignore right or middle clicks on start #454
if ( events === actions.start && e.buttons !== undefined && e.buttons > 1 ) {
return false;
}
// Ignore right or middle clicks on start #454
if ( data.hover && e.buttons ) {
return false;
}
e.calcPoint = e.points[ options.ort ];
// Call the event handler with the event [ and additional data ].
callback ( e, data );
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"scope_Target",
".",
"hasAttribute",
"(",
"'disabled'",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Stop if an active 'tap' transition is taking place.",
"if",
"(",
"hasClass",
"(",
"scope_Target",
",",
"options",
"... | This function can be used to 'filter' events to the slider. element is a node, not a nodeList | [
"This",
"function",
"can",
"be",
"used",
"to",
"filter",
"events",
"to",
"the",
"slider",
".",
"element",
"is",
"a",
"node",
"not",
"a",
"nodeList"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1263-L1295 | train | Handle the event | [
30522,
3853,
1006,
1041,
1007,
1063,
2065,
1006,
9531,
1035,
4539,
1012,
2038,
19321,
3089,
8569,
2618,
1006,
1005,
9776,
1005,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
1013,
1013,
2644,
2065,
2019,
3161,
1005,
11112,
1005,
6653,
2003,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js | function (method, handler) {
if (!method || !handler) {
return;
}
if (!this.handlers[method]) {
//initialize array
this.handlers[method] = [];
}
// add handler to the stack
this.handlers[method].push(handler);
} | javascript | function (method, handler) {
if (!method || !handler) {
return;
}
if (!this.handlers[method]) {
//initialize array
this.handlers[method] = [];
}
// add handler to the stack
this.handlers[method].push(handler);
} | [
"function",
"(",
"method",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"method",
"||",
"!",
"handler",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"this",
".",
"handlers",
"[",
"method",
"]",
")",
"{",
"//initialize array",
"this",
".",
"handlers",
... | Subscribe handlers to specific messages.
@param {string} method Message type.
@param {function} handler.
TODO: add handler name or any identification mechanism to then implement 'off'? | [
"Subscribe",
"handlers",
"to",
"specific",
"messages",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L113-L123 | train | add handler to the stack | [
30522,
3853,
1006,
4118,
1010,
28213,
1007,
1063,
2065,
1006,
999,
4118,
1064,
1064,
999,
28213,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
999,
2023,
1012,
28213,
2015,
1031,
4118,
1033,
1007,
1063,
1013,
1013,
3988,
4697,
9140,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/extensions/table/tableDataHandler.js | stuffCellsIntoIncompleteRow | function stuffCellsIntoIncompleteRow(tableData, limitIndex) {
tableData.forEach((rowData, rowIndex) => {
const startIndex = rowData.length;
if (startIndex) {
const [{nodeName}] = rowData;
util.range(startIndex, limitIndex).forEach(colIndex => {
rowData.push(createBasicCell(rowIndex, colIndex, nodeName));
});
}
});
} | javascript | function stuffCellsIntoIncompleteRow(tableData, limitIndex) {
tableData.forEach((rowData, rowIndex) => {
const startIndex = rowData.length;
if (startIndex) {
const [{nodeName}] = rowData;
util.range(startIndex, limitIndex).forEach(colIndex => {
rowData.push(createBasicCell(rowIndex, colIndex, nodeName));
});
}
});
} | [
"function",
"stuffCellsIntoIncompleteRow",
"(",
"tableData",
",",
"limitIndex",
")",
"{",
"tableData",
".",
"forEach",
"(",
"(",
"rowData",
",",
"rowIndex",
")",
"=>",
"{",
"const",
"startIndex",
"=",
"rowData",
".",
"length",
";",
"if",
"(",
"startIndex",
"... | Stuff cells into incomplete row.
@param {Array.<Array.<object>>} tableData - table data
@param {number} limitIndex - limit index
@ignore | [
"Stuff",
"cells",
"into",
"incomplete",
"row",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/tableDataHandler.js#L336-L347 | train | stuff cells into incomplete row | [
30522,
3853,
4933,
29109,
4877,
18447,
28765,
9006,
10814,
3334,
5004,
1006,
2795,
2850,
2696,
1010,
5787,
22254,
10288,
1007,
1063,
2795,
2850,
2696,
1012,
18921,
6776,
1006,
1006,
5216,
2850,
2696,
1010,
5216,
22254,
10288,
1007,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/util/util.js | function() {
var stickyProp;
var testEl = angular.element('<div>');
$document[0].body.appendChild(testEl[0]);
var stickyProps = ['sticky', '-webkit-sticky'];
for (var i = 0; i < stickyProps.length; ++i) {
testEl.css({
position: stickyProps[i],
top: 0,
'z-index': 2
});
if (testEl.css('position') == stickyProps[i]) {
stickyProp = stickyProps[i];
break;
}
}
testEl.remove();
return stickyProp;
} | javascript | function() {
var stickyProp;
var testEl = angular.element('<div>');
$document[0].body.appendChild(testEl[0]);
var stickyProps = ['sticky', '-webkit-sticky'];
for (var i = 0; i < stickyProps.length; ++i) {
testEl.css({
position: stickyProps[i],
top: 0,
'z-index': 2
});
if (testEl.css('position') == stickyProps[i]) {
stickyProp = stickyProps[i];
break;
}
}
testEl.remove();
return stickyProp;
} | [
"function",
"(",
")",
"{",
"var",
"stickyProp",
";",
"var",
"testEl",
"=",
"angular",
".",
"element",
"(",
"'<div>'",
")",
";",
"$document",
"[",
"0",
"]",
".",
"body",
".",
"appendChild",
"(",
"testEl",
"[",
"0",
"]",
")",
";",
"var",
"stickyProps",... | Checks if the current browser is natively supporting the `sticky` position.
@returns {string} supported sticky property name | [
"Checks",
"if",
"the",
"current",
"browser",
"is",
"natively",
"supporting",
"the",
"sticky",
"position",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L757-L779 | train | Get sticky property | [
30522,
3853,
1006,
1007,
1063,
13075,
15875,
21572,
2361,
1025,
13075,
3231,
2884,
1027,
16108,
1012,
5783,
1006,
1005,
1026,
4487,
2615,
1028,
1005,
1007,
1025,
1002,
6254,
1031,
1014,
1033,
1012,
2303,
1012,
10439,
10497,
19339,
1006,
323... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/_AnnotationHelperExpression.js | function (oInterface, oPathValue) {
var bExpression = oPathValue.asExpression,
aParts = [],
oResult,
aResults = [];
// needed so that we can safely call the forEach
Basics.expectType(oPathValue, "array");
oPathValue.value.forEach(function (oUnused, i) {
// an embedded concat must use expression binding
oResult = Expression.parameter(oInterface, oPathValue, i);
// if any parameter is type expression, the concat must become expression, too
bExpression = bExpression || oResult.result === "expression";
aResults.push(oResult);
});
// convert the results to strings after we know whether the result is expression
aResults.forEach(function (oResult) {
if (bExpression) {
// the expression might have a lower operator precedence than '+'
Expression.wrapExpression(oResult);
}
if (oResult.type !== 'edm:Null') {
// ignore null (otherwise the string 'null' would appear in expressions)
aParts.push(Basics.resultToString(oResult, bExpression, oPathValue.withType));
}
});
oResult = bExpression
? {result : "expression", value : aParts.join("+")}
: {result : "composite", value : aParts.join("")};
oResult.type = "Edm.String";
return oResult;
} | javascript | function (oInterface, oPathValue) {
var bExpression = oPathValue.asExpression,
aParts = [],
oResult,
aResults = [];
// needed so that we can safely call the forEach
Basics.expectType(oPathValue, "array");
oPathValue.value.forEach(function (oUnused, i) {
// an embedded concat must use expression binding
oResult = Expression.parameter(oInterface, oPathValue, i);
// if any parameter is type expression, the concat must become expression, too
bExpression = bExpression || oResult.result === "expression";
aResults.push(oResult);
});
// convert the results to strings after we know whether the result is expression
aResults.forEach(function (oResult) {
if (bExpression) {
// the expression might have a lower operator precedence than '+'
Expression.wrapExpression(oResult);
}
if (oResult.type !== 'edm:Null') {
// ignore null (otherwise the string 'null' would appear in expressions)
aParts.push(Basics.resultToString(oResult, bExpression, oPathValue.withType));
}
});
oResult = bExpression
? {result : "expression", value : aParts.join("+")}
: {result : "composite", value : aParts.join("")};
oResult.type = "Edm.String";
return oResult;
} | [
"function",
"(",
"oInterface",
",",
"oPathValue",
")",
"{",
"var",
"bExpression",
"=",
"oPathValue",
".",
"asExpression",
",",
"aParts",
"=",
"[",
"]",
",",
"oResult",
",",
"aResults",
"=",
"[",
"]",
";",
"// needed so that we can safely call the forEach",
"Basi... | Handling of "14.5.3.1.1 Function odata.concat".
@param {sap.ui.core.util.XMLPreprocessor.IContext|sap.ui.model.Context} oInterface
the callback interface related to the current formatter call
@param {object} oPathValue
path and value information pointing to the parameters array (see Expression object)
@returns {object}
the result object | [
"Handling",
"of",
"14",
".",
"5",
".",
"3",
".",
"1",
".",
"1",
"Function",
"odata",
".",
"concat",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperExpression.js#L190-L221 | train | Converts an array of parameters to strings | [
30522,
3853,
1006,
1051,
18447,
2121,
12172,
1010,
6728,
8988,
10175,
5657,
1007,
1063,
13075,
2022,
2595,
20110,
3258,
1027,
6728,
8988,
10175,
5657,
1012,
2004,
10288,
20110,
3258,
1010,
4237,
2015,
1027,
1031,
1033,
1010,
10848,
23722,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.