repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GeekyAnts/vue-native-core | packages/vue-server-renderer/build.js | createRenderer$1 | function createRenderer$1 (ref) {
if ( ref === void 0 ) ref = {};
var modules = ref.modules; if ( modules === void 0 ) modules = [];
var directives = ref.directives; if ( directives === void 0 ) directives = {};
var isUnaryTag = ref.isUnaryTag; if ( isUnaryTag === void 0 ) isUnaryTag = (function () { return false; });
var template = ref.template;
var inject = ref.inject;
var cache = ref.cache;
var shouldPreload = ref.shouldPreload;
var clientManifest = ref.clientManifest;
var render = createRenderFunction(modules, directives, isUnaryTag, cache);
var templateRenderer = new TemplateRenderer({
template: template,
inject: inject,
shouldPreload: shouldPreload,
clientManifest: clientManifest
});
return {
renderToString: function renderToString (
component,
context,
done
) {
if (typeof context === 'function') {
done = context;
context = {};
}
if (context) {
templateRenderer.bindRenderFns(context);
}
var result = '';
var write = createWriteFunction(function (text) {
result += text;
return false
}, done);
try {
render(component, write, context, function () {
if (template) {
result = templateRenderer.renderSync(result, context);
}
done(null, result);
});
} catch (e) {
done(e);
}
},
renderToStream: function renderToStream (
component,
context
) {
if (context) {
templateRenderer.bindRenderFns(context);
}
var renderStream = new RenderStream(function (write, done) {
render(component, write, context, done);
});
if (!template) {
return renderStream
} else {
var templateStream = templateRenderer.createStream(context);
renderStream.on('error', function (err) {
templateStream.emit('error', err);
});
renderStream.pipe(templateStream);
return templateStream
}
}
}
} | javascript | function createRenderer$1 (ref) {
if ( ref === void 0 ) ref = {};
var modules = ref.modules; if ( modules === void 0 ) modules = [];
var directives = ref.directives; if ( directives === void 0 ) directives = {};
var isUnaryTag = ref.isUnaryTag; if ( isUnaryTag === void 0 ) isUnaryTag = (function () { return false; });
var template = ref.template;
var inject = ref.inject;
var cache = ref.cache;
var shouldPreload = ref.shouldPreload;
var clientManifest = ref.clientManifest;
var render = createRenderFunction(modules, directives, isUnaryTag, cache);
var templateRenderer = new TemplateRenderer({
template: template,
inject: inject,
shouldPreload: shouldPreload,
clientManifest: clientManifest
});
return {
renderToString: function renderToString (
component,
context,
done
) {
if (typeof context === 'function') {
done = context;
context = {};
}
if (context) {
templateRenderer.bindRenderFns(context);
}
var result = '';
var write = createWriteFunction(function (text) {
result += text;
return false
}, done);
try {
render(component, write, context, function () {
if (template) {
result = templateRenderer.renderSync(result, context);
}
done(null, result);
});
} catch (e) {
done(e);
}
},
renderToStream: function renderToStream (
component,
context
) {
if (context) {
templateRenderer.bindRenderFns(context);
}
var renderStream = new RenderStream(function (write, done) {
render(component, write, context, done);
});
if (!template) {
return renderStream
} else {
var templateStream = templateRenderer.createStream(context);
renderStream.on('error', function (err) {
templateStream.emit('error', err);
});
renderStream.pipe(templateStream);
return templateStream
}
}
}
} | [
"function",
"createRenderer$1",
"(",
"ref",
")",
"{",
"if",
"(",
"ref",
"===",
"void",
"0",
")",
"ref",
"=",
"{",
"}",
";",
"var",
"modules",
"=",
"ref",
".",
"modules",
";",
"if",
"(",
"modules",
"===",
"void",
"0",
")",
"modules",
"=",
"[",
"]"... | /* | [
"/",
"*"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/vue-server-renderer/build.js#L5542-L5613 | train | Creates a renderer function for a component. | [
30522,
3853,
3443,
7389,
4063,
2121,
1002,
1015,
1006,
25416,
1007,
1063,
2065,
1006,
25416,
1027,
1027,
1027,
11675,
1014,
1007,
25416,
1027,
1063,
1065,
1025,
13075,
14184,
1027,
25416,
1012,
14184,
1025,
2065,
1006,
14184,
1027,
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... |
facebook/watchman | node/bser/index.js | dumpToBuffer | function dumpToBuffer(val) {
var buf = new Accumulator();
// Build out the header
buf.writeByte(0);
buf.writeByte(1);
// Reserve room for an int32 to hold our PDU length
buf.writeByte(BSER_INT32);
buf.writeInt(0, 4); // We'll come back and fill this in at the end
dump_any(buf, val);
// Compute PDU length
var off = buf.writeOffset;
var len = off - 7 /* the header length */;
buf.writeOffset = 3; // The length value to fill in
buf.writeInt(len, 4); // write the length in the space we reserved
buf.writeOffset = off;
return buf.buf.slice(0, off);
} | javascript | function dumpToBuffer(val) {
var buf = new Accumulator();
// Build out the header
buf.writeByte(0);
buf.writeByte(1);
// Reserve room for an int32 to hold our PDU length
buf.writeByte(BSER_INT32);
buf.writeInt(0, 4); // We'll come back and fill this in at the end
dump_any(buf, val);
// Compute PDU length
var off = buf.writeOffset;
var len = off - 7 /* the header length */;
buf.writeOffset = 3; // The length value to fill in
buf.writeInt(len, 4); // write the length in the space we reserved
buf.writeOffset = off;
return buf.buf.slice(0, off);
} | [
"function",
"dumpToBuffer",
"(",
"val",
")",
"{",
"var",
"buf",
"=",
"new",
"Accumulator",
"(",
")",
";",
"// Build out the header",
"buf",
".",
"writeByte",
"(",
"0",
")",
";",
"buf",
".",
"writeByte",
"(",
"1",
")",
";",
"// Reserve room for an int32 to ho... | BSER encode value and return a buffer of the contents | [
"BSER",
"encode",
"value",
"and",
"return",
"a",
"buffer",
"of",
"the",
"contents"
] | 8d576a2d3e1191c977f03f584993da63a3b8e5ec | https://github.com/facebook/watchman/blob/8d576a2d3e1191c977f03f584993da63a3b8e5ec/node/bser/index.js#L566-L585 | train | Dump the given value into a buffer. | [
30522,
3853,
15653,
3406,
8569,
12494,
1006,
11748,
1007,
1063,
13075,
20934,
2546,
1027,
2047,
16222,
2819,
20350,
1006,
1007,
1025,
1013,
1013,
3857,
2041,
1996,
20346,
20934,
2546,
1012,
4339,
3762,
2618,
1006,
1014,
1007,
1025,
20934,
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/extensibility/Package.js | formatError | function formatError(error) {
function localize(key) {
if (Strings[key]) {
return Strings[key];
}
console.log("Unknown installation error", key);
return Strings.UNKNOWN_ERROR;
}
if (Array.isArray(error)) {
error[0] = localize(error[0]);
return StringUtils.format.apply(window, error);
} else {
return localize(error);
}
} | javascript | function formatError(error) {
function localize(key) {
if (Strings[key]) {
return Strings[key];
}
console.log("Unknown installation error", key);
return Strings.UNKNOWN_ERROR;
}
if (Array.isArray(error)) {
error[0] = localize(error[0]);
return StringUtils.format.apply(window, error);
} else {
return localize(error);
}
} | [
"function",
"formatError",
"(",
"error",
")",
"{",
"function",
"localize",
"(",
"key",
")",
"{",
"if",
"(",
"Strings",
"[",
"key",
"]",
")",
"{",
"return",
"Strings",
"[",
"key",
"]",
";",
"}",
"console",
".",
"log",
"(",
"\"Unknown installation error\""... | Converts an error object as returned by install(), installFromPath() or
installFromURL() into a flattened, localized string.
@param {string|Array.<string>} error
@return {string} | [
"Converts",
"an",
"error",
"object",
"as",
"returned",
"by",
"install",
"()",
"installFromPath",
"()",
"or",
"installFromURL",
"()",
"into",
"a",
"flattened",
"localized",
"string",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/Package.js#L414-L429 | train | format error | [
30522,
3853,
4289,
2121,
29165,
1006,
7561,
1007,
1063,
3853,
2334,
4697,
1006,
3145,
1007,
1063,
2065,
1006,
7817,
1031,
3145,
1033,
1007,
1063,
2709,
7817,
1031,
3145,
1033,
1025,
1065,
10122,
1012,
8833,
1006,
1000,
4242,
8272,
7561,
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... |
nodejs/node-gyp | lib/configure.js | run | function run(exec, args, shell, callback) {
var env = extend({}, this.env)
env.TERM = 'dumb'
const opts = { env: env, shell: shell }
this.log.silly('execFile: exec = %j', exec)
this.log.silly('execFile: args = %j', args)
this.log.silly('execFile: opts = %j', opts)
try {
this.execFile(exec, args, opts, execFileCallback.bind(this))
} catch (err) {
this.log.silly('execFile: threw:\n%s', err.stack)
return callback(err)
}
function execFileCallback(err, stdout, stderr) {
this.log.silly('execFile result: err = %j', err && err.stack || err)
this.log.silly('execFile result: stdout = %j', stdout)
this.log.silly('execFile result: stderr = %j', stderr)
if (err) {
return callback(err)
}
const execPath = stdout.trim()
callback(null, execPath)
}
} | javascript | function run(exec, args, shell, callback) {
var env = extend({}, this.env)
env.TERM = 'dumb'
const opts = { env: env, shell: shell }
this.log.silly('execFile: exec = %j', exec)
this.log.silly('execFile: args = %j', args)
this.log.silly('execFile: opts = %j', opts)
try {
this.execFile(exec, args, opts, execFileCallback.bind(this))
} catch (err) {
this.log.silly('execFile: threw:\n%s', err.stack)
return callback(err)
}
function execFileCallback(err, stdout, stderr) {
this.log.silly('execFile result: err = %j', err && err.stack || err)
this.log.silly('execFile result: stdout = %j', stdout)
this.log.silly('execFile result: stderr = %j', stderr)
if (err) {
return callback(err)
}
const execPath = stdout.trim()
callback(null, execPath)
}
} | [
"function",
"run",
"(",
"exec",
",",
"args",
",",
"shell",
",",
"callback",
")",
"{",
"var",
"env",
"=",
"extend",
"(",
"{",
"}",
",",
"this",
".",
"env",
")",
"env",
".",
"TERM",
"=",
"'dumb'",
"const",
"opts",
"=",
"{",
"env",
":",
"env",
","... | Run an executable or shell command, trimming the output. | [
"Run",
"an",
"executable",
"or",
"shell",
"command",
"trimming",
"the",
"output",
"."
] | 721eb691cf15556cc2700eda0558d5bad5f84232 | https://github.com/nodejs/node-gyp/blob/721eb691cf15556cc2700eda0558d5bad5f84232/lib/configure.js#L581-L606 | train | Runs a command in the specified shell. | [
30522,
3853,
2448,
1006,
4654,
8586,
1010,
12098,
5620,
1010,
5806,
1010,
2655,
5963,
1007,
1063,
13075,
4372,
2615,
1027,
7949,
1006,
1063,
1065,
1010,
2023,
1012,
4372,
2615,
1007,
4372,
2615,
1012,
2744,
1027,
1005,
12873,
1005,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
markdown-it/markdown-it | lib/parser_inline.js | ParserInline | function ParserInline() {
var i;
/**
* ParserInline#ruler -> Ruler
*
* [[Ruler]] instance. Keep configuration of inline rules.
**/
this.ruler = new Ruler();
for (i = 0; i < _rules.length; i++) {
this.ruler.push(_rules[i][0], _rules[i][1]);
}
/**
* ParserInline#ruler2 -> Ruler
*
* [[Ruler]] instance. Second ruler used for post-processing
* (e.g. in emphasis-like rules).
**/
this.ruler2 = new Ruler();
for (i = 0; i < _rules2.length; i++) {
this.ruler2.push(_rules2[i][0], _rules2[i][1]);
}
} | javascript | function ParserInline() {
var i;
/**
* ParserInline#ruler -> Ruler
*
* [[Ruler]] instance. Keep configuration of inline rules.
**/
this.ruler = new Ruler();
for (i = 0; i < _rules.length; i++) {
this.ruler.push(_rules[i][0], _rules[i][1]);
}
/**
* ParserInline#ruler2 -> Ruler
*
* [[Ruler]] instance. Second ruler used for post-processing
* (e.g. in emphasis-like rules).
**/
this.ruler2 = new Ruler();
for (i = 0; i < _rules2.length; i++) {
this.ruler2.push(_rules2[i][0], _rules2[i][1]);
}
} | [
"function",
"ParserInline",
"(",
")",
"{",
"var",
"i",
";",
"/**\n * ParserInline#ruler -> Ruler\n *\n * [[Ruler]] instance. Keep configuration of inline rules.\n **/",
"this",
".",
"ruler",
"=",
"new",
"Ruler",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"... | new ParserInline() | [
"new",
"ParserInline",
"()"
] | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/lib/parser_inline.js#L40-L65 | train | Inline Parser class | [
30522,
3853,
11968,
8043,
2378,
4179,
1006,
1007,
1063,
13075,
1045,
1025,
1013,
1008,
1008,
1008,
11968,
8043,
2378,
4179,
1001,
7786,
1011,
1028,
7786,
1008,
1008,
1031,
1031,
7786,
1033,
1033,
6013,
1012,
2562,
9563,
1997,
23881,
3513,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/sunburst/SunburstPiece.js | getNodeColor | function getNodeColor(node, seriesModel, ecModel) {
// Color from visualMap
var visualColor = node.getVisual('color');
var visualMetaList = node.getVisual('visualMeta');
if (!visualMetaList || visualMetaList.length === 0) {
// Use first-generation color if has no visualMap
visualColor = null;
}
// Self color or level color
var color = node.getModel('itemStyle').get('color');
if (color) {
return color;
}
else if (visualColor) {
// Color mapping
return visualColor;
}
else if (node.depth === 0) {
// Virtual root node
return ecModel.option.color[0];
}
else {
// First-generation color
var length = ecModel.option.color.length;
color = ecModel.option.color[getRootId(node) % length];
}
return color;
} | javascript | function getNodeColor(node, seriesModel, ecModel) {
// Color from visualMap
var visualColor = node.getVisual('color');
var visualMetaList = node.getVisual('visualMeta');
if (!visualMetaList || visualMetaList.length === 0) {
// Use first-generation color if has no visualMap
visualColor = null;
}
// Self color or level color
var color = node.getModel('itemStyle').get('color');
if (color) {
return color;
}
else if (visualColor) {
// Color mapping
return visualColor;
}
else if (node.depth === 0) {
// Virtual root node
return ecModel.option.color[0];
}
else {
// First-generation color
var length = ecModel.option.color.length;
color = ecModel.option.color[getRootId(node) % length];
}
return color;
} | [
"function",
"getNodeColor",
"(",
"node",
",",
"seriesModel",
",",
"ecModel",
")",
"{",
"// Color from visualMap",
"var",
"visualColor",
"=",
"node",
".",
"getVisual",
"(",
"'color'",
")",
";",
"var",
"visualMetaList",
"=",
"node",
".",
"getVisual",
"(",
"'visu... | Get node color
@param {TreeNode} node the node to get color
@param {module:echarts/model/Series} seriesModel series
@param {module:echarts/model/Global} ecModel echarts defaults | [
"Get",
"node",
"color"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/sunburst/SunburstPiece.js#L356-L384 | train | Get node color | [
30522,
3853,
2131,
3630,
3207,
18717,
1006,
13045,
1010,
2186,
5302,
9247,
1010,
14925,
5302,
9247,
1007,
1063,
1013,
1013,
3609,
2013,
5107,
2863,
2361,
13075,
5107,
18717,
1027,
13045,
1012,
2131,
11365,
8787,
1006,
1005,
3609,
1005,
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... |
babel/babel | packages/babel-traverse/src/path/evaluation.js | deopt | function deopt(path, state) {
if (!state.confident) return;
state.deoptPath = path;
state.confident = false;
} | javascript | function deopt(path, state) {
if (!state.confident) return;
state.deoptPath = path;
state.confident = false;
} | [
"function",
"deopt",
"(",
"path",
",",
"state",
")",
"{",
"if",
"(",
"!",
"state",
".",
"confident",
")",
"return",
";",
"state",
".",
"deoptPath",
"=",
"path",
";",
"state",
".",
"confident",
"=",
"false",
";",
"}"
] | Deopts the evaluation | [
"Deopts",
"the",
"evaluation"
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-traverse/src/path/evaluation.js#L34-L38 | train | Deopt a path | [
30522,
3853,
2139,
7361,
2102,
1006,
4130,
1010,
2110,
1007,
1063,
2065,
1006,
999,
2110,
1012,
9657,
1007,
2709,
1025,
2110,
1012,
2139,
7361,
25856,
8988,
1027,
4130,
1025,
2110,
1012,
9657,
1027,
6270,
1025,
1065,
102,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/GrowingEnablement.js | function(bLoading) {
var oTrigger = this._oTrigger,
oControl = this._oControl;
// If there are no visible columns then also hide the trigger.
if (!oTrigger || !oControl || !oControl.shouldRenderItems() || !oControl.getDomRef()) {
return;
}
var oBinding = oControl.getBinding("items");
if (!oBinding) {
return;
}
// update busy state
oTrigger.setBusy(bLoading);
oTrigger.$().toggleClass("sapMGrowingListBusyIndicatorVisible", bLoading);
if (bLoading) {
oTrigger.setActive(false);
oControl.$("triggerList").css("display", "");
} else {
var aItems = oControl.getItems(true),
iItemsLength = aItems.length,
iBindingLength = oBinding.getLength() || 0,
bLengthFinal = oBinding.isLengthFinal(),
bHasScrollToLoad = oControl.getGrowingScrollToLoad(),
oTriggerDomRef = oTrigger.getDomRef();
// put the focus to the newly added item if growing button is pressed
if (oTriggerDomRef && oTriggerDomRef.contains(document.activeElement)) {
(aItems[this._iLastItemsCount] || oControl).focus();
}
// show, update or hide the growing button
if (!iItemsLength || !this._iLimit ||
(bLengthFinal && this._iLimit >= iBindingLength) ||
(bHasScrollToLoad && this._getHasScrollbars())) {
oControl.$("triggerList").css("display", "none");
} else {
if (bLengthFinal) {
oControl.$("triggerInfo").css("display", "block").text(this._getListItemInfo());
}
oTrigger.$().removeClass("sapMGrowingListBusyIndicatorVisible");
oControl.$("triggerList").css("display", "");
}
// store the last item count to be able to focus to the newly added item when the growing button is pressed
this._iLastItemsCount = this._oControl.getItems(true).length;
// at the beginning we should scroll to last item
if (bHasScrollToLoad && this._oScrollPosition === undefined && oControl.getGrowingDirection() == ListGrowingDirection.Upwards) {
this._oScrollPosition = {
left : 0,
top : 0
};
}
// scroll to last position
if (iItemsLength > 0 && this._oScrollPosition) {
var oScrollDelegate = this._oScrollDelegate,
oScrollPosition = this._oScrollPosition;
oScrollDelegate.scrollTo(oScrollPosition.left, oScrollDelegate.getScrollHeight() - oScrollPosition.top);
this._oScrollPosition = null;
}
}
} | javascript | function(bLoading) {
var oTrigger = this._oTrigger,
oControl = this._oControl;
// If there are no visible columns then also hide the trigger.
if (!oTrigger || !oControl || !oControl.shouldRenderItems() || !oControl.getDomRef()) {
return;
}
var oBinding = oControl.getBinding("items");
if (!oBinding) {
return;
}
// update busy state
oTrigger.setBusy(bLoading);
oTrigger.$().toggleClass("sapMGrowingListBusyIndicatorVisible", bLoading);
if (bLoading) {
oTrigger.setActive(false);
oControl.$("triggerList").css("display", "");
} else {
var aItems = oControl.getItems(true),
iItemsLength = aItems.length,
iBindingLength = oBinding.getLength() || 0,
bLengthFinal = oBinding.isLengthFinal(),
bHasScrollToLoad = oControl.getGrowingScrollToLoad(),
oTriggerDomRef = oTrigger.getDomRef();
// put the focus to the newly added item if growing button is pressed
if (oTriggerDomRef && oTriggerDomRef.contains(document.activeElement)) {
(aItems[this._iLastItemsCount] || oControl).focus();
}
// show, update or hide the growing button
if (!iItemsLength || !this._iLimit ||
(bLengthFinal && this._iLimit >= iBindingLength) ||
(bHasScrollToLoad && this._getHasScrollbars())) {
oControl.$("triggerList").css("display", "none");
} else {
if (bLengthFinal) {
oControl.$("triggerInfo").css("display", "block").text(this._getListItemInfo());
}
oTrigger.$().removeClass("sapMGrowingListBusyIndicatorVisible");
oControl.$("triggerList").css("display", "");
}
// store the last item count to be able to focus to the newly added item when the growing button is pressed
this._iLastItemsCount = this._oControl.getItems(true).length;
// at the beginning we should scroll to last item
if (bHasScrollToLoad && this._oScrollPosition === undefined && oControl.getGrowingDirection() == ListGrowingDirection.Upwards) {
this._oScrollPosition = {
left : 0,
top : 0
};
}
// scroll to last position
if (iItemsLength > 0 && this._oScrollPosition) {
var oScrollDelegate = this._oScrollDelegate,
oScrollPosition = this._oScrollPosition;
oScrollDelegate.scrollTo(oScrollPosition.left, oScrollDelegate.getScrollHeight() - oScrollPosition.top);
this._oScrollPosition = null;
}
}
} | [
"function",
"(",
"bLoading",
")",
"{",
"var",
"oTrigger",
"=",
"this",
".",
"_oTrigger",
",",
"oControl",
"=",
"this",
".",
"_oControl",
";",
"// If there are no visible columns then also hide the trigger.",
"if",
"(",
"!",
"oTrigger",
"||",
"!",
"oControl",
"||",... | updates the trigger state | [
"updates",
"the",
"trigger",
"state"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/GrowingEnablement.js#L611-L679 | train | Show or hide the trigger | [
30522,
3853,
1006,
1038,
18570,
1007,
1063,
13075,
27178,
3089,
13327,
1027,
2023,
1012,
1035,
27178,
3089,
13327,
1010,
1051,
8663,
13181,
2140,
1027,
2023,
1012,
1035,
1051,
8663,
13181,
2140,
1025,
1013,
1013,
2065,
2045,
2024,
2053,
571... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | _init | function _init() {
$cursorInfo = $("#status-cursor");
$fileInfo = $("#status-file");
$indentType = $("#indent-type");
$indentWidthLabel = $("#indent-width-label");
$indentWidthInput = $("#indent-width-input");
$statusOverwrite = $("#status-overwrite");
languageSelect = new DropdownButton("", [], function (item, index) {
var document = EditorManager.getActiveEditor().document,
defaultLang = LanguageManager.getLanguageForPath(document.file.fullPath, true);
if (item === LANGUAGE_SET_AS_DEFAULT) {
var label = _.escape(StringUtils.format(Strings.STATUSBAR_SET_DEFAULT_LANG, LanguageManager.getCompoundFileExtension(document.file.fullPath)));
return { html: label, enabled: document.getLanguage() !== defaultLang };
}
var html = _.escape(item.getName());
// Show indicators for currently selected & default languages for the current file
if (item === defaultLang) {
html += " <span class='default-language'>" + Strings.STATUSBAR_DEFAULT_LANG + "</span>";
}
if (item === document.getLanguage()) {
html = "<span class='checked-language'></span>" + html;
}
return html;
});
languageSelect.dropdownExtraClasses = "dropdown-status-bar";
languageSelect.$button.addClass("btn-status-bar");
$("#status-language").append(languageSelect.$button);
languageSelect.$button.attr("title", Strings.STATUSBAR_LANG_TOOLTIP);
encodingSelect = new DropdownButton("", [], function (item, index) {
var document = EditorManager.getActiveEditor().document;
var html = _.escape(item);
// Show indicators for currently selected & default languages for the current file
if (item === "UTF-8") {
html += " <span class='default-language'>" + Strings.STATUSBAR_DEFAULT_LANG + "</span>";
}
if (item === document.file._encoding) {
html = "<span class='checked-language'></span>" + html;
}
return html;
});
encodingSelect.dropdownExtraClasses = "dropdown-status-bar";
encodingSelect.$button.addClass("btn-status-bar");
$("#status-encoding").append(encodingSelect.$button);
encodingSelect.$button.attr("title", Strings.STATUSBAR_ENCODING_TOOLTIP);
// indentation event handlers
$indentType.on("click", _toggleIndentType);
$indentWidthLabel
.on("click", function () {
// update the input value before displaying
var fullPath = EditorManager.getActiveEditor().document.file.fullPath;
$indentWidthInput.val(_getIndentSize(fullPath));
$indentWidthLabel.addClass("hidden");
$indentWidthInput.removeClass("hidden");
$indentWidthInput.focus();
$indentWidthInput
.on("blur", function () {
_changeIndentWidth(fullPath, $indentWidthInput.val());
})
.on("keyup", function (event) {
if (event.keyCode === KeyEvent.DOM_VK_RETURN) {
$indentWidthInput.blur();
} else if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) {
_changeIndentWidth(fullPath, false);
}
});
});
$indentWidthInput.focus(function () { $indentWidthInput.select(); });
// Language select change handler
languageSelect.on("select", function (e, lang) {
var document = EditorManager.getActiveEditor().document,
fullPath = document.file.fullPath;
var fileType = (document.file instanceof InMemoryFile) ? "newFile" : "existingFile",
filelanguageName = lang ? lang._name : "";
HealthLogger.sendAnalyticsData(
HealthLogger.commonStrings.USAGE + HealthLogger.commonStrings.LANGUAGE_CHANGE
+ filelanguageName + fileType,
HealthLogger.commonStrings.USAGE,
HealthLogger.commonStrings.LANGUAGE_CHANGE,
filelanguageName.toLowerCase(),
fileType
);
if (lang === LANGUAGE_SET_AS_DEFAULT) {
// Set file's current language in preferences as a file extension override (only enabled if not default already)
var fileExtensionMap = PreferencesManager.get("language.fileExtensions");
fileExtensionMap[LanguageManager.getCompoundFileExtension(fullPath)] = document.getLanguage().getId();
PreferencesManager.set("language.fileExtensions", fileExtensionMap);
} else {
// Set selected language as a path override for just this one file (not persisted)
var defaultLang = LanguageManager.getLanguageForPath(fullPath, true);
// if default language selected, pass null to clear the override
LanguageManager.setLanguageOverrideForPath(fullPath, lang === defaultLang ? null : lang);
}
});
// Encoding select change handler
encodingSelect.on("select", function (e, encoding) {
var document = EditorManager.getActiveEditor().document,
originalPath = document.file.fullPath,
originalEncoding = document.file._encoding;
document.file._encoding = encoding;
if (!(document.file instanceof InMemoryFile) && document.isDirty) {
CommandManager.execute(Commands.FILE_SAVE_AS, {doc: document}).done(function () {
var doc = DocumentManager.getCurrentDocument();
if (originalPath === doc.file.fullPath) {
_changeEncodingAndReloadDoc(doc);
} else {
document.file._encoding = originalEncoding;
}
}).fail(function () {
document.file._encoding = originalEncoding;
});
} else if (document.file instanceof InMemoryFile) {
encodingSelect.$button.text(encoding);
} else if (!document.isDirty) {
_changeEncodingAndReloadDoc(document);
}
});
$statusOverwrite.on("click", _updateEditorOverwriteMode);
} | javascript | function _init() {
$cursorInfo = $("#status-cursor");
$fileInfo = $("#status-file");
$indentType = $("#indent-type");
$indentWidthLabel = $("#indent-width-label");
$indentWidthInput = $("#indent-width-input");
$statusOverwrite = $("#status-overwrite");
languageSelect = new DropdownButton("", [], function (item, index) {
var document = EditorManager.getActiveEditor().document,
defaultLang = LanguageManager.getLanguageForPath(document.file.fullPath, true);
if (item === LANGUAGE_SET_AS_DEFAULT) {
var label = _.escape(StringUtils.format(Strings.STATUSBAR_SET_DEFAULT_LANG, LanguageManager.getCompoundFileExtension(document.file.fullPath)));
return { html: label, enabled: document.getLanguage() !== defaultLang };
}
var html = _.escape(item.getName());
// Show indicators for currently selected & default languages for the current file
if (item === defaultLang) {
html += " <span class='default-language'>" + Strings.STATUSBAR_DEFAULT_LANG + "</span>";
}
if (item === document.getLanguage()) {
html = "<span class='checked-language'></span>" + html;
}
return html;
});
languageSelect.dropdownExtraClasses = "dropdown-status-bar";
languageSelect.$button.addClass("btn-status-bar");
$("#status-language").append(languageSelect.$button);
languageSelect.$button.attr("title", Strings.STATUSBAR_LANG_TOOLTIP);
encodingSelect = new DropdownButton("", [], function (item, index) {
var document = EditorManager.getActiveEditor().document;
var html = _.escape(item);
// Show indicators for currently selected & default languages for the current file
if (item === "UTF-8") {
html += " <span class='default-language'>" + Strings.STATUSBAR_DEFAULT_LANG + "</span>";
}
if (item === document.file._encoding) {
html = "<span class='checked-language'></span>" + html;
}
return html;
});
encodingSelect.dropdownExtraClasses = "dropdown-status-bar";
encodingSelect.$button.addClass("btn-status-bar");
$("#status-encoding").append(encodingSelect.$button);
encodingSelect.$button.attr("title", Strings.STATUSBAR_ENCODING_TOOLTIP);
// indentation event handlers
$indentType.on("click", _toggleIndentType);
$indentWidthLabel
.on("click", function () {
// update the input value before displaying
var fullPath = EditorManager.getActiveEditor().document.file.fullPath;
$indentWidthInput.val(_getIndentSize(fullPath));
$indentWidthLabel.addClass("hidden");
$indentWidthInput.removeClass("hidden");
$indentWidthInput.focus();
$indentWidthInput
.on("blur", function () {
_changeIndentWidth(fullPath, $indentWidthInput.val());
})
.on("keyup", function (event) {
if (event.keyCode === KeyEvent.DOM_VK_RETURN) {
$indentWidthInput.blur();
} else if (event.keyCode === KeyEvent.DOM_VK_ESCAPE) {
_changeIndentWidth(fullPath, false);
}
});
});
$indentWidthInput.focus(function () { $indentWidthInput.select(); });
// Language select change handler
languageSelect.on("select", function (e, lang) {
var document = EditorManager.getActiveEditor().document,
fullPath = document.file.fullPath;
var fileType = (document.file instanceof InMemoryFile) ? "newFile" : "existingFile",
filelanguageName = lang ? lang._name : "";
HealthLogger.sendAnalyticsData(
HealthLogger.commonStrings.USAGE + HealthLogger.commonStrings.LANGUAGE_CHANGE
+ filelanguageName + fileType,
HealthLogger.commonStrings.USAGE,
HealthLogger.commonStrings.LANGUAGE_CHANGE,
filelanguageName.toLowerCase(),
fileType
);
if (lang === LANGUAGE_SET_AS_DEFAULT) {
// Set file's current language in preferences as a file extension override (only enabled if not default already)
var fileExtensionMap = PreferencesManager.get("language.fileExtensions");
fileExtensionMap[LanguageManager.getCompoundFileExtension(fullPath)] = document.getLanguage().getId();
PreferencesManager.set("language.fileExtensions", fileExtensionMap);
} else {
// Set selected language as a path override for just this one file (not persisted)
var defaultLang = LanguageManager.getLanguageForPath(fullPath, true);
// if default language selected, pass null to clear the override
LanguageManager.setLanguageOverrideForPath(fullPath, lang === defaultLang ? null : lang);
}
});
// Encoding select change handler
encodingSelect.on("select", function (e, encoding) {
var document = EditorManager.getActiveEditor().document,
originalPath = document.file.fullPath,
originalEncoding = document.file._encoding;
document.file._encoding = encoding;
if (!(document.file instanceof InMemoryFile) && document.isDirty) {
CommandManager.execute(Commands.FILE_SAVE_AS, {doc: document}).done(function () {
var doc = DocumentManager.getCurrentDocument();
if (originalPath === doc.file.fullPath) {
_changeEncodingAndReloadDoc(doc);
} else {
document.file._encoding = originalEncoding;
}
}).fail(function () {
document.file._encoding = originalEncoding;
});
} else if (document.file instanceof InMemoryFile) {
encodingSelect.$button.text(encoding);
} else if (!document.isDirty) {
_changeEncodingAndReloadDoc(document);
}
});
$statusOverwrite.on("click", _updateEditorOverwriteMode);
} | [
"function",
"_init",
"(",
")",
"{",
"$cursorInfo",
"=",
"$",
"(",
"\"#status-cursor\"",
")",
";",
"$fileInfo",
"=",
"$",
"(",
"\"#status-file\"",
")",
";",
"$indentType",
"=",
"$",
"(",
"\"#indent-type\"",
")",
";",
"$indentWidthLabel",
"=",
"$",
"(",
"\"#... | Initialize | [
"Initialize"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorStatusBar.js#L380-L520 | train | Initialize status bar | [
30522,
3853,
1035,
1999,
4183,
1006,
1007,
1063,
1002,
12731,
25301,
6657,
14876,
1027,
1002,
1006,
1000,
1001,
3570,
1011,
12731,
25301,
2099,
1000,
1007,
1025,
1002,
5371,
2378,
14876,
1027,
1002,
1006,
1000,
1001,
3570,
1011,
5371,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
} | javascript | function(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
} | [
"function",
"(",
"array",
",",
"from",
",",
"to",
")",
"{",
"var",
"rest",
"=",
"array",
".",
"slice",
"(",
"(",
"to",
"||",
"from",
")",
"+",
"1",
"||",
"array",
".",
"length",
")",
";",
"array",
".",
"length",
"=",
"from",
"<",
"0",
"?",
"a... | TODO helper method to remove elements from array
@private | [
"TODO",
"helper",
"method",
"to",
"remove",
"elements",
"from",
"array"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3654-L3658 | train | Add a range of items to an array | [
30522,
3853,
1006,
9140,
1010,
2013,
1010,
2000,
1007,
1063,
13075,
2717,
1027,
9140,
1012,
14704,
1006,
1006,
2000,
1064,
1064,
2013,
1007,
1009,
1015,
1064,
1064,
9140,
1012,
3091,
1007,
1025,
9140,
1012,
3091,
1027,
2013,
1026,
1014,
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... | |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/DataGrid.js | function()
{
var headerTableColumns = this._headerTableColumnGroup.children;
var tableWidth = this._dataTable.offsetWidth;
var numColumns = headerTableColumns.length;
// Do not attempt to use offsetes if we're not attached to the document tree yet.
if (!this._columnWidthsInitialized && this.element.offsetWidth) {
// Give all the columns initial widths now so that during a resize,
// when the two columns that get resized get a percent value for
// their widths, all the other columns already have percent values
// for their widths.
for (var i = 0; i < numColumns; i++) {
var columnWidth = this.headerTableBody.rows[0].cells[i].offsetWidth;
var percentWidth = ((columnWidth / tableWidth) * 100) + "%";
this._headerTableColumnGroup.children[i].style.width = percentWidth;
this._dataTableColumnGroup.children[i].style.width = percentWidth;
}
this._columnWidthsInitialized = true;
}
this._positionResizers();
this.dispatchEventToListeners("width changed");
} | javascript | function()
{
var headerTableColumns = this._headerTableColumnGroup.children;
var tableWidth = this._dataTable.offsetWidth;
var numColumns = headerTableColumns.length;
// Do not attempt to use offsetes if we're not attached to the document tree yet.
if (!this._columnWidthsInitialized && this.element.offsetWidth) {
// Give all the columns initial widths now so that during a resize,
// when the two columns that get resized get a percent value for
// their widths, all the other columns already have percent values
// for their widths.
for (var i = 0; i < numColumns; i++) {
var columnWidth = this.headerTableBody.rows[0].cells[i].offsetWidth;
var percentWidth = ((columnWidth / tableWidth) * 100) + "%";
this._headerTableColumnGroup.children[i].style.width = percentWidth;
this._dataTableColumnGroup.children[i].style.width = percentWidth;
}
this._columnWidthsInitialized = true;
}
this._positionResizers();
this.dispatchEventToListeners("width changed");
} | [
"function",
"(",
")",
"{",
"var",
"headerTableColumns",
"=",
"this",
".",
"_headerTableColumnGroup",
".",
"children",
";",
"var",
"tableWidth",
"=",
"this",
".",
"_dataTable",
".",
"offsetWidth",
";",
"var",
"numColumns",
"=",
"headerTableColumns",
".",
"length"... | Updates the widths of the table, including the positions of the column resizers. IMPORTANT: This function MUST be called once after the element of the DataGrid is attached to its parent element and every subsequent time the width of the parent element is changed in order to make it possible to resize the columns. If this function is not called after the DataGrid is attached to its parent element, then the DataGrid's columns will not be resizable. | [
"Updates",
"the",
"widths",
"of",
"the",
"table",
"including",
"the",
"positions",
"of",
"the",
"column",
"resizers",
".",
"IMPORTANT",
":",
"This",
"function",
"MUST",
"be",
"called",
"once",
"after",
"the",
"element",
"of",
"the",
"DataGrid",
"is",
"attach... | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/DataGrid.js#L404-L427 | train | This method is called when the width of the table is changed. | [
30522,
3853,
1006,
1007,
1063,
13075,
20346,
10880,
25778,
2819,
3619,
1027,
2023,
1012,
1035,
20346,
10880,
25778,
2819,
3070,
22107,
1012,
2336,
1025,
13075,
2795,
9148,
11927,
2232,
1027,
2023,
1012,
1035,
2951,
10880,
1012,
16396,
9148,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
graphql/graphql-js | resources/benchmark.js | prepareRevision | function prepareRevision(revision) {
console.log(`🍳 Preparing ${revision}...`);
if (revision === LOCAL) {
return babelBuild(LOCAL_DIR());
} else {
if (!fs.existsSync(TEMP_DIR())) {
fs.mkdirSync(TEMP_DIR());
}
const hash = hashForRevision(revision);
const dir = TEMP_DIR(hash);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
execSync(`git archive "${hash}" | tar -xC "${dir}"`);
execSync('yarn install', { cwd: dir });
}
for (const file of findFiles(LOCAL_DIR('src'), '*/__tests__/*')) {
const from = LOCAL_DIR('src', file);
const to = path.join(dir, 'src', file);
fs.copyFileSync(from, to);
}
execSync(
`cp -R "${LOCAL_DIR()}/src/__fixtures__/" "${dir}/src/__fixtures__/"`
);
return babelBuild(dir);
}
} | javascript | function prepareRevision(revision) {
console.log(`🍳 Preparing ${revision}...`);
if (revision === LOCAL) {
return babelBuild(LOCAL_DIR());
} else {
if (!fs.existsSync(TEMP_DIR())) {
fs.mkdirSync(TEMP_DIR());
}
const hash = hashForRevision(revision);
const dir = TEMP_DIR(hash);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
execSync(`git archive "${hash}" | tar -xC "${dir}"`);
execSync('yarn install', { cwd: dir });
}
for (const file of findFiles(LOCAL_DIR('src'), '*/__tests__/*')) {
const from = LOCAL_DIR('src', file);
const to = path.join(dir, 'src', file);
fs.copyFileSync(from, to);
}
execSync(
`cp -R "${LOCAL_DIR()}/src/__fixtures__/" "${dir}/src/__fixtures__/"`
);
return babelBuild(dir);
}
} | [
"function",
"prepareRevision",
"(",
"revision",
")",
"{",
"console",
".",
"log",
"(",
"`",
"ev",
"ision}..",
".",
"",
"",
"",
"if",
"(",
"revision",
"===",
"LOCAL",
")",
"{",
"return",
"babelBuild",
"(",
"LOCAL_DIR",
"(",
")",
")",
";",
"}",
"else",
... | Build a benchmarkable environment for the given revision and returns path to its 'dist' directory. | [
"Build",
"a",
"benchmarkable",
"environment",
"for",
"the",
"given",
"revision",
"and",
"returns",
"path",
"to",
"its",
"dist",
"directory",
"."
] | b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef | https://github.com/graphql/graphql-js/blob/b65ff6db8893c1c68f0f236c4b2d663e6c55f5ef/resources/benchmark.js#L48-L77 | train | Prepare a revision for babel build | [
30522,
3853,
7374,
2890,
17084,
1006,
13921,
1007,
1063,
10122,
1012,
8833,
1006,
1036,
100,
8225,
1002,
1063,
13921,
1065,
1012,
1012,
1012,
1036,
1007,
1025,
2065,
1006,
13921,
1027,
1027,
1027,
2334,
1007,
1063,
2709,
11561,
20850,
19231... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (rules, selectedRulesIDs, issues) {
var rulesViewModel = {},
issueCount = 0,
group = {},
library = {},
rule = {},
rulesCopy = jQuery.extend(true, {}, rules),
issuesCopy = jQuery.extend(true, {}, issues);
for (group in rulesCopy) {
rulesViewModel[group] = jQuery.extend(true, {}, rulesCopy[group].ruleset._mRules);
library = rulesViewModel[group];
// Create non-enumerable properties
Object.defineProperty(library, 'selected', {
enumerable: false,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(library, 'issueCount', {
enumerable: false,
configurable: true,
writable: true,
value: 0
});
for (rule in rulesCopy[group].ruleset._mRules) {
library[rule] = jQuery.extend(true, [], library[rule]);
// Create non-enumerable properties
Object.defineProperty(library[rule], 'selected', {
enumerable: false,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(library[rule], 'issueCount', {
enumerable: false,
configurable: true,
writable: true,
value: 0
});
// Add selected flag to library and rule level.
if (selectedRulesIDs[rule]) {
library[rule].selected = true;
library.selected = true;
}
// Add issue count to library and rule level.
if (issuesCopy[group] && issuesCopy[group][rule]) {
// Not creating a new array to keep the properties.
library[rule].push.apply(library[rule], issuesCopy[group][rule]);
issueCount = issuesCopy[group][rule].length;
library[rule].issueCount = issueCount;
library.issueCount += issueCount;
}
}
}
return rulesViewModel;
} | javascript | function (rules, selectedRulesIDs, issues) {
var rulesViewModel = {},
issueCount = 0,
group = {},
library = {},
rule = {},
rulesCopy = jQuery.extend(true, {}, rules),
issuesCopy = jQuery.extend(true, {}, issues);
for (group in rulesCopy) {
rulesViewModel[group] = jQuery.extend(true, {}, rulesCopy[group].ruleset._mRules);
library = rulesViewModel[group];
// Create non-enumerable properties
Object.defineProperty(library, 'selected', {
enumerable: false,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(library, 'issueCount', {
enumerable: false,
configurable: true,
writable: true,
value: 0
});
for (rule in rulesCopy[group].ruleset._mRules) {
library[rule] = jQuery.extend(true, [], library[rule]);
// Create non-enumerable properties
Object.defineProperty(library[rule], 'selected', {
enumerable: false,
configurable: true,
writable: true,
value: false
});
Object.defineProperty(library[rule], 'issueCount', {
enumerable: false,
configurable: true,
writable: true,
value: 0
});
// Add selected flag to library and rule level.
if (selectedRulesIDs[rule]) {
library[rule].selected = true;
library.selected = true;
}
// Add issue count to library and rule level.
if (issuesCopy[group] && issuesCopy[group][rule]) {
// Not creating a new array to keep the properties.
library[rule].push.apply(library[rule], issuesCopy[group][rule]);
issueCount = issuesCopy[group][rule].length;
library[rule].issueCount = issueCount;
library.issueCount += issueCount;
}
}
}
return rulesViewModel;
} | [
"function",
"(",
"rules",
",",
"selectedRulesIDs",
",",
"issues",
")",
"{",
"var",
"rulesViewModel",
"=",
"{",
"}",
",",
"issueCount",
"=",
"0",
",",
"group",
"=",
"{",
"}",
",",
"library",
"=",
"{",
"}",
",",
"rule",
"=",
"{",
"}",
",",
"rulesCopy... | Gets rules and issues, and converts each rule to a ruleViewModel - parameters should be converted as specified beforehand.
@public
@method
@name sap.ui.support.IssueManager.getRulesViewModel
@param {object} rules All the rules from _mRulesets
@param {array} selectedRulesIDs The rule ID's of the selected rules.
@param {array} issues The issues to map to the rulesViewModel
The issues passes should be grouped and in ViewModel format.
@returns {object} rulesViewModel All the rules with issues, selected flag and issueCount properties
The issues are in ViewModel format. | [
"Gets",
"rules",
"and",
"issues",
"and",
"converts",
"each",
"rule",
"to",
"a",
"ruleViewModel",
"-",
"parameters",
"should",
"be",
"converted",
"as",
"specified",
"beforehand",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/IssueManager.js#L133-L195 | train | Creates a new rules view model and issues view model | [
30522,
3853,
1006,
3513,
1010,
3479,
6820,
4244,
9821,
1010,
3314,
1007,
1063,
13075,
3513,
8584,
5302,
9247,
1027,
1063,
1065,
1010,
3277,
3597,
16671,
1027,
1014,
1010,
2177,
1027,
1063,
1065,
1010,
3075,
1027,
1063,
1065,
1010,
3627,
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... | |
chartjs/Chart.js | src/scales/scale.time.js | computeOffsets | function computeOffsets(table, ticks, min, max, options) {
var start = 0;
var end = 0;
var first, last;
if (options.offset && ticks.length) {
if (!getMin(options)) {
first = interpolate(table, 'time', ticks[0], 'pos');
if (ticks.length === 1) {
start = 1 - first;
} else {
start = (interpolate(table, 'time', ticks[1], 'pos') - first) / 2;
}
}
if (!getMax(options)) {
last = interpolate(table, 'time', ticks[ticks.length - 1], 'pos');
if (ticks.length === 1) {
end = last;
} else {
end = (last - interpolate(table, 'time', ticks[ticks.length - 2], 'pos')) / 2;
}
}
}
return {start: start, end: end};
} | javascript | function computeOffsets(table, ticks, min, max, options) {
var start = 0;
var end = 0;
var first, last;
if (options.offset && ticks.length) {
if (!getMin(options)) {
first = interpolate(table, 'time', ticks[0], 'pos');
if (ticks.length === 1) {
start = 1 - first;
} else {
start = (interpolate(table, 'time', ticks[1], 'pos') - first) / 2;
}
}
if (!getMax(options)) {
last = interpolate(table, 'time', ticks[ticks.length - 1], 'pos');
if (ticks.length === 1) {
end = last;
} else {
end = (last - interpolate(table, 'time', ticks[ticks.length - 2], 'pos')) / 2;
}
}
}
return {start: start, end: end};
} | [
"function",
"computeOffsets",
"(",
"table",
",",
"ticks",
",",
"min",
",",
"max",
",",
"options",
")",
"{",
"var",
"start",
"=",
"0",
";",
"var",
"end",
"=",
"0",
";",
"var",
"first",
",",
"last",
";",
"if",
"(",
"options",
".",
"offset",
"&&",
"... | Returns the start and end offsets from edges in the form of {start, end}
where each value is a relative width to the scale and ranges between 0 and 1.
They add extra margins on the both sides by scaling down the original scale.
Offsets are added when the `offset` option is true. | [
"Returns",
"the",
"start",
"and",
"end",
"offsets",
"from",
"edges",
"in",
"the",
"form",
"of",
"{",
"start",
"end",
"}",
"where",
"each",
"value",
"is",
"a",
"relative",
"width",
"to",
"the",
"scale",
"and",
"ranges",
"between",
"0",
"and",
"1",
".",
... | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/scales/scale.time.js#L384-L409 | train | Compute the offsets for a given set of ticks | [
30522,
3853,
24134,
27475,
8454,
1006,
2795,
1010,
16356,
2015,
1010,
8117,
1010,
4098,
1010,
7047,
1007,
1063,
13075,
2707,
1027,
1014,
1025,
13075,
2203,
1027,
1014,
1025,
13075,
2034,
1010,
2197,
1025,
2065,
1006,
7047,
1012,
16396,
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... |
SAP/openui5 | src/sap.ui.codeeditor/src/sap/ui/codeeditor/js/ace/worker-xml.js | function(namespaceURI,localName){
var attr = this.getNamedItemNS(namespaceURI,localName);
_removeNamedNode(this._ownerElement,this,attr);
return attr;
} | javascript | function(namespaceURI,localName){
var attr = this.getNamedItemNS(namespaceURI,localName);
_removeNamedNode(this._ownerElement,this,attr);
return attr;
} | [
"function",
"(",
"namespaceURI",
",",
"localName",
")",
"{",
"var",
"attr",
"=",
"this",
".",
"getNamedItemNS",
"(",
"namespaceURI",
",",
"localName",
")",
";",
"_removeNamedNode",
"(",
"this",
".",
"_ownerElement",
",",
"this",
",",
"attr",
")",
";",
"ret... | raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR | [
"raises",
":",
"NOT_FOUND_ERR",
"NO_MODIFICATION_ALLOWED_ERR"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.codeeditor/src/sap/ui/codeeditor/js/ace/worker-xml.js#L2100-L2104 | train | Removes an attribute from the element. | [
30522,
3853,
1006,
3415,
15327,
9496,
1010,
2334,
18442,
1007,
1063,
13075,
2012,
16344,
1027,
2023,
1012,
2131,
18442,
23194,
6633,
3619,
1006,
3415,
15327,
9496,
1010,
2334,
18442,
1007,
1025,
1035,
6366,
18442,
2094,
3630,
3207,
1006,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
sparksuite/simplemde-markdown-editor | src/js/simplemde.js | getState | function getState(cm, pos) {
pos = pos || cm.getCursor("start");
var stat = cm.getTokenAt(pos);
if(!stat.type) return {};
var types = stat.type.split(" ");
var ret = {},
data, text;
for(var i = 0; i < types.length; i++) {
data = types[i];
if(data === "strong") {
ret.bold = true;
} else if(data === "variable-2") {
text = cm.getLine(pos.line);
if(/^\s*\d+\.\s/.test(text)) {
ret["ordered-list"] = true;
} else {
ret["unordered-list"] = true;
}
} else if(data === "atom") {
ret.quote = true;
} else if(data === "em") {
ret.italic = true;
} else if(data === "quote") {
ret.quote = true;
} else if(data === "strikethrough") {
ret.strikethrough = true;
} else if(data === "comment") {
ret.code = true;
} else if(data === "link") {
ret.link = true;
} else if(data === "tag") {
ret.image = true;
} else if(data.match(/^header(\-[1-6])?$/)) {
ret[data.replace("header", "heading")] = true;
}
}
return ret;
} | javascript | function getState(cm, pos) {
pos = pos || cm.getCursor("start");
var stat = cm.getTokenAt(pos);
if(!stat.type) return {};
var types = stat.type.split(" ");
var ret = {},
data, text;
for(var i = 0; i < types.length; i++) {
data = types[i];
if(data === "strong") {
ret.bold = true;
} else if(data === "variable-2") {
text = cm.getLine(pos.line);
if(/^\s*\d+\.\s/.test(text)) {
ret["ordered-list"] = true;
} else {
ret["unordered-list"] = true;
}
} else if(data === "atom") {
ret.quote = true;
} else if(data === "em") {
ret.italic = true;
} else if(data === "quote") {
ret.quote = true;
} else if(data === "strikethrough") {
ret.strikethrough = true;
} else if(data === "comment") {
ret.code = true;
} else if(data === "link") {
ret.link = true;
} else if(data === "tag") {
ret.image = true;
} else if(data.match(/^header(\-[1-6])?$/)) {
ret[data.replace("header", "heading")] = true;
}
}
return ret;
} | [
"function",
"getState",
"(",
"cm",
",",
"pos",
")",
"{",
"pos",
"=",
"pos",
"||",
"cm",
".",
"getCursor",
"(",
"\"start\"",
")",
";",
"var",
"stat",
"=",
"cm",
".",
"getTokenAt",
"(",
"pos",
")",
";",
"if",
"(",
"!",
"stat",
".",
"type",
")",
"... | The state of CodeMirror at the given position. | [
"The",
"state",
"of",
"CodeMirror",
"at",
"the",
"given",
"position",
"."
] | 6abda7ab68cc20f4aca870eb243747951b90ab04 | https://github.com/sparksuite/simplemde-markdown-editor/blob/6abda7ab68cc20f4aca870eb243747951b90ab04/src/js/simplemde.js#L140-L179 | train | Get state of a given position | [
30522,
3853,
4152,
12259,
1006,
4642,
1010,
13433,
2015,
1007,
1063,
13433,
2015,
1027,
13433,
2015,
1064,
1064,
4642,
1012,
2131,
10841,
25301,
2099,
1006,
1000,
2707,
1000,
1007,
1025,
13075,
28093,
1027,
4642,
1012,
2131,
18715,
8189,
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... |
mui-org/material-ui | packages/material-ui-styles/src/getThemeProps/getThemeProps.js | getThemeProps | function getThemeProps(params) {
const { theme, name, props } = params;
if (!theme || !theme.props || !theme.props[name]) {
return props;
}
// Resolve default props, code borrow from React source.
// https://github.com/facebook/react/blob/15a8f031838a553e41c0b66eb1bcf1da8448104d/packages/react/src/ReactElement.js#L221
const defaultProps = theme.props[name];
let propName;
for (propName in defaultProps) {
if (props[propName] === undefined) {
props[propName] = defaultProps[propName];
}
}
return props;
} | javascript | function getThemeProps(params) {
const { theme, name, props } = params;
if (!theme || !theme.props || !theme.props[name]) {
return props;
}
// Resolve default props, code borrow from React source.
// https://github.com/facebook/react/blob/15a8f031838a553e41c0b66eb1bcf1da8448104d/packages/react/src/ReactElement.js#L221
const defaultProps = theme.props[name];
let propName;
for (propName in defaultProps) {
if (props[propName] === undefined) {
props[propName] = defaultProps[propName];
}
}
return props;
} | [
"function",
"getThemeProps",
"(",
"params",
")",
"{",
"const",
"{",
"theme",
",",
"name",
",",
"props",
"}",
"=",
"params",
";",
"if",
"(",
"!",
"theme",
"||",
"!",
"theme",
".",
"props",
"||",
"!",
"theme",
".",
"props",
"[",
"name",
"]",
")",
"... | /* eslint-disable no-restricted-syntax | [
"/",
"*",
"eslint",
"-",
"disable",
"no",
"-",
"restricted",
"-",
"syntax"
] | 1555e52367835946382fbf2a8f681de71318915d | https://github.com/mui-org/material-ui/blob/1555e52367835946382fbf2a8f681de71318915d/packages/material-ui-styles/src/getThemeProps/getThemeProps.js#L3-L22 | train | Get theme props | [
30522,
3853,
2131,
10760,
4168,
21572,
4523,
1006,
11498,
5244,
1007,
1063,
9530,
3367,
1063,
4323,
1010,
2171,
1010,
24387,
1065,
1027,
11498,
5244,
1025,
2065,
1006,
999,
4323,
1064,
1064,
999,
4323,
1012,
24387,
1064,
1064,
999,
4323,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/EditorManager.js | openDocument | function openDocument(doc, pane, editorOptions) {
var perfTimerName = PerfUtils.markStart("EditorManager.openDocument():\t" + (!doc || doc.file.fullPath));
if (doc && pane) {
_showEditor(doc, pane, editorOptions);
}
PerfUtils.addMeasurement(perfTimerName);
} | javascript | function openDocument(doc, pane, editorOptions) {
var perfTimerName = PerfUtils.markStart("EditorManager.openDocument():\t" + (!doc || doc.file.fullPath));
if (doc && pane) {
_showEditor(doc, pane, editorOptions);
}
PerfUtils.addMeasurement(perfTimerName);
} | [
"function",
"openDocument",
"(",
"doc",
",",
"pane",
",",
"editorOptions",
")",
"{",
"var",
"perfTimerName",
"=",
"PerfUtils",
".",
"markStart",
"(",
"\"EditorManager.openDocument():\\t\"",
"+",
"(",
"!",
"doc",
"||",
"doc",
".",
"file",
".",
"fullPath",
")",
... | Opens the specified document in the given pane
@param {!Document} doc - the document to open
@param {!Pane} pane - the pane to open the document in
@param {!Object} editorOptions - If specified, contains
editor options that can be passed to CodeMirror
@return {boolean} true if the file can be opened, false if not | [
"Opens",
"the",
"specified",
"document",
"in",
"the",
"given",
"pane"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorManager.js#L613-L621 | train | Open a document | [
30522,
3853,
2330,
3527,
24894,
4765,
1006,
9986,
1010,
6090,
2063,
1010,
3559,
7361,
9285,
1007,
1063,
13075,
2566,
6199,
14428,
12789,
4168,
1027,
2566,
11263,
3775,
4877,
1012,
6017,
7559,
2102,
1006,
1000,
3559,
24805,
4590,
1012,
2330,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/radioButton/radio-button.js | configureAria | function configureAria(element, scope){
element.attr({
id: attr.id || 'radio_' + $mdUtil.nextUid(),
role: 'radio',
'aria-checked': 'false'
});
$mdAria.expectWithText(element, 'aria-label');
} | javascript | function configureAria(element, scope){
element.attr({
id: attr.id || 'radio_' + $mdUtil.nextUid(),
role: 'radio',
'aria-checked': 'false'
});
$mdAria.expectWithText(element, 'aria-label');
} | [
"function",
"configureAria",
"(",
"element",
",",
"scope",
")",
"{",
"element",
".",
"attr",
"(",
"{",
"id",
":",
"attr",
".",
"id",
"||",
"'radio_'",
"+",
"$mdUtil",
".",
"nextUid",
"(",
")",
",",
"role",
":",
"'radio'",
",",
"'aria-checked'",
":",
... | Inject ARIA-specific attributes appropriate for each radio button | [
"Inject",
"ARIA",
"-",
"specific",
"attributes",
"appropriate",
"for",
"each",
"radio",
"button"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/radioButton/radio-button.js#L335-L343 | train | Aria - specific configuration for the radio button | [
30522,
3853,
9530,
8873,
27390,
14644,
2401,
1006,
5783,
1010,
9531,
1007,
1063,
5783,
1012,
2012,
16344,
1006,
1063,
8909,
1024,
2012,
16344,
1012,
8909,
1064,
1064,
1005,
2557,
1035,
1005,
1009,
1002,
9108,
21823,
2140,
1012,
2279,
21272,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/api/v0.1/subscribers.js | doQuery | function doQuery(options) {
return models.Subscriber.getByEmail(options.data.subscribers[0].email)
.then((subscriber) => {
if (subscriber && options.context.external) {
// we don't expose this information
return Promise.resolve(subscriber);
} else if (subscriber) {
return Promise.reject(new common.errors.ValidationError({message: common.i18n.t('errors.api.subscribers.subscriberAlreadyExists')}));
}
return models.Subscriber.add(options.data.subscribers[0], _.omit(options, ['data'])).catch((error) => {
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
return Promise.reject(new common.errors.ValidationError({message: common.i18n.t('errors.api.subscribers.subscriberAlreadyExists')}));
}
return Promise.reject(error);
});
})
.then((model) => {
return {
subscribers: [model.toJSON(options)]
};
});
} | javascript | function doQuery(options) {
return models.Subscriber.getByEmail(options.data.subscribers[0].email)
.then((subscriber) => {
if (subscriber && options.context.external) {
// we don't expose this information
return Promise.resolve(subscriber);
} else if (subscriber) {
return Promise.reject(new common.errors.ValidationError({message: common.i18n.t('errors.api.subscribers.subscriberAlreadyExists')}));
}
return models.Subscriber.add(options.data.subscribers[0], _.omit(options, ['data'])).catch((error) => {
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
return Promise.reject(new common.errors.ValidationError({message: common.i18n.t('errors.api.subscribers.subscriberAlreadyExists')}));
}
return Promise.reject(error);
});
})
.then((model) => {
return {
subscribers: [model.toJSON(options)]
};
});
} | [
"function",
"doQuery",
"(",
"options",
")",
"{",
"return",
"models",
".",
"Subscriber",
".",
"getByEmail",
"(",
"options",
".",
"data",
".",
"subscribers",
"[",
"0",
"]",
".",
"email",
")",
".",
"then",
"(",
"(",
"subscriber",
")",
"=>",
"{",
"if",
"... | ### Model Query
Make the call to the Model layer
@param {Object} options
@returns {Object} options | [
"###",
"Model",
"Query",
"Make",
"the",
"call",
"to",
"the",
"Model",
"layer"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/api/v0.1/subscribers.js#L113-L136 | train | Query for a subscriber | [
30522,
3853,
2079,
4226,
2854,
1006,
7047,
1007,
1063,
2709,
4275,
1012,
4942,
29234,
2099,
1012,
2131,
3762,
14545,
4014,
1006,
7047,
1012,
2951,
1012,
17073,
1031,
30524,
1007,
1025,
1065,
2842,
2065,
1006,
4942,
29234,
2099,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
keplergl/kepler.gl | src/reducers/vis-state-updaters.js | closeSpecificMapAtIndex | function closeSpecificMapAtIndex(state, action) {
// retrieve layers meta data from the remaining map that we need to keep
const indexToRetrieve = 1 - action.payload;
const metaSettings = state.splitMaps[indexToRetrieve];
if (!metaSettings || !metaSettings.layers) {
// if we can't find the meta settings we simply clean up splitMaps and
// keep global state as it is
// but why does this ever happen?
return {
...state,
splitMaps: []
};
}
const {layers} = state;
// update layer visibility
const newLayers = layers.map(layer =>
layer.updateLayerConfig({
isVisible: metaSettings.layers[layer.id]
? metaSettings.layers[layer.id].isVisible
: layer.config.isVisible
})
);
// delete map
return {
...state,
layers: newLayers,
splitMaps: []
};
} | javascript | function closeSpecificMapAtIndex(state, action) {
// retrieve layers meta data from the remaining map that we need to keep
const indexToRetrieve = 1 - action.payload;
const metaSettings = state.splitMaps[indexToRetrieve];
if (!metaSettings || !metaSettings.layers) {
// if we can't find the meta settings we simply clean up splitMaps and
// keep global state as it is
// but why does this ever happen?
return {
...state,
splitMaps: []
};
}
const {layers} = state;
// update layer visibility
const newLayers = layers.map(layer =>
layer.updateLayerConfig({
isVisible: metaSettings.layers[layer.id]
? metaSettings.layers[layer.id].isVisible
: layer.config.isVisible
})
);
// delete map
return {
...state,
layers: newLayers,
splitMaps: []
};
} | [
"function",
"closeSpecificMapAtIndex",
"(",
"state",
",",
"action",
")",
"{",
"// retrieve layers meta data from the remaining map that we need to keep",
"const",
"indexToRetrieve",
"=",
"1",
"-",
"action",
".",
"payload",
";",
"const",
"metaSettings",
"=",
"state",
".",
... | When a user clicks on the specific map closing icon
the application will close the selected map
and will merge the remaining one with the global state
TODO: i think in the future this action should be called merge map layers with global settings
@param {Object} state `visState`
@param {Object} action action
@returns {Object} nextState | [
"When",
"a",
"user",
"clicks",
"on",
"the",
"specific",
"map",
"closing",
"icon",
"the",
"application",
"will",
"close",
"the",
"selected",
"map",
"and",
"will",
"merge",
"the",
"remaining",
"one",
"with",
"the",
"global",
"state",
"TODO",
":",
"i",
"think... | 779238435707cc54335c2d00001e4b9334b314aa | https://github.com/keplergl/kepler.gl/blob/779238435707cc54335c2d00001e4b9334b314aa/src/reducers/vis-state-updaters.js#L1196-L1228 | train | close specific map at index 1 | [
30522,
3853,
14572,
5051,
6895,
8873,
27487,
22068,
7629,
3207,
2595,
1006,
2110,
1010,
2895,
1007,
1063,
1013,
1013,
12850,
9014,
18804,
2951,
2013,
1996,
3588,
4949,
2008,
2057,
2342,
2000,
2562,
9530,
3367,
5950,
19277,
18886,
18697,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/signals.js | Signal | function Signal() {
/**
* @type Array.<SignalBinding>
* @private
*/
this._bindings = [];
this._prevParams = null;
// enforce dispatch to aways work on same context (#47)
var self = this;
this.dispatch = function(){
Signal.prototype.dispatch.apply(self, arguments);
};
} | javascript | function Signal() {
/**
* @type Array.<SignalBinding>
* @private
*/
this._bindings = [];
this._prevParams = null;
// enforce dispatch to aways work on same context (#47)
var self = this;
this.dispatch = function(){
Signal.prototype.dispatch.apply(self, arguments);
};
} | [
"function",
"Signal",
"(",
")",
"{",
"/**\n * @type Array.<SignalBinding>\n * @private\n */",
"this",
".",
"_bindings",
"=",
"[",
"]",
";",
"this",
".",
"_prevParams",
"=",
"null",
";",
"// enforce dispatch to aways work on same context (#47)",
"var",
... | Custom event broadcaster
<br />- inspired by Robert Penner's AS3 Signals.
@name Signal
@author Miller Medeiros
@constructor | [
"Custom",
"event",
"broadcaster",
"<br",
"/",
">",
"-",
"inspired",
"by",
"Robert",
"Penner",
"s",
"AS3",
"Signals",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/signals.js#L176-L189 | train | Signal constructor. | [
30522,
3853,
4742,
1006,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2828,
9140,
1012,
1026,
4742,
8428,
4667,
1028,
1008,
1030,
2797,
1008,
1013,
2023,
1012,
1035,
8031,
2015,
1027,
1031,
1033,
1025,
2023,
1012,
1035,
3653,
2615,
28689,
52... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Inspector/Inspector.js | _verifySignature | function _verifySignature(signature, value) {
if (value === undefined) {
console.assert(signature.optional === true, "Missing argument: " + signature.name);
}
return true;
} | javascript | function _verifySignature(signature, value) {
if (value === undefined) {
console.assert(signature.optional === true, "Missing argument: " + signature.name);
}
return true;
} | [
"function",
"_verifySignature",
"(",
"signature",
",",
"value",
")",
"{",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"console",
".",
"assert",
"(",
"signature",
".",
"optional",
"===",
"true",
",",
"\"Missing argument: \"",
"+",
"signature",
".",
"nam... | user agent string Check a parameter value against the given signature
This only checks for optional parameters, not types
Type checking is complex because of $ref and done on the remote end anyways
@param {signature}
@param {value} | [
"user",
"agent",
"string",
"Check",
"a",
"parameter",
"value",
"against",
"the",
"given",
"signature",
"This",
"only",
"checks",
"for",
"optional",
"parameters",
"not",
"types",
"Type",
"checking",
"is",
"complex",
"because",
"of",
"$ref",
"and",
"done",
"on",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Inspector/Inspector.js#L104-L109 | train | Verify signature | [
30522,
3853,
1035,
20410,
5332,
16989,
11244,
1006,
8085,
1010,
3643,
1007,
1063,
2065,
1006,
3643,
1027,
1027,
1027,
6151,
28344,
1007,
1063,
10122,
1012,
20865,
1006,
8085,
1012,
11887,
1027,
1027,
1027,
2995,
1010,
1000,
4394,
6685,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/InlineColorEditor/ColorEditor.js | _0xColorToHex | function _0xColorToHex(color, convertToStr) {
var hexColor = tinycolor(color.replace("0x", "#"));
hexColor._format = "0x";
if (convertToStr) {
return hexColor.toString();
}
return hexColor;
} | javascript | function _0xColorToHex(color, convertToStr) {
var hexColor = tinycolor(color.replace("0x", "#"));
hexColor._format = "0x";
if (convertToStr) {
return hexColor.toString();
}
return hexColor;
} | [
"function",
"_0xColorToHex",
"(",
"color",
",",
"convertToStr",
")",
"{",
"var",
"hexColor",
"=",
"tinycolor",
"(",
"color",
".",
"replace",
"(",
"\"0x\"",
",",
"\"#\"",
")",
")",
";",
"hexColor",
".",
"_format",
"=",
"\"0x\"",
";",
"if",
"(",
"convertTo... | Converts 0x-prefixed color to hex
@param {string} color - Color to convert
@param {boolean} convertToString - true if color should
be returned as string
@returns {tinycolor|string} - Hex color as a Tinycolor object
or a hex string | [
"Converts",
"0x",
"-",
"prefixed",
"color",
"to",
"hex"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/ColorEditor.js#L71-L79 | train | Convert a 0x color to a hex color | [
30522,
3853,
1035,
1014,
2595,
18717,
3406,
5369,
2595,
1006,
3609,
1010,
10463,
13122,
16344,
1007,
1063,
13075,
2002,
2595,
18717,
1027,
4714,
18717,
1006,
3609,
1012,
5672,
1006,
1000,
1014,
2595,
1000,
1010,
1000,
1001,
1000,
1007,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
firebase/firebase-js-sdk | packages/auth/src/iframeclient/iframewrapper.js | function() {
// The developer may have tried to previously run gapi.load and failed.
// Run this to fix that.
fireauth.util.resetUnloadedGapiModules();
var loader = /** @type {function(string, !Object)} */ (
fireauth.util.getObjectRef('gapi.load'));
loader('gapi.iframes', {
'callback': resolve,
'ontimeout': function() {
// The above reset may be sufficient, but having this reset after
// failure ensures that if the developer calls gapi.load after the
// connection is re-established and before another attempt to embed
// the iframe, it would work and would not be broken because of our
// failed attempt.
// Timeout when gapi.iframes.Iframe not loaded.
fireauth.util.resetUnloadedGapiModules();
reject(new Error('Network Error'));
},
'timeout': fireauth.iframeclient.IframeWrapper.NETWORK_TIMEOUT_.get()
});
} | javascript | function() {
// The developer may have tried to previously run gapi.load and failed.
// Run this to fix that.
fireauth.util.resetUnloadedGapiModules();
var loader = /** @type {function(string, !Object)} */ (
fireauth.util.getObjectRef('gapi.load'));
loader('gapi.iframes', {
'callback': resolve,
'ontimeout': function() {
// The above reset may be sufficient, but having this reset after
// failure ensures that if the developer calls gapi.load after the
// connection is re-established and before another attempt to embed
// the iframe, it would work and would not be broken because of our
// failed attempt.
// Timeout when gapi.iframes.Iframe not loaded.
fireauth.util.resetUnloadedGapiModules();
reject(new Error('Network Error'));
},
'timeout': fireauth.iframeclient.IframeWrapper.NETWORK_TIMEOUT_.get()
});
} | [
"function",
"(",
")",
"{",
"// The developer may have tried to previously run gapi.load and failed.",
"// Run this to fix that.",
"fireauth",
".",
"util",
".",
"resetUnloadedGapiModules",
"(",
")",
";",
"var",
"loader",
"=",
"/** @type {function(string, !Object)} */",
"(",
"fir... | Function to run when gapi.load is ready. | [
"Function",
"to",
"run",
"when",
"gapi",
".",
"load",
"is",
"ready",
"."
] | 491598a499813dacc23724de5e237ec220cc560e | https://github.com/firebase/firebase-js-sdk/blob/491598a499813dacc23724de5e237ec220cc560e/packages/auth/src/iframeclient/iframewrapper.js#L252-L272 | train | The network error is thrown when the network error occurs. | [
30522,
3853,
1006,
1007,
1063,
1013,
1013,
1996,
9722,
2089,
2031,
2699,
2000,
3130,
2448,
6578,
2072,
1012,
7170,
1998,
3478,
1012,
1013,
1013,
2448,
2023,
2000,
8081,
2008,
1012,
2543,
4887,
2705,
1012,
21183,
4014,
1012,
25141,
4609,
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... | |
ipfs/js-ipfs | examples/exchange-files-in-browser/public/app.js | start | function start () {
if (!node) {
const options = {
EXPERIMENTAL: {
pubsub: true
},
repo: 'ipfs-' + Math.random(),
config: {
Addresses: {
Swarm: ['/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star']
}
}
}
node = new IPFS(options)
node.once('start', () => {
node.id()
.then((id) => {
info = id
updateView('ready', node)
onSuccess('Node is ready.')
setInterval(refreshPeerList, 1000)
setInterval(sendFileList, 10000)
})
.catch((error) => onError(error))
subscribeToWorkpsace()
window.addEventListener('hashchange', workspaceUpdated)
})
}
} | javascript | function start () {
if (!node) {
const options = {
EXPERIMENTAL: {
pubsub: true
},
repo: 'ipfs-' + Math.random(),
config: {
Addresses: {
Swarm: ['/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star']
}
}
}
node = new IPFS(options)
node.once('start', () => {
node.id()
.then((id) => {
info = id
updateView('ready', node)
onSuccess('Node is ready.')
setInterval(refreshPeerList, 1000)
setInterval(sendFileList, 10000)
})
.catch((error) => onError(error))
subscribeToWorkpsace()
window.addEventListener('hashchange', workspaceUpdated)
})
}
} | [
"function",
"start",
"(",
")",
"{",
"if",
"(",
"!",
"node",
")",
"{",
"const",
"options",
"=",
"{",
"EXPERIMENTAL",
":",
"{",
"pubsub",
":",
"true",
"}",
",",
"repo",
":",
"'ipfs-'",
"+",
"Math",
".",
"random",
"(",
")",
",",
"config",
":",
"{",
... | /* ===========================================================================
Start the IPFS node
=========================================================================== | [
"/",
"*",
"===========================================================================",
"Start",
"the",
"IPFS",
"node",
"==========================================================================="
] | 97e67601094acda3906549ecb0248fd09f1a8cc3 | https://github.com/ipfs/js-ipfs/blob/97e67601094acda3906549ecb0248fd09f1a8cc3/examples/exchange-files-in-browser/public/app.js#L44-L76 | train | Starts the node | [
30522,
3853,
2707,
1006,
1007,
1063,
2065,
1006,
999,
13045,
1007,
1063,
9530,
3367,
7047,
1027,
1063,
6388,
1024,
1063,
23598,
12083,
1024,
2995,
1065,
1010,
16360,
2080,
1024,
1005,
12997,
10343,
1011,
1005,
1009,
8785,
1012,
6721,
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... |
benweet/stackedit | src/services/networkSvc.js | parseHeaders | function parseHeaders(xhr) {
const pairs = xhr.getAllResponseHeaders().trim().split('\n');
const headers = {};
pairs.forEach((header) => {
const split = header.trim().split(':');
const key = split.shift().trim().toLowerCase();
const value = split.join(':').trim();
headers[key] = value;
});
return headers;
} | javascript | function parseHeaders(xhr) {
const pairs = xhr.getAllResponseHeaders().trim().split('\n');
const headers = {};
pairs.forEach((header) => {
const split = header.trim().split(':');
const key = split.shift().trim().toLowerCase();
const value = split.join(':').trim();
headers[key] = value;
});
return headers;
} | [
"function",
"parseHeaders",
"(",
"xhr",
")",
"{",
"const",
"pairs",
"=",
"xhr",
".",
"getAllResponseHeaders",
"(",
")",
".",
"trim",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
";",
"const",
"headers",
"=",
"{",
"}",
";",
"pairs",
".",
"forEach",
"(",... | 3 minutes (twice the default sync period) | [
"3",
"minutes",
"(",
"twice",
"the",
"default",
"sync",
"period",
")"
] | 91f8cf3c10b75df65b69f9181cee8151d65a788d | https://github.com/benweet/stackedit/blob/91f8cf3c10b75df65b69f9181cee8151d65a788d/src/services/networkSvc.js#L13-L23 | train | Parse the response headers from the server | [
30522,
3853,
11968,
3366,
4974,
2545,
1006,
1060,
8093,
1007,
1063,
9530,
3367,
7689,
1027,
1060,
8093,
1012,
2131,
8095,
6072,
26029,
3366,
4974,
2545,
1006,
1007,
1012,
12241,
1006,
1007,
1012,
3975,
1006,
1005,
1032,
1050,
1005,
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... |
TryGhost/Ghost | core/server/helpers/get.js | resolvePaths | function resolvePaths(globals, data, value) {
var regex = /\{\{(.*?)\}\}/g;
value = value.replace(regex, function (match, path) {
var result;
// Handle aliases
path = pathAliases[path] ? pathAliases[path] : path;
// Handle Handlebars .[] style arrays
path = path.replace(/\.\[/g, '[');
if (path.charAt(0) === '@') {
result = jsonpath.query(globals, path.substr(1));
} else {
// Do the query, which always returns an array of matches
result = jsonpath.query(data, path);
}
// Handle the case where the single data property we return is a Date
// Data.toString() is not DB compatible, so use `toISOString()` instead
if (_.isDate(result[0])) {
result[0] = result[0].toISOString();
}
// Concatenate the results with a comma, handles common case of multiple tag slugs
return result.join(',');
});
return value;
} | javascript | function resolvePaths(globals, data, value) {
var regex = /\{\{(.*?)\}\}/g;
value = value.replace(regex, function (match, path) {
var result;
// Handle aliases
path = pathAliases[path] ? pathAliases[path] : path;
// Handle Handlebars .[] style arrays
path = path.replace(/\.\[/g, '[');
if (path.charAt(0) === '@') {
result = jsonpath.query(globals, path.substr(1));
} else {
// Do the query, which always returns an array of matches
result = jsonpath.query(data, path);
}
// Handle the case where the single data property we return is a Date
// Data.toString() is not DB compatible, so use `toISOString()` instead
if (_.isDate(result[0])) {
result[0] = result[0].toISOString();
}
// Concatenate the results with a comma, handles common case of multiple tag slugs
return result.join(',');
});
return value;
} | [
"function",
"resolvePaths",
"(",
"globals",
",",
"data",
",",
"value",
")",
"{",
"var",
"regex",
"=",
"/",
"\\{\\{(.*?)\\}\\}",
"/",
"g",
";",
"value",
"=",
"value",
".",
"replace",
"(",
"regex",
",",
"function",
"(",
"match",
",",
"path",
")",
"{",
... | ## Resolve Paths
Find and resolve path strings
@param {Object} data
@param {String} value
@returns {String} | [
"##",
"Resolve",
"Paths",
"Find",
"and",
"resolve",
"path",
"strings"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/helpers/get.js#L77-L106 | train | Resolve paths in the value | [
30522,
3853,
10663,
15069,
2015,
1006,
3795,
2015,
1010,
2951,
1010,
3643,
1007,
1063,
13075,
19723,
10288,
1027,
1013,
1032,
1063,
1032,
1063,
1006,
1012,
1008,
1029,
1007,
1032,
1065,
1032,
1065,
1013,
1043,
1025,
3643,
1027,
3643,
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... |
angular/material | src/components/gridList/grid-list.js | GridLayoutFactory | function GridLayoutFactory($mdUtil) {
var defaultAnimator = GridTileAnimator;
/**
* Set the reflow animator callback
*/
GridLayout.animateWith = function(customAnimator) {
defaultAnimator = !angular.isFunction(customAnimator) ? GridTileAnimator : customAnimator;
};
return GridLayout;
/**
* Publish layout function
*/
function GridLayout(colCount, tileSpans) {
var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;
layoutTime = $mdUtil.time(function() {
layoutInfo = calculateGridFor(colCount, tileSpans);
});
return self = {
/**
* An array of objects describing each tile's position in the grid.
*/
layoutInfo: function() {
return layoutInfo;
},
/**
* Maps grid positioning to an element and a set of styles using the
* provided updateFn.
*/
map: function(updateFn) {
mapTime = $mdUtil.time(function() {
var info = self.layoutInfo();
gridStyles = updateFn(info.positioning, info.rowCount);
});
return self;
},
/**
* Default animator simply sets the element.css( <styles> ). An alternate
* animator can be provided as an argument. The function has the following
* signature:
*
* function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
*/
reflow: function(animatorFn) {
reflowTime = $mdUtil.time(function() {
var animator = animatorFn || defaultAnimator;
animator(gridStyles.grid, gridStyles.tiles);
});
return self;
},
/**
* Timing for the most recent layout run.
*/
performance: function() {
return {
tileCount: tileSpans.length,
layoutTime: layoutTime,
mapTime: mapTime,
reflowTime: reflowTime,
totalTime: layoutTime + mapTime + reflowTime
};
}
};
}
/**
* Default Gridlist animator simple sets the css for each element;
* NOTE: any transitions effects must be manually set in the CSS.
* e.g.
*
* md-grid-tile {
* transition: all 700ms ease-out 50ms;
* }
*
*/
function GridTileAnimator(grid, tiles) {
grid.element.css(grid.style);
tiles.forEach(function(t) {
t.element.css(t.style);
});
}
/**
* Calculates the positions of tiles.
*
* The algorithm works as follows:
* An Array<Number> with length colCount (spaceTracker) keeps track of
* available tiling positions, where elements of value 0 represents an
* empty position. Space for a tile is reserved by finding a sequence of
* 0s with length <= than the tile's colspan. When such a space has been
* found, the occupied tile positions are incremented by the tile's
* rowspan value, as these positions have become unavailable for that
* many rows.
*
* If the end of a row has been reached without finding space for the
* tile, spaceTracker's elements are each decremented by 1 to a minimum
* of 0. Rows are searched in this fashion until space is found.
*/
function calculateGridFor(colCount, tileSpans) {
var curCol = 0,
curRow = 0,
spaceTracker = newSpaceTracker();
return {
positioning: tileSpans.map(function(spans, i) {
return {
spans: spans,
position: reserveSpace(spans, i)
};
}),
rowCount: curRow + Math.max.apply(Math, spaceTracker)
};
function reserveSpace(spans, i) {
if (spans.col > colCount) {
throw 'md-grid-list: Tile at position ' + i + ' has a colspan ' +
'(' + spans.col + ') that exceeds the column count ' +
'(' + colCount + ')';
}
var start = 0,
end = 0;
// TODO(shyndman): This loop isn't strictly necessary if you can
// determine the minimum number of rows before a space opens up. To do
// this, recognize that you've iterated across an entire row looking for
// space, and if so fast-forward by the minimum rowSpan count. Repeat
// until the required space opens up.
while (end - start < spans.col) {
if (curCol >= colCount) {
nextRow();
continue;
}
start = spaceTracker.indexOf(0, curCol);
if (start === -1 || (end = findEnd(start + 1)) === -1) {
start = end = 0;
nextRow();
continue;
}
curCol = end + 1;
}
adjustRow(start, spans.col, spans.row);
curCol = start + spans.col;
return {
col: start,
row: curRow
};
}
function nextRow() {
curCol = 0;
curRow++;
adjustRow(0, colCount, -1); // Decrement row spans by one
}
function adjustRow(from, cols, by) {
for (var i = from; i < from + cols; i++) {
spaceTracker[i] = Math.max(spaceTracker[i] + by, 0);
}
}
function findEnd(start) {
var i;
for (i = start; i < spaceTracker.length; i++) {
if (spaceTracker[i] !== 0) {
return i;
}
}
if (i === spaceTracker.length) {
return i;
}
}
function newSpaceTracker() {
var tracker = [];
for (var i = 0; i < colCount; i++) {
tracker.push(0);
}
return tracker;
}
}
} | javascript | function GridLayoutFactory($mdUtil) {
var defaultAnimator = GridTileAnimator;
/**
* Set the reflow animator callback
*/
GridLayout.animateWith = function(customAnimator) {
defaultAnimator = !angular.isFunction(customAnimator) ? GridTileAnimator : customAnimator;
};
return GridLayout;
/**
* Publish layout function
*/
function GridLayout(colCount, tileSpans) {
var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;
layoutTime = $mdUtil.time(function() {
layoutInfo = calculateGridFor(colCount, tileSpans);
});
return self = {
/**
* An array of objects describing each tile's position in the grid.
*/
layoutInfo: function() {
return layoutInfo;
},
/**
* Maps grid positioning to an element and a set of styles using the
* provided updateFn.
*/
map: function(updateFn) {
mapTime = $mdUtil.time(function() {
var info = self.layoutInfo();
gridStyles = updateFn(info.positioning, info.rowCount);
});
return self;
},
/**
* Default animator simply sets the element.css( <styles> ). An alternate
* animator can be provided as an argument. The function has the following
* signature:
*
* function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
*/
reflow: function(animatorFn) {
reflowTime = $mdUtil.time(function() {
var animator = animatorFn || defaultAnimator;
animator(gridStyles.grid, gridStyles.tiles);
});
return self;
},
/**
* Timing for the most recent layout run.
*/
performance: function() {
return {
tileCount: tileSpans.length,
layoutTime: layoutTime,
mapTime: mapTime,
reflowTime: reflowTime,
totalTime: layoutTime + mapTime + reflowTime
};
}
};
}
/**
* Default Gridlist animator simple sets the css for each element;
* NOTE: any transitions effects must be manually set in the CSS.
* e.g.
*
* md-grid-tile {
* transition: all 700ms ease-out 50ms;
* }
*
*/
function GridTileAnimator(grid, tiles) {
grid.element.css(grid.style);
tiles.forEach(function(t) {
t.element.css(t.style);
});
}
/**
* Calculates the positions of tiles.
*
* The algorithm works as follows:
* An Array<Number> with length colCount (spaceTracker) keeps track of
* available tiling positions, where elements of value 0 represents an
* empty position. Space for a tile is reserved by finding a sequence of
* 0s with length <= than the tile's colspan. When such a space has been
* found, the occupied tile positions are incremented by the tile's
* rowspan value, as these positions have become unavailable for that
* many rows.
*
* If the end of a row has been reached without finding space for the
* tile, spaceTracker's elements are each decremented by 1 to a minimum
* of 0. Rows are searched in this fashion until space is found.
*/
function calculateGridFor(colCount, tileSpans) {
var curCol = 0,
curRow = 0,
spaceTracker = newSpaceTracker();
return {
positioning: tileSpans.map(function(spans, i) {
return {
spans: spans,
position: reserveSpace(spans, i)
};
}),
rowCount: curRow + Math.max.apply(Math, spaceTracker)
};
function reserveSpace(spans, i) {
if (spans.col > colCount) {
throw 'md-grid-list: Tile at position ' + i + ' has a colspan ' +
'(' + spans.col + ') that exceeds the column count ' +
'(' + colCount + ')';
}
var start = 0,
end = 0;
// TODO(shyndman): This loop isn't strictly necessary if you can
// determine the minimum number of rows before a space opens up. To do
// this, recognize that you've iterated across an entire row looking for
// space, and if so fast-forward by the minimum rowSpan count. Repeat
// until the required space opens up.
while (end - start < spans.col) {
if (curCol >= colCount) {
nextRow();
continue;
}
start = spaceTracker.indexOf(0, curCol);
if (start === -1 || (end = findEnd(start + 1)) === -1) {
start = end = 0;
nextRow();
continue;
}
curCol = end + 1;
}
adjustRow(start, spans.col, spans.row);
curCol = start + spans.col;
return {
col: start,
row: curRow
};
}
function nextRow() {
curCol = 0;
curRow++;
adjustRow(0, colCount, -1); // Decrement row spans by one
}
function adjustRow(from, cols, by) {
for (var i = from; i < from + cols; i++) {
spaceTracker[i] = Math.max(spaceTracker[i] + by, 0);
}
}
function findEnd(start) {
var i;
for (i = start; i < spaceTracker.length; i++) {
if (spaceTracker[i] !== 0) {
return i;
}
}
if (i === spaceTracker.length) {
return i;
}
}
function newSpaceTracker() {
var tracker = [];
for (var i = 0; i < colCount; i++) {
tracker.push(0);
}
return tracker;
}
}
} | [
"function",
"GridLayoutFactory",
"(",
"$mdUtil",
")",
"{",
"var",
"defaultAnimator",
"=",
"GridTileAnimator",
";",
"/**\n * Set the reflow animator callback\n */",
"GridLayout",
".",
"animateWith",
"=",
"function",
"(",
"customAnimator",
")",
"{",
"defaultAnimator",
"... | /* @ngInject | [
"/",
"*"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L466-L660 | train | Creates a new GridLayout instance. | [
30522,
3853,
8370,
8485,
5833,
21450,
1006,
1002,
9108,
21823,
2140,
1007,
1063,
13075,
12398,
7088,
18900,
2953,
1027,
8370,
15286,
7088,
18900,
2953,
1025,
1013,
1008,
1008,
1008,
2275,
1996,
25416,
8261,
25132,
2655,
5963,
1008,
1013,
83... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/dom/jquery/Aria.js | removeFromAttributeList | function removeFromAttributeList(sAttribute, sValue) {
var sAttributes = this.attr(sAttribute) || "",
aAttributes = sAttributes.split(" "),
iIndex = aAttributes.indexOf(sValue);
if (iIndex == -1) {
return this;
}
aAttributes.splice(iIndex, 1);
if (aAttributes.length) {
this.attr(sAttribute, aAttributes.join(" "));
} else {
this.removeAttr(sAttribute);
}
return this;
} | javascript | function removeFromAttributeList(sAttribute, sValue) {
var sAttributes = this.attr(sAttribute) || "",
aAttributes = sAttributes.split(" "),
iIndex = aAttributes.indexOf(sValue);
if (iIndex == -1) {
return this;
}
aAttributes.splice(iIndex, 1);
if (aAttributes.length) {
this.attr(sAttribute, aAttributes.join(" "));
} else {
this.removeAttr(sAttribute);
}
return this;
} | [
"function",
"removeFromAttributeList",
"(",
"sAttribute",
",",
"sValue",
")",
"{",
"var",
"sAttributes",
"=",
"this",
".",
"attr",
"(",
"sAttribute",
")",
"||",
"\"\"",
",",
"aAttributes",
"=",
"sAttributes",
".",
"split",
"(",
"\" \"",
")",
",",
"iIndex",
... | Remove space separated value from the given attribute.
@this {jQuery} jQuery context
@param {string} sAttribute The name of the attribute.
@param {string} sValue The value of the attribute to be inserted.
@return {jQuery} <code>this</code> to allow method chaining.
@author SAP SE
@function
@private | [
"Remove",
"space",
"separated",
"value",
"from",
"the",
"given",
"attribute",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/dom/jquery/Aria.js#L62-L79 | train | Removes an attribute from the list of attributes | [
30522,
3853,
6366,
19699,
9626,
4779,
3089,
8569,
9834,
2923,
1006,
2938,
18886,
8569,
2618,
1010,
17917,
2389,
5657,
1007,
1063,
13075,
2938,
18886,
8569,
4570,
1027,
2023,
1012,
2012,
16344,
1006,
2938,
18886,
8569,
2618,
1007,
1064,
1064... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js | function (oContext) {
var iEndOfPath, // after $*Path
iIndexOfAt, // first "@" before $*Path
iIndexOfPath, // begin of $*Path
iLastIndexOfSlash, // last "/" before iIndexOfAt
aMatches,
sPath = oContext.getPath(),
sPrefix,
vValue;
for (;;) {
aMatches = sPath.match(rPaths);
if (!aMatches) {
return sPath;
}
iIndexOfPath = aMatches.index;
iEndOfPath = iIndexOfPath + aMatches[0].length;
sPrefix = sPath.slice(0, iEndOfPath);
vValue = oContext.getModel().getObject(sPrefix);
if (typeof vValue !== "string") {
throw new Error("Cannot resolve " + sPrefix
+ " due to unexpected value " + vValue);
}
sPrefix = sPath.slice(0, iIndexOfPath);
iIndexOfAt = sPrefix.indexOf("@");
iLastIndexOfSlash = sPrefix.lastIndexOf("/", iIndexOfAt);
if (iLastIndexOfSlash === 0) { // do not cut off entity set
sPrefix = sPrefix.slice(0, iIndexOfAt);
if (iIndexOfAt > 1 && vValue) {
sPrefix += "/";
}
} else { // cut off property, but end with slash
sPrefix = sPrefix.slice(0, iLastIndexOfSlash + 1);
}
sPath = sPrefix + vValue + sPath.slice(iEndOfPath);
}
} | javascript | function (oContext) {
var iEndOfPath, // after $*Path
iIndexOfAt, // first "@" before $*Path
iIndexOfPath, // begin of $*Path
iLastIndexOfSlash, // last "/" before iIndexOfAt
aMatches,
sPath = oContext.getPath(),
sPrefix,
vValue;
for (;;) {
aMatches = sPath.match(rPaths);
if (!aMatches) {
return sPath;
}
iIndexOfPath = aMatches.index;
iEndOfPath = iIndexOfPath + aMatches[0].length;
sPrefix = sPath.slice(0, iEndOfPath);
vValue = oContext.getModel().getObject(sPrefix);
if (typeof vValue !== "string") {
throw new Error("Cannot resolve " + sPrefix
+ " due to unexpected value " + vValue);
}
sPrefix = sPath.slice(0, iIndexOfPath);
iIndexOfAt = sPrefix.indexOf("@");
iLastIndexOfSlash = sPrefix.lastIndexOf("/", iIndexOfAt);
if (iLastIndexOfSlash === 0) { // do not cut off entity set
sPrefix = sPrefix.slice(0, iIndexOfAt);
if (iIndexOfAt > 1 && vValue) {
sPrefix += "/";
}
} else { // cut off property, but end with slash
sPrefix = sPrefix.slice(0, iLastIndexOfSlash + 1);
}
sPath = sPrefix + vValue + sPath.slice(iEndOfPath);
}
} | [
"function",
"(",
"oContext",
")",
"{",
"var",
"iEndOfPath",
",",
"// after $*Path",
"iIndexOfAt",
",",
"// first \"@\" before $*Path",
"iIndexOfPath",
",",
"// begin of $*Path",
"iLastIndexOfSlash",
",",
"// last \"/\" before iIndexOfAt",
"aMatches",
",",
"sPath",
"=",
"o... | Helper function for a <code>template:with</code> instruction that returns an
equivalent to the given context's path, without "$AnnotationPath",
"$NavigationPropertyPath", "$Path", and "$PropertyPath" segments.
@param {sap.ui.model.Context} oContext
A context which belongs to an {@link sap.ui.model.odata.v4.ODataMetaModel}
@returns {string}
An equivalent to the given context's path, without the mentioned segments
@throws {Error}
If one of the mentioned segments has a non-string value and thus the path cannot
be resolved
@public
@see sap.ui.model.odata.v4.AnnotationHelper.format
@since 1.63.0 | [
"Helper",
"function",
"for",
"a",
"<code",
">",
"template",
":",
"with<",
"/",
"code",
">",
"instruction",
"that",
"returns",
"an",
"equivalent",
"to",
"the",
"given",
"context",
"s",
"path",
"without",
"$AnnotationPath",
"$NavigationPropertyPath",
"$Path",
"and... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/AnnotationHelper.js#L486-L525 | train | Returns the path of the given context. | [
30522,
3853,
1006,
1051,
8663,
18209,
1007,
1063,
13075,
29464,
15482,
22540,
8988,
1010,
1013,
1013,
2044,
1002,
1008,
4130,
2462,
13629,
2595,
11253,
4017,
1010,
1013,
1013,
2034,
1000,
1030,
1000,
2077,
1002,
1008,
4130,
2462,
13629,
259... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | namecmp | function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
for(var i = 0, c = 0, Z = Math.min(L.length, R.length); i < Z; ++i) {
if((c = L[i].length - R[i].length)) return c;
if(L[i] != R[i]) return L[i] < R[i] ? -1 : 1;
}
return L.length - R.length;
} | javascript | function namecmp(l, r) {
var L = l.split("/"), R = r.split("/");
for(var i = 0, c = 0, Z = Math.min(L.length, R.length); i < Z; ++i) {
if((c = L[i].length - R[i].length)) return c;
if(L[i] != R[i]) return L[i] < R[i] ? -1 : 1;
}
return L.length - R.length;
} | [
"function",
"namecmp",
"(",
"l",
",",
"r",
")",
"{",
"var",
"L",
"=",
"l",
".",
"split",
"(",
"\"/\"",
")",
",",
"R",
"=",
"r",
".",
"split",
"(",
"\"/\"",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"c",
"=",
"0",
",",
"Z",
"=",
"... | /* [MS-CFB] 2.6.4 | [
"/",
"*",
"[",
"MS",
"-",
"CFB",
"]",
"2",
".",
"6",
".",
"4"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L1251-L1258 | train | Compare two names | [
30522,
3853,
2171,
27487,
2361,
1006,
1048,
1010,
1054,
1007,
1063,
13075,
1048,
1027,
1048,
1012,
3975,
1006,
1000,
1013,
1000,
1007,
1010,
1054,
1027,
1054,
1012,
3975,
1006,
1000,
1013,
1000,
1007,
1025,
2005,
1006,
13075,
1045,
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/LiveDevelopment/Agents/CSSAgent.js | styleForURL | function styleForURL(url) {
var styleSheetId, styles = {};
url = _canonicalize(url);
for (styleSheetId in _styleSheetDetails) {
if (_styleSheetDetails[styleSheetId].canonicalizedURL === url) {
styles[styleSheetId] = _styleSheetDetails[styleSheetId];
}
}
return styles;
} | javascript | function styleForURL(url) {
var styleSheetId, styles = {};
url = _canonicalize(url);
for (styleSheetId in _styleSheetDetails) {
if (_styleSheetDetails[styleSheetId].canonicalizedURL === url) {
styles[styleSheetId] = _styleSheetDetails[styleSheetId];
}
}
return styles;
} | [
"function",
"styleForURL",
"(",
"url",
")",
"{",
"var",
"styleSheetId",
",",
"styles",
"=",
"{",
"}",
";",
"url",
"=",
"_canonicalize",
"(",
"url",
")",
";",
"for",
"(",
"styleSheetId",
"in",
"_styleSheetDetails",
")",
"{",
"if",
"(",
"_styleSheetDetails",... | Get the style sheets for a url
@param {string} url
@return {Object.<string, CSSStyleSheetHeader>} | [
"Get",
"the",
"style",
"sheets",
"for",
"a",
"url"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/CSSAgent.js#L81-L90 | train | Get styleSheet for a given URL | [
30522,
3853,
2806,
29278,
3126,
2140,
1006,
24471,
2140,
1007,
1063,
13075,
6782,
21030,
3775,
2094,
1010,
6782,
1027,
1063,
1065,
1025,
24471,
2140,
1027,
1035,
18562,
4697,
1006,
24471,
2140,
1007,
1025,
2005,
1006,
6782,
21030,
3775,
209... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/rules/CoreHelper.support.js | function (styleSheet) {
var styleSheetSourceName;
if (styleSheet.href) {
// This will get only the name of the styleSheet example: "/customstyle.css"
styleSheetSourceName = styleSheet.href.substr(styleSheet.href.lastIndexOf("/"), styleSheet.href.length - 1);
} else {
styleSheetSourceName = " <style> tag ";
}
return styleSheetSourceName;
} | javascript | function (styleSheet) {
var styleSheetSourceName;
if (styleSheet.href) {
// This will get only the name of the styleSheet example: "/customstyle.css"
styleSheetSourceName = styleSheet.href.substr(styleSheet.href.lastIndexOf("/"), styleSheet.href.length - 1);
} else {
styleSheetSourceName = " <style> tag ";
}
return styleSheetSourceName;
} | [
"function",
"(",
"styleSheet",
")",
"{",
"var",
"styleSheetSourceName",
";",
"if",
"(",
"styleSheet",
".",
"href",
")",
"{",
"// This will get only the name of the styleSheet example: \"/customstyle.css\"",
"styleSheetSourceName",
"=",
"styleSheet",
".",
"href",
".",
"sub... | *
Gets the only the style sheet name from source.
@param styleSheet
@returns {string} Name of the file source or "<style> tag" if style sheet is inline. | [
"*",
"Gets",
"the",
"only",
"the",
"style",
"sheet",
"name",
"from",
"source",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/rules/CoreHelper.support.js#L66-L77 | train | Get the name of the style sheet | [
30522,
3853,
1006,
6782,
21030,
2102,
1007,
1063,
13075,
6782,
21030,
3215,
8162,
27524,
14074,
1025,
2065,
1006,
6782,
21030,
2102,
1012,
17850,
12879,
1007,
1063,
1013,
1013,
2023,
2097,
2131,
2069,
1996,
2171,
1997,
1996,
6782,
21030,
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... | |
adobe/brackets | src/JSUtils/node/TernNodeDomain.js | getTernHints | function getTernHints(fileInfo, offset, isProperty) {
var request = buildRequest(fileInfo, "completions", offset),
i;
//_log("request " + dir + " " + file + " " + offset /*+ " " + text */);
try {
ternServer.request(request, function (error, data) {
var completions = [];
if (error) {
_log("Error returned from Tern 'completions' request: " + error);
} else {
//_log("found " + data.completions + " for " + file + "@" + offset);
completions = data.completions.map(function (completion) {
return {value: completion.name, type: completion.type, depth: completion.depth,
guess: completion.guess, origin: completion.origin, doc: completion.doc, url: completion.url};
});
}
if (completions.length > 0 || !isProperty) {
// Post a message back to the main thread with the completions
self.postMessage({type: MessageIds.TERN_COMPLETIONS_MSG,
file: _getNormalizedFilename(fileInfo.name),
offset: offset,
completions: completions
});
} else {
// if there are no completions, then get all the properties
getTernProperties(fileInfo, offset, MessageIds.TERN_COMPLETIONS_MSG);
}
});
} catch (e) {
_reportError(e, fileInfo.name);
}
} | javascript | function getTernHints(fileInfo, offset, isProperty) {
var request = buildRequest(fileInfo, "completions", offset),
i;
//_log("request " + dir + " " + file + " " + offset /*+ " " + text */);
try {
ternServer.request(request, function (error, data) {
var completions = [];
if (error) {
_log("Error returned from Tern 'completions' request: " + error);
} else {
//_log("found " + data.completions + " for " + file + "@" + offset);
completions = data.completions.map(function (completion) {
return {value: completion.name, type: completion.type, depth: completion.depth,
guess: completion.guess, origin: completion.origin, doc: completion.doc, url: completion.url};
});
}
if (completions.length > 0 || !isProperty) {
// Post a message back to the main thread with the completions
self.postMessage({type: MessageIds.TERN_COMPLETIONS_MSG,
file: _getNormalizedFilename(fileInfo.name),
offset: offset,
completions: completions
});
} else {
// if there are no completions, then get all the properties
getTernProperties(fileInfo, offset, MessageIds.TERN_COMPLETIONS_MSG);
}
});
} catch (e) {
_reportError(e, fileInfo.name);
}
} | [
"function",
"getTernHints",
"(",
"fileInfo",
",",
"offset",
",",
"isProperty",
")",
"{",
"var",
"request",
"=",
"buildRequest",
"(",
"fileInfo",
",",
"\"completions\"",
",",
"offset",
")",
",",
"i",
";",
"//_log(\"request \" + dir + \" \" + file + \" \" + offset /*+ \... | Get the completions for the given offset
@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- type of update, name of file, and the text of the update.
For "full" updates, the whole text of the file is present. For "part" updates,
the changed portion of the text. For "empty" updates, the file has not been modified
and the text is empty.
@param {{line: number, ch: number}} offset -
the offset into the file where we want completions for
@param {boolean} isProperty - true if getting a property hint,
otherwise getting an identifier hint. | [
"Get",
"the",
"completions",
"for",
"the",
"given",
"offset"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/node/TernNodeDomain.js#L457-L489 | train | Get the completions for a given file and offset | [
30522,
3853,
2131,
16451,
10606,
3215,
1006,
5371,
2378,
14876,
1010,
16396,
1010,
2003,
21572,
4842,
3723,
1007,
1063,
13075,
5227,
1027,
3857,
2890,
15500,
1006,
5371,
2378,
14876,
1010,
1000,
6503,
2015,
1000,
1010,
16396,
1007,
1010,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/preferences/PreferencesManager.js | _updateCurrentProjectContext | function _updateCurrentProjectContext() {
var defaultScopeOrder = PreferencesImpl.manager._getScopeOrder({});
scopeOrderWithProject = _adjustScopeOrderForProject(defaultScopeOrder, true);
scopeOrderWithoutProject = _adjustScopeOrderForProject(defaultScopeOrder, false);
CURRENT_PROJECT.scopeOrder = scopeOrderWithProject;
} | javascript | function _updateCurrentProjectContext() {
var defaultScopeOrder = PreferencesImpl.manager._getScopeOrder({});
scopeOrderWithProject = _adjustScopeOrderForProject(defaultScopeOrder, true);
scopeOrderWithoutProject = _adjustScopeOrderForProject(defaultScopeOrder, false);
CURRENT_PROJECT.scopeOrder = scopeOrderWithProject;
} | [
"function",
"_updateCurrentProjectContext",
"(",
")",
"{",
"var",
"defaultScopeOrder",
"=",
"PreferencesImpl",
".",
"manager",
".",
"_getScopeOrder",
"(",
"{",
"}",
")",
";",
"scopeOrderWithProject",
"=",
"_adjustScopeOrderForProject",
"(",
"defaultScopeOrder",
",",
"... | @private
Updates the CURRENT_PROJECT context to have the correct scopes. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesManager.js#L256-L261 | train | Updates the current project context | [
30522,
3853,
1035,
10651,
10841,
14343,
3372,
21572,
20614,
8663,
18209,
1006,
1007,
1063,
13075,
12398,
26127,
8551,
2121,
1027,
18394,
5714,
24759,
1012,
3208,
1012,
1035,
4152,
16186,
8551,
2121,
1006,
1063,
1065,
1007,
1025,
9531,
8551,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (msg) {
var msgHandlers;
if (!msg.method) {
// no message type, ignoring it
// TODO: should we trigger a generic event?
console.log("[Brackets LiveDev] Received message without method.");
return;
}
// get handlers for msg.method
msgHandlers = this.handlers[msg.method];
if (msgHandlers && msgHandlers.length > 0) {
// invoke handlers with the received message
msgHandlers.forEach(function (handler) {
try {
// TODO: check which context should be used to call handlers here.
handler(msg);
return;
} catch (e) {
console.log("[Brackets LiveDev] Error executing a handler for " + msg.method);
console.log(e.stack);
return;
}
});
} else {
// no subscribers, ignore it.
// TODO: any other default handling? (eg. specific respond, trigger as a generic event, etc.);
console.log("[Brackets LiveDev] No subscribers for message " + msg.method);
return;
}
} | javascript | function (msg) {
var msgHandlers;
if (!msg.method) {
// no message type, ignoring it
// TODO: should we trigger a generic event?
console.log("[Brackets LiveDev] Received message without method.");
return;
}
// get handlers for msg.method
msgHandlers = this.handlers[msg.method];
if (msgHandlers && msgHandlers.length > 0) {
// invoke handlers with the received message
msgHandlers.forEach(function (handler) {
try {
// TODO: check which context should be used to call handlers here.
handler(msg);
return;
} catch (e) {
console.log("[Brackets LiveDev] Error executing a handler for " + msg.method);
console.log(e.stack);
return;
}
});
} else {
// no subscribers, ignore it.
// TODO: any other default handling? (eg. specific respond, trigger as a generic event, etc.);
console.log("[Brackets LiveDev] No subscribers for message " + msg.method);
return;
}
} | [
"function",
"(",
"msg",
")",
"{",
"var",
"msgHandlers",
";",
"if",
"(",
"!",
"msg",
".",
"method",
")",
"{",
"// no message type, ignoring it",
"// TODO: should we trigger a generic event?",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Received message without method... | Dispatch messages to handlers according to msg.method value.
@param {Object} msg Message to be dispatched. | [
"Dispatch",
"messages",
"to",
"handlers",
"according",
"to",
"msg",
".",
"method",
"value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L60-L90 | train | handle a message | [
30522,
3853,
1006,
5796,
2290,
1007,
1063,
13075,
5796,
22218,
21222,
2015,
1025,
2065,
1006,
999,
5796,
2290,
1012,
4118,
1007,
1063,
1013,
1013,
2053,
4471,
2828,
1010,
9217,
2009,
1013,
1013,
28681,
2080,
1024,
2323,
2057,
9495,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/InAppNotifications/main.js | _getVersionInfoUrl | function _getVersionInfoUrl(localeParam) {
var locale = localeParam || brackets.getLocale();
if (locale.length > 2) {
locale = locale.substring(0, 2);
}
return brackets.config.notification_info_url.replace("<locale>", locale);
} | javascript | function _getVersionInfoUrl(localeParam) {
var locale = localeParam || brackets.getLocale();
if (locale.length > 2) {
locale = locale.substring(0, 2);
}
return brackets.config.notification_info_url.replace("<locale>", locale);
} | [
"function",
"_getVersionInfoUrl",
"(",
"localeParam",
")",
"{",
"var",
"locale",
"=",
"localeParam",
"||",
"brackets",
".",
"getLocale",
"(",
")",
";",
"if",
"(",
"locale",
".",
"length",
">",
"2",
")",
"{",
"locale",
"=",
"locale",
".",
"substring",
"("... | Constructs notification info URL for XHR
@param {string=} localeParam - optional locale, defaults to 'brackets.getLocale()' when omitted.
@returns {string} the new notification info url | [
"Constructs",
"notification",
"info",
"URL",
"for",
"XHR"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InAppNotifications/main.js#L55-L64 | train | Get the URL to the version information page | [
30522,
3853,
1035,
2131,
27774,
2378,
14876,
3126,
2140,
1006,
2334,
13699,
5400,
2213,
1007,
1063,
13075,
2334,
2063,
1027,
2334,
13699,
5400,
2213,
1064,
1064,
19719,
1012,
2131,
4135,
9289,
2063,
1006,
1007,
1025,
2065,
1006,
2334,
2063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/entity/prompts.js | logFieldsAndRelationships | function logFieldsAndRelationships() {
const context = this.context;
if (context.fields.length > 0 || context.relationships.length > 0) {
this.log(chalk.red(chalk.white('\n================= ') + context.entityNameCapitalized + chalk.white(' =================')));
}
if (context.fields.length > 0) {
this.log(chalk.white('Fields'));
context.fields.forEach(field => {
const validationDetails = [];
const fieldValidate = _.isArray(field.fieldValidateRules) && field.fieldValidateRules.length >= 1;
if (fieldValidate === true) {
if (field.fieldValidateRules.includes('required')) {
validationDetails.push('required');
}
if (field.fieldValidateRules.includes('unique')) {
validationDetails.push('unique');
}
if (field.fieldValidateRules.includes('minlength')) {
validationDetails.push(`minlength='${field.fieldValidateRulesMinlength}'`);
}
if (field.fieldValidateRules.includes('maxlength')) {
validationDetails.push(`maxlength='${field.fieldValidateRulesMaxlength}'`);
}
if (field.fieldValidateRules.includes('pattern')) {
validationDetails.push(`pattern='${field.fieldValidateRulesPattern}'`);
}
if (field.fieldValidateRules.includes('min')) {
validationDetails.push(`min='${field.fieldValidateRulesMin}'`);
}
if (field.fieldValidateRules.includes('max')) {
validationDetails.push(`max='${field.fieldValidateRulesMax}'`);
}
if (field.fieldValidateRules.includes('minbytes')) {
validationDetails.push(`minbytes='${field.fieldValidateRulesMinbytes}'`);
}
if (field.fieldValidateRules.includes('maxbytes')) {
validationDetails.push(`maxbytes='${field.fieldValidateRulesMaxbytes}'`);
}
}
this.log(
chalk.red(field.fieldName) +
chalk.white(` (${field.fieldType}${field.fieldTypeBlobContent ? ` ${field.fieldTypeBlobContent}` : ''}) `) +
chalk.cyan(validationDetails.join(' '))
);
});
this.log();
}
if (context.relationships.length > 0) {
this.log(chalk.white('Relationships'));
context.relationships.forEach(relationship => {
const validationDetails = [];
if (relationship.relationshipValidateRules && relationship.relationshipValidateRules.includes('required')) {
validationDetails.push('required');
}
this.log(
`${chalk.red(relationship.relationshipName)} ${chalk.white(`(${_.upperFirst(relationship.otherEntityName)})`)} ${chalk.cyan(
relationship.relationshipType
)} ${chalk.cyan(validationDetails.join(' '))}`
);
});
this.log();
}
} | javascript | function logFieldsAndRelationships() {
const context = this.context;
if (context.fields.length > 0 || context.relationships.length > 0) {
this.log(chalk.red(chalk.white('\n================= ') + context.entityNameCapitalized + chalk.white(' =================')));
}
if (context.fields.length > 0) {
this.log(chalk.white('Fields'));
context.fields.forEach(field => {
const validationDetails = [];
const fieldValidate = _.isArray(field.fieldValidateRules) && field.fieldValidateRules.length >= 1;
if (fieldValidate === true) {
if (field.fieldValidateRules.includes('required')) {
validationDetails.push('required');
}
if (field.fieldValidateRules.includes('unique')) {
validationDetails.push('unique');
}
if (field.fieldValidateRules.includes('minlength')) {
validationDetails.push(`minlength='${field.fieldValidateRulesMinlength}'`);
}
if (field.fieldValidateRules.includes('maxlength')) {
validationDetails.push(`maxlength='${field.fieldValidateRulesMaxlength}'`);
}
if (field.fieldValidateRules.includes('pattern')) {
validationDetails.push(`pattern='${field.fieldValidateRulesPattern}'`);
}
if (field.fieldValidateRules.includes('min')) {
validationDetails.push(`min='${field.fieldValidateRulesMin}'`);
}
if (field.fieldValidateRules.includes('max')) {
validationDetails.push(`max='${field.fieldValidateRulesMax}'`);
}
if (field.fieldValidateRules.includes('minbytes')) {
validationDetails.push(`minbytes='${field.fieldValidateRulesMinbytes}'`);
}
if (field.fieldValidateRules.includes('maxbytes')) {
validationDetails.push(`maxbytes='${field.fieldValidateRulesMaxbytes}'`);
}
}
this.log(
chalk.red(field.fieldName) +
chalk.white(` (${field.fieldType}${field.fieldTypeBlobContent ? ` ${field.fieldTypeBlobContent}` : ''}) `) +
chalk.cyan(validationDetails.join(' '))
);
});
this.log();
}
if (context.relationships.length > 0) {
this.log(chalk.white('Relationships'));
context.relationships.forEach(relationship => {
const validationDetails = [];
if (relationship.relationshipValidateRules && relationship.relationshipValidateRules.includes('required')) {
validationDetails.push('required');
}
this.log(
`${chalk.red(relationship.relationshipName)} ${chalk.white(`(${_.upperFirst(relationship.otherEntityName)})`)} ${chalk.cyan(
relationship.relationshipType
)} ${chalk.cyan(validationDetails.join(' '))}`
);
});
this.log();
}
} | [
"function",
"logFieldsAndRelationships",
"(",
")",
"{",
"const",
"context",
"=",
"this",
".",
"context",
";",
"if",
"(",
"context",
".",
"fields",
".",
"length",
">",
"0",
"||",
"context",
".",
"relationships",
".",
"length",
">",
"0",
")",
"{",
"this",
... | Show the entity and it's fields and relationships in console | [
"Show",
"the",
"entity",
"and",
"it",
"s",
"fields",
"and",
"relationships",
"in",
"console"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/entity/prompts.js#L1075-L1137 | train | Logs fields and relationships | [
30522,
3853,
8833,
15155,
5685,
16570,
10708,
19801,
1006,
1007,
1063,
9530,
3367,
6123,
1027,
2023,
1012,
6123,
1025,
2065,
1006,
6123,
1012,
4249,
1012,
3091,
1028,
1014,
1064,
1064,
6123,
1012,
6550,
1012,
3091,
1028,
1014,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/service.js | defineService | function defineService(serviceIdentifier, versions, features) {
AWS.Service._serviceMap[serviceIdentifier] = true;
if (!Array.isArray(versions)) {
features = versions;
versions = [];
}
var svc = inherit(AWS.Service, features || {});
if (typeof serviceIdentifier === 'string') {
AWS.Service.addVersions(svc, versions);
var identifier = svc.serviceIdentifier || serviceIdentifier;
svc.serviceIdentifier = identifier;
} else { // defineService called with an API
svc.prototype.api = serviceIdentifier;
AWS.Service.defineMethods(svc);
}
AWS.SequentialExecutor.call(this.prototype);
//util.clientSideMonitoring is only available in node
if (!this.prototype.publisher && AWS.util.clientSideMonitoring) {
var Publisher = AWS.util.clientSideMonitoring.Publisher;
var configProvider = AWS.util.clientSideMonitoring.configProvider;
var publisherConfig = configProvider();
this.prototype.publisher = new Publisher(publisherConfig);
if (publisherConfig.enabled) {
//if csm is enabled in environment, SDK should send all metrics
AWS.Service._clientSideMonitoring = true;
}
}
AWS.SequentialExecutor.call(svc.prototype);
AWS.Service.addDefaultMonitoringListeners(svc.prototype);
return svc;
} | javascript | function defineService(serviceIdentifier, versions, features) {
AWS.Service._serviceMap[serviceIdentifier] = true;
if (!Array.isArray(versions)) {
features = versions;
versions = [];
}
var svc = inherit(AWS.Service, features || {});
if (typeof serviceIdentifier === 'string') {
AWS.Service.addVersions(svc, versions);
var identifier = svc.serviceIdentifier || serviceIdentifier;
svc.serviceIdentifier = identifier;
} else { // defineService called with an API
svc.prototype.api = serviceIdentifier;
AWS.Service.defineMethods(svc);
}
AWS.SequentialExecutor.call(this.prototype);
//util.clientSideMonitoring is only available in node
if (!this.prototype.publisher && AWS.util.clientSideMonitoring) {
var Publisher = AWS.util.clientSideMonitoring.Publisher;
var configProvider = AWS.util.clientSideMonitoring.configProvider;
var publisherConfig = configProvider();
this.prototype.publisher = new Publisher(publisherConfig);
if (publisherConfig.enabled) {
//if csm is enabled in environment, SDK should send all metrics
AWS.Service._clientSideMonitoring = true;
}
}
AWS.SequentialExecutor.call(svc.prototype);
AWS.Service.addDefaultMonitoringListeners(svc.prototype);
return svc;
} | [
"function",
"defineService",
"(",
"serviceIdentifier",
",",
"versions",
",",
"features",
")",
"{",
"AWS",
".",
"Service",
".",
"_serviceMap",
"[",
"serviceIdentifier",
"]",
"=",
"true",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"versions",
")",
")... | Defines a new Service class using a service identifier and list of versions
including an optional set of features (functions) to apply to the class
prototype.
@param serviceIdentifier [String] the identifier for the service
@param versions [Array<String>] a list of versions that work with this
service
@param features [Object] an object to attach to the prototype
@return [Class<Service>] the service class defined by this function. | [
"Defines",
"a",
"new",
"Service",
"class",
"using",
"a",
"service",
"identifier",
"and",
"list",
"of",
"versions",
"including",
"an",
"optional",
"set",
"of",
"features",
"(",
"functions",
")",
"to",
"apply",
"to",
"the",
"class",
"prototype",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L690-L723 | train | defineService - define a service | [
30522,
3853,
11859,
2121,
7903,
2063,
1006,
2326,
5178,
16778,
8873,
2121,
1010,
4617,
1010,
2838,
1007,
1063,
22091,
2015,
1012,
2326,
1012,
1035,
2326,
2863,
2361,
1031,
2326,
5178,
16778,
8873,
2121,
1033,
1027,
2995,
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... |
adobe/brackets | src/JSUtils/ScopeManager.js | _setConfig | function _setConfig(configUpdate) {
config = brackets._configureJSCodeHints.config;
postMessage({
type: MessageIds.SET_CONFIG,
config: configUpdate
});
} | javascript | function _setConfig(configUpdate) {
config = brackets._configureJSCodeHints.config;
postMessage({
type: MessageIds.SET_CONFIG,
config: configUpdate
});
} | [
"function",
"_setConfig",
"(",
"configUpdate",
")",
"{",
"config",
"=",
"brackets",
".",
"_configureJSCodeHints",
".",
"config",
";",
"postMessage",
"(",
"{",
"type",
":",
"MessageIds",
".",
"SET_CONFIG",
",",
"config",
":",
"configUpdate",
"}",
")",
";",
"}... | @private
Update the configuration in the tern node domain. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L1582-L1588 | train | Sets the config of the node | [
30522,
3853,
1035,
2275,
8663,
8873,
2290,
1006,
9530,
8873,
12193,
17299,
3686,
1007,
1063,
9530,
8873,
2290,
1027,
19719,
1012,
1035,
9530,
8873,
27390,
20518,
9363,
25383,
18447,
2015,
1012,
9530,
8873,
2290,
1025,
2695,
7834,
3736,
3351... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/hello-mui/js/mui.js | function() {
var self = this;
var val = self.input.value;
if (val == null || val == '' || isNaN(val)) {
self.input.value = self.options.min || 0;
self.minus.disabled = self.options.min != null;
} else {
var val = parseInt(val);
if (self.options.max != null && !isNaN(self.options.max) && val >= parseInt(self.options.max)) {
val = self.options.max;
self.plus.disabled = true;
} else {
self.plus.disabled = false;
}
if (self.options.min != null && !isNaN(self.options.min) && val <= parseInt(self.options.min)) {
val = self.options.min;
self.minus.disabled = true;
} else {
self.minus.disabled = false;
}
self.input.value = val;
}
} | javascript | function() {
var self = this;
var val = self.input.value;
if (val == null || val == '' || isNaN(val)) {
self.input.value = self.options.min || 0;
self.minus.disabled = self.options.min != null;
} else {
var val = parseInt(val);
if (self.options.max != null && !isNaN(self.options.max) && val >= parseInt(self.options.max)) {
val = self.options.max;
self.plus.disabled = true;
} else {
self.plus.disabled = false;
}
if (self.options.min != null && !isNaN(self.options.min) && val <= parseInt(self.options.min)) {
val = self.options.min;
self.minus.disabled = true;
} else {
self.minus.disabled = false;
}
self.input.value = val;
}
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"val",
"=",
"self",
".",
"input",
".",
"value",
";",
"if",
"(",
"val",
"==",
"null",
"||",
"val",
"==",
"''",
"||",
"isNaN",
"(",
"val",
")",
")",
"{",
"self",
".",
"input",
"... | 验证当前值是法合法 | [
"验证当前值是法合法"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.js#L8227-L8249 | train | Set the value of the option | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
11748,
1027,
2969,
1012,
7953,
1012,
3643,
1025,
2065,
1006,
11748,
1027,
1027,
19701,
1064,
1064,
11748,
1027,
1027,
1005,
1005,
1064,
1064,
3475,
2319,
1006,
11748,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/core/util/util.js | function(element, nodeName, scanDeep, warnNotFound) {
var found = scanTree(element);
if (!found && !!warnNotFound) {
$log.warn($mdUtil.supplant("Unable to find node '{0}' in element '{1}'.",[nodeName, element[0].outerHTML]));
}
return angular.element(found || element);
/**
* Breadth-First tree scan for element with matching `nodeName`
*/
function scanTree(element) {
return scanLevel(element) || (scanDeep ? scanChildren(element) : null);
}
/**
* Case-insensitive scan of current elements only (do not descend).
*/
function scanLevel(element) {
if (element) {
for (var i = 0, len = element.length; i < len; i++) {
if (element[i].nodeName.toLowerCase() === nodeName) {
return element[i];
}
}
}
return null;
}
/**
* Scan children of specified node
*/
function scanChildren(element) {
var found;
if (element) {
for (var i = 0, len = element.length; i < len; i++) {
var target = element[i];
if (!found) {
for (var j = 0, numChild = target.childNodes.length; j < numChild; j++) {
found = found || scanTree([target.childNodes[j]]);
}
}
}
}
return found;
}
} | javascript | function(element, nodeName, scanDeep, warnNotFound) {
var found = scanTree(element);
if (!found && !!warnNotFound) {
$log.warn($mdUtil.supplant("Unable to find node '{0}' in element '{1}'.",[nodeName, element[0].outerHTML]));
}
return angular.element(found || element);
/**
* Breadth-First tree scan for element with matching `nodeName`
*/
function scanTree(element) {
return scanLevel(element) || (scanDeep ? scanChildren(element) : null);
}
/**
* Case-insensitive scan of current elements only (do not descend).
*/
function scanLevel(element) {
if (element) {
for (var i = 0, len = element.length; i < len; i++) {
if (element[i].nodeName.toLowerCase() === nodeName) {
return element[i];
}
}
}
return null;
}
/**
* Scan children of specified node
*/
function scanChildren(element) {
var found;
if (element) {
for (var i = 0, len = element.length; i < len; i++) {
var target = element[i];
if (!found) {
for (var j = 0, numChild = target.childNodes.length; j < numChild; j++) {
found = found || scanTree([target.childNodes[j]]);
}
}
}
}
return found;
}
} | [
"function",
"(",
"element",
",",
"nodeName",
",",
"scanDeep",
",",
"warnNotFound",
")",
"{",
"var",
"found",
"=",
"scanTree",
"(",
"element",
")",
";",
"if",
"(",
"!",
"found",
"&&",
"!",
"!",
"warnNotFound",
")",
"{",
"$log",
".",
"warn",
"(",
"$mdU... | Functional equivalent for $element.filter(‘md-bottom-sheet’)
useful with interimElements where the element and its container are important...
@param {angular.JQLite} element to scan
@param {string} nodeName of node to find (e.g. 'md-dialog')
@param {boolean=} scanDeep optional flag to allow deep scans; defaults to 'false'.
@param {boolean=} warnNotFound optional flag to enable log warnings; defaults to false | [
"Functional",
"equivalent",
"for",
"$element",
".",
"filter",
"(",
"‘md",
"-",
"bottom",
"-",
"sheet’",
")",
"useful",
"with",
"interimElements",
"where",
"the",
"element",
"and",
"its",
"container",
"are",
"important",
"..."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L597-L644 | train | Returns the first node that matches nodeName | [
30522,
3853,
1006,
5783,
1010,
13045,
18442,
1010,
13594,
26095,
2361,
1010,
11582,
17048,
14876,
8630,
1007,
1063,
13075,
2179,
1027,
13594,
13334,
1006,
5783,
1007,
1025,
2065,
1006,
999,
2179,
1004,
1004,
999,
999,
11582,
17048,
14876,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aws/aws-sdk-js | lib/services/s3.js | requestBucketRegion | function requestBucketRegion(resp, done) {
var error = resp.error;
var req = resp.request;
var bucket = req.params.Bucket || null;
if (!error || !bucket || error.region || req.operation === 'listObjects' ||
(AWS.util.isNode() && req.operation === 'headBucket') ||
(error.statusCode === 400 && req.operation !== 'headObject') ||
regionRedirectErrorCodes.indexOf(error.code) === -1) {
return done();
}
var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects';
var reqParams = {Bucket: bucket};
if (reqOperation === 'listObjects') reqParams.MaxKeys = 0;
var regionReq = req.service[reqOperation](reqParams);
regionReq._requestRegionForBucket = bucket;
regionReq.send(function() {
var region = req.service.bucketRegionCache[bucket] || null;
error.region = region;
done();
});
} | javascript | function requestBucketRegion(resp, done) {
var error = resp.error;
var req = resp.request;
var bucket = req.params.Bucket || null;
if (!error || !bucket || error.region || req.operation === 'listObjects' ||
(AWS.util.isNode() && req.operation === 'headBucket') ||
(error.statusCode === 400 && req.operation !== 'headObject') ||
regionRedirectErrorCodes.indexOf(error.code) === -1) {
return done();
}
var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects';
var reqParams = {Bucket: bucket};
if (reqOperation === 'listObjects') reqParams.MaxKeys = 0;
var regionReq = req.service[reqOperation](reqParams);
regionReq._requestRegionForBucket = bucket;
regionReq.send(function() {
var region = req.service.bucketRegionCache[bucket] || null;
error.region = region;
done();
});
} | [
"function",
"requestBucketRegion",
"(",
"resp",
",",
"done",
")",
"{",
"var",
"error",
"=",
"resp",
".",
"error",
";",
"var",
"req",
"=",
"resp",
".",
"request",
";",
"var",
"bucket",
"=",
"req",
".",
"params",
".",
"Bucket",
"||",
"null",
";",
"if",... | If region was not obtained synchronously, then send async request
to get bucket region for errors resulting from wrong region.
@api private | [
"If",
"region",
"was",
"not",
"obtained",
"synchronously",
"then",
"send",
"async",
"request",
"to",
"get",
"bucket",
"region",
"for",
"errors",
"resulting",
"from",
"wrong",
"region",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L600-L621 | train | Request bucket region | [
30522,
3853,
5227,
24204,
3388,
23784,
1006,
24501,
2361,
1010,
2589,
1007,
1063,
13075,
7561,
1027,
24501,
2361,
1012,
7561,
1025,
13075,
2128,
4160,
1027,
24501,
2361,
1012,
5227,
1025,
13075,
13610,
1027,
2128,
4160,
1012,
11498,
5244,
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... |
summernote/summernote | src/js/base/core/dom.js | splitTree | function splitTree(root, point, options) {
// ex) [#text, <span>, <p>]
const ancestors = listAncestor(point.node, func.eq(root));
if (!ancestors.length) {
return null;
} else if (ancestors.length === 1) {
return splitNode(point, options);
}
return ancestors.reduce(function(node, parent) {
if (node === point.node) {
node = splitNode(point, options);
}
return splitNode({
node: parent,
offset: node ? position(node) : nodeLength(parent),
}, options);
});
} | javascript | function splitTree(root, point, options) {
// ex) [#text, <span>, <p>]
const ancestors = listAncestor(point.node, func.eq(root));
if (!ancestors.length) {
return null;
} else if (ancestors.length === 1) {
return splitNode(point, options);
}
return ancestors.reduce(function(node, parent) {
if (node === point.node) {
node = splitNode(point, options);
}
return splitNode({
node: parent,
offset: node ? position(node) : nodeLength(parent),
}, options);
});
} | [
"function",
"splitTree",
"(",
"root",
",",
"point",
",",
"options",
")",
"{",
"// ex) [#text, <span>, <p>]",
"const",
"ancestors",
"=",
"listAncestor",
"(",
"point",
".",
"node",
",",
"func",
".",
"eq",
"(",
"root",
")",
")",
";",
"if",
"(",
"!",
"ancest... | @method splitTree
split tree by point
@param {Node} root - split root
@param {BoundaryPoint} point
@param {Object} [options]
@param {Boolean} [options.isSkipPaddingBlankHTML] - default: false
@param {Boolean} [options.isNotSplitEdgePoint] - default: false
@return {Node} right node of boundaryPoint | [
"@method",
"splitTree"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L796-L816 | train | Split a node into two nodes | [
30522,
3853,
3975,
13334,
1006,
7117,
1010,
2391,
1010,
7047,
1007,
1063,
1013,
1013,
4654,
1007,
1031,
1001,
3793,
1010,
1026,
8487,
1028,
1010,
1026,
1052,
1028,
1033,
9530,
3367,
10748,
1027,
2862,
26755,
4263,
1006,
2391,
1012,
13045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | common/src/web/jquery-1.3.2.js | function(from, to, unit){
this.startTime = now();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
this.now = this.start;
this.pos = this.state = 0;
var self = this;
function t(gotoEnd){
return self.step(gotoEnd);
}
t.elem = this.elem;
if ( t() && jQuery.timers.push(t) && !timerId ) {
timerId = setInterval(function(){
var timers = jQuery.timers;
for ( var i = 0; i < timers.length; i++ )
if ( !timers[i]() )
timers.splice(i--, 1);
if ( !timers.length ) {
clearInterval( timerId );
timerId = undefined;
}
}, 13);
}
} | javascript | function(from, to, unit){
this.startTime = now();
this.start = from;
this.end = to;
this.unit = unit || this.unit || "px";
this.now = this.start;
this.pos = this.state = 0;
var self = this;
function t(gotoEnd){
return self.step(gotoEnd);
}
t.elem = this.elem;
if ( t() && jQuery.timers.push(t) && !timerId ) {
timerId = setInterval(function(){
var timers = jQuery.timers;
for ( var i = 0; i < timers.length; i++ )
if ( !timers[i]() )
timers.splice(i--, 1);
if ( !timers.length ) {
clearInterval( timerId );
timerId = undefined;
}
}, 13);
}
} | [
"function",
"(",
"from",
",",
"to",
",",
"unit",
")",
"{",
"this",
".",
"startTime",
"=",
"now",
"(",
")",
";",
"this",
".",
"start",
"=",
"from",
";",
"this",
".",
"end",
"=",
"to",
";",
"this",
".",
"unit",
"=",
"unit",
"||",
"this",
".",
"... | Start an animation from one number to another | [
"Start",
"an",
"animation",
"from",
"one",
"number",
"to",
"another"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/common/src/web/jquery-1.3.2.js#L4037-L4066 | train | set the start and end values | [
30522,
3853,
1006,
2013,
1010,
2000,
1010,
3131,
1007,
1063,
2023,
1012,
2707,
7292,
1027,
2085,
1006,
1007,
1025,
2023,
1012,
2707,
1027,
2013,
1025,
2023,
1012,
2203,
1027,
2000,
1025,
2023,
1012,
3131,
1027,
3131,
1064,
1064,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/update-check.js | updateCheckError | function updateCheckError(err) {
api.settings.edit({
settings: [{
key: 'next_update_check',
value: nextCheckTimestamp()
}]
}, internal);
err.context = common.i18n.t('errors.updateCheck.checkingForUpdatesFailed.error');
err.help = common.i18n.t('errors.updateCheck.checkingForUpdatesFailed.help', {url: 'https://docs.ghost.org'});
common.logging.error(err);
} | javascript | function updateCheckError(err) {
api.settings.edit({
settings: [{
key: 'next_update_check',
value: nextCheckTimestamp()
}]
}, internal);
err.context = common.i18n.t('errors.updateCheck.checkingForUpdatesFailed.error');
err.help = common.i18n.t('errors.updateCheck.checkingForUpdatesFailed.help', {url: 'https://docs.ghost.org'});
common.logging.error(err);
} | [
"function",
"updateCheckError",
"(",
"err",
")",
"{",
"api",
".",
"settings",
".",
"edit",
"(",
"{",
"settings",
":",
"[",
"{",
"key",
":",
"'next_update_check'",
",",
"value",
":",
"nextCheckTimestamp",
"(",
")",
"}",
"]",
"}",
",",
"internal",
")",
"... | @description Centralised error handler for the update check unit.
CASES:
- the update check service returns an error
- error during collecting blog stats
We still need to ensure that we set the "next_update_check" to a new value, otherwise no more
update checks will happen.
@param err | [
"@description",
"Centralised",
"error",
"handler",
"for",
"the",
"update",
"check",
"unit",
"."
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/update-check.js#L43-L54 | train | updateCheckError - error message | [
30522,
3853,
10651,
5403,
9102,
29165,
1006,
9413,
2099,
1007,
1063,
17928,
1012,
10906,
1012,
10086,
1006,
1063,
10906,
1024,
1031,
1063,
3145,
1024,
1005,
2279,
1035,
10651,
1035,
4638,
1005,
1010,
3643,
1024,
2279,
5403,
3600,
7292,
9153... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
cytoscape/cytoscape.js | dist/cytoscape.esm.js | animation | function animation() {
return function animationImpl(properties, params) {
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var cy = this._private.cy || this;
var isCore = !selfIsArrayLike;
var isEles = !isCore;
if (!cy.styleEnabled()) {
return this;
}
var style$$1 = cy.style();
properties = extend({}, properties, params);
var propertiesEmpty = Object.keys(properties).length === 0;
if (propertiesEmpty) {
return new Animation(all[0], properties); // nothing to animate
}
if (properties.duration === undefined) {
properties.duration = 400;
}
switch (properties.duration) {
case 'slow':
properties.duration = 600;
break;
case 'fast':
properties.duration = 200;
break;
}
if (isEles) {
properties.style = style$$1.getPropsList(properties.style || properties.css);
properties.css = undefined;
}
if (isEles && properties.renderedPosition != null) {
var rpos = properties.renderedPosition;
var pan = cy.pan();
var zoom = cy.zoom();
properties.position = renderedToModelPosition(rpos, zoom, pan);
} // override pan w/ panBy if set
if (isCore && properties.panBy != null) {
var panBy = properties.panBy;
var cyPan = cy.pan();
properties.pan = {
x: cyPan.x + panBy.x,
y: cyPan.y + panBy.y
};
} // override pan w/ center if set
var center = properties.center || properties.centre;
if (isCore && center != null) {
var centerPan = cy.getCenterPan(center.eles, properties.zoom);
if (centerPan != null) {
properties.pan = centerPan;
}
} // override pan & zoom w/ fit if set
if (isCore && properties.fit != null) {
var fit = properties.fit;
var fitVp = cy.getFitViewport(fit.eles || fit.boundingBox, fit.padding);
if (fitVp != null) {
properties.pan = fitVp.pan;
properties.zoom = fitVp.zoom;
}
} // override zoom (& potentially pan) w/ zoom obj if set
if (isCore && plainObject(properties.zoom)) {
var vp = cy.getZoomedViewport(properties.zoom);
if (vp != null) {
if (vp.zoomed) {
properties.zoom = vp.zoom;
}
if (vp.panned) {
properties.pan = vp.pan;
}
}
}
return new Animation(all[0], properties);
};
} | javascript | function animation() {
return function animationImpl(properties, params) {
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var cy = this._private.cy || this;
var isCore = !selfIsArrayLike;
var isEles = !isCore;
if (!cy.styleEnabled()) {
return this;
}
var style$$1 = cy.style();
properties = extend({}, properties, params);
var propertiesEmpty = Object.keys(properties).length === 0;
if (propertiesEmpty) {
return new Animation(all[0], properties); // nothing to animate
}
if (properties.duration === undefined) {
properties.duration = 400;
}
switch (properties.duration) {
case 'slow':
properties.duration = 600;
break;
case 'fast':
properties.duration = 200;
break;
}
if (isEles) {
properties.style = style$$1.getPropsList(properties.style || properties.css);
properties.css = undefined;
}
if (isEles && properties.renderedPosition != null) {
var rpos = properties.renderedPosition;
var pan = cy.pan();
var zoom = cy.zoom();
properties.position = renderedToModelPosition(rpos, zoom, pan);
} // override pan w/ panBy if set
if (isCore && properties.panBy != null) {
var panBy = properties.panBy;
var cyPan = cy.pan();
properties.pan = {
x: cyPan.x + panBy.x,
y: cyPan.y + panBy.y
};
} // override pan w/ center if set
var center = properties.center || properties.centre;
if (isCore && center != null) {
var centerPan = cy.getCenterPan(center.eles, properties.zoom);
if (centerPan != null) {
properties.pan = centerPan;
}
} // override pan & zoom w/ fit if set
if (isCore && properties.fit != null) {
var fit = properties.fit;
var fitVp = cy.getFitViewport(fit.eles || fit.boundingBox, fit.padding);
if (fitVp != null) {
properties.pan = fitVp.pan;
properties.zoom = fitVp.zoom;
}
} // override zoom (& potentially pan) w/ zoom obj if set
if (isCore && plainObject(properties.zoom)) {
var vp = cy.getZoomedViewport(properties.zoom);
if (vp != null) {
if (vp.zoomed) {
properties.zoom = vp.zoom;
}
if (vp.panned) {
properties.pan = vp.pan;
}
}
}
return new Animation(all[0], properties);
};
} | [
"function",
"animation",
"(",
")",
"{",
"return",
"function",
"animationImpl",
"(",
"properties",
",",
"params",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"selfIsArrayLike",
"=",
"self",
".",
"length",
"!==",
"undefined",
";",
"var",
"all",
"=",
... | delay | [
"delay"
] | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L5800-L5897 | train | Animation implementation for the core animation | [
30522,
3853,
7284,
1006,
1007,
1063,
2709,
3853,
7284,
5714,
24759,
1006,
5144,
1010,
11498,
5244,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
2969,
14268,
11335,
8516,
17339,
1027,
2969,
1012,
3091,
999,
1027,
1027,
6151,
28344,
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... |
apache/incubator-echarts | src/coord/Axis.js | function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
} | javascript | function (coord, clamp) {
var extent = this._extent;
var scale = this.scale;
if (this.onBand && scale.type === 'ordinal') {
extent = extent.slice();
fixExtentWithBands(extent, scale.count());
}
var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
return this.scale.scale(t);
} | [
"function",
"(",
"coord",
",",
"clamp",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"scale",
"=",
"this",
".",
"scale",
";",
"if",
"(",
"this",
".",
"onBand",
"&&",
"scale",
".",
"type",
"===",
"'ordinal'",
")",
"{",
"extent... | Convert coord to data. Data is the rank if it has an ordinal scale
@param {number} coord
@param {boolean} clamp
@return {number} | [
"Convert",
"coord",
"to",
"data",
".",
"Data",
"is",
"the",
"rank",
"if",
"it",
"has",
"an",
"ordinal",
"scale"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L147-L159 | train | Returns a new vector with the given coord | [
30522,
3853,
1006,
2522,
8551,
1010,
18856,
16613,
1007,
1063,
13075,
6698,
1027,
2023,
1012,
1035,
6698,
1025,
13075,
4094,
1027,
2023,
1012,
4094,
1025,
2065,
1006,
2023,
1012,
2006,
12733,
1004,
1004,
4094,
1012,
2828,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js | getChangeSetResponseIndex | function getChangeSetResponseIndex(sMimeTypeHeaders) {
var sContentID = getHeaderValue(sMimeTypeHeaders, "content-id"),
iResponseIndex;
if (!sContentID) {
throw new Error("Content-ID MIME header missing for the change set response.");
}
iResponseIndex = parseInt(sContentID);
if (isNaN(iResponseIndex)) {
throw new Error("Invalid Content-ID value in change set response.");
}
return iResponseIndex;
} | javascript | function getChangeSetResponseIndex(sMimeTypeHeaders) {
var sContentID = getHeaderValue(sMimeTypeHeaders, "content-id"),
iResponseIndex;
if (!sContentID) {
throw new Error("Content-ID MIME header missing for the change set response.");
}
iResponseIndex = parseInt(sContentID);
if (isNaN(iResponseIndex)) {
throw new Error("Invalid Content-ID value in change set response.");
}
return iResponseIndex;
} | [
"function",
"getChangeSetResponseIndex",
"(",
"sMimeTypeHeaders",
")",
"{",
"var",
"sContentID",
"=",
"getHeaderValue",
"(",
"sMimeTypeHeaders",
",",
"\"content-id\"",
")",
",",
"iResponseIndex",
";",
"if",
"(",
"!",
"sContentID",
")",
"{",
"throw",
"new",
"Error"... | Returns index of the response inside of a change set by parsing the Content-ID header value
available as a part of the specified change set response <code>sMimeTypeHeaders</code>.
The function expects Content-ID header value to be specified in <code>i.j</code> notation,
where <code>i</code> represents the index of the response inside of the change set.
@param {string} sMimeTypeHeaders
Section of MIME part representing MIME HTTP headers of the change set response
@returns {number} Zero-based index of the response inside of the change set
@throws {Error} If there is no Content-ID header in the specified
<code>sMimeTypeHeaders</code> or the available Content-ID header value is not a number. | [
"Returns",
"index",
"of",
"the",
"response",
"inside",
"of",
"a",
"change",
"set",
"by",
"parsing",
"the",
"Content",
"-",
"ID",
"header",
"value",
"available",
"as",
"a",
"part",
"of",
"the",
"specified",
"change",
"set",
"response",
"<code",
">",
"sMimeT... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js#L92-L105 | train | Returns the index of the change set response. | [
30522,
3853,
2131,
22305,
6810,
19168,
26029,
20240,
13629,
2595,
1006,
15488,
14428,
13874,
4974,
2545,
1007,
1063,
13075,
8040,
28040,
16778,
2094,
1027,
2131,
4974,
2121,
10175,
5657,
1006,
15488,
14428,
13874,
4974,
2545,
1010,
1000,
4180... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
caolan/async | lib/mapValuesLimit.js | mapValuesLimit | function mapValuesLimit(obj, limit, iteratee, callback) {
callback = once(callback);
var newObj = {};
var _iteratee = wrapAsync(iteratee)
return eachOfLimit(limit)(obj, (val, key, next) => {
_iteratee(val, key, (err, result) => {
if (err) return next(err);
newObj[key] = result;
next(err);
});
}, err => callback(err, newObj));
} | javascript | function mapValuesLimit(obj, limit, iteratee, callback) {
callback = once(callback);
var newObj = {};
var _iteratee = wrapAsync(iteratee)
return eachOfLimit(limit)(obj, (val, key, next) => {
_iteratee(val, key, (err, result) => {
if (err) return next(err);
newObj[key] = result;
next(err);
});
}, err => callback(err, newObj));
} | [
"function",
"mapValuesLimit",
"(",
"obj",
",",
"limit",
",",
"iteratee",
",",
"callback",
")",
"{",
"callback",
"=",
"once",
"(",
"callback",
")",
";",
"var",
"newObj",
"=",
"{",
"}",
";",
"var",
"_iteratee",
"=",
"wrapAsync",
"(",
"iteratee",
")",
"re... | The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
time.
@name mapValuesLimit
@static
@memberOf module:Collections
@method
@see [async.mapValues]{@link module:Collections.mapValues}
@category Collection
@param {Object} obj - A collection to iterate over.
@param {number} limit - The maximum number of async operations at a time.
@param {AsyncFunction} iteratee - A function to apply to each value and key
in `coll`.
The iteratee should complete with the transformed value as its result.
Invoked with (value, key, callback).
@param {Function} [callback] - A callback which is called when all `iteratee`
functions have finished, or an error occurs. `result` is a new object consisting
of each key from `obj`, with each transformed value on the right-hand side.
Invoked with (err, result).
@returns {Promise} a promise, if no callback is passed | [
"The",
"same",
"as",
"[",
"mapValues",
"]",
"{",
"@link",
"module",
":",
"Collections",
".",
"mapValues",
"}",
"but",
"runs",
"a",
"maximum",
"of",
"limit",
"async",
"operations",
"at",
"a",
"time",
"."
] | 4330d536c106592139fa82062494c9dba0da1fdb | https://github.com/caolan/async/blob/4330d536c106592139fa82062494c9dba0da1fdb/lib/mapValuesLimit.js#L28-L39 | train | Map values from an object to a new object with the highest key value | [
30522,
3853,
4949,
10175,
15808,
17960,
4183,
1006,
27885,
3501,
1010,
5787,
1010,
2009,
22139,
2063,
1010,
2655,
5963,
1007,
1063,
2655,
5963,
1027,
2320,
1006,
2655,
5963,
1007,
1025,
13075,
2047,
16429,
3501,
1027,
1063,
1065,
1025,
1307... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
google/closure-library | closure/goog/loader/activemodulemanager.js | get | function get() {
if (!moduleManager && getDefault) {
moduleManager = getDefault();
}
asserts.assert(
moduleManager != null, 'The module manager has not yet been set.');
return moduleManager;
} | javascript | function get() {
if (!moduleManager && getDefault) {
moduleManager = getDefault();
}
asserts.assert(
moduleManager != null, 'The module manager has not yet been set.');
return moduleManager;
} | [
"function",
"get",
"(",
")",
"{",
"if",
"(",
"!",
"moduleManager",
"&&",
"getDefault",
")",
"{",
"moduleManager",
"=",
"getDefault",
"(",
")",
";",
"}",
"asserts",
".",
"assert",
"(",
"moduleManager",
"!=",
"null",
",",
"'The module manager has not yet been se... | Gets the active module manager, instantiating one if necessary.
@return {!AbstractModuleManager} | [
"Gets",
"the",
"active",
"module",
"manager",
"instantiating",
"one",
"if",
"necessary",
"."
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/loader/activemodulemanager.js#L36-L43 | train | Get the module manager | [
30522,
3853,
2131,
1006,
1007,
1063,
2065,
1006,
999,
11336,
24805,
4590,
1004,
1004,
2131,
3207,
7011,
11314,
1007,
1063,
11336,
24805,
4590,
1027,
2131,
3207,
7011,
11314,
1006,
1007,
1025,
1065,
19514,
1012,
20865,
1006,
11336,
24805,
45... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Configuration.js | function(sFormatId) {
sFormatId = sFormatId ? sFormatId.toUpperCase() : "";
check(!sFormatId || M_ABAP_NUMBER_FORMAT_SYMBOLS.hasOwnProperty(sFormatId), "sFormatId must be one of [' ','X','Y'] or empty");
var mChanges = this.oConfiguration._collect();
this.sLegacyNumberFormat = mChanges.legacyNumberFormat = sFormatId;
this.setNumberSymbol("group", M_ABAP_NUMBER_FORMAT_SYMBOLS[sFormatId].groupingSeparator);
this.setNumberSymbol("decimal", M_ABAP_NUMBER_FORMAT_SYMBOLS[sFormatId].decimalSeparator);
this.oConfiguration._endCollect();
return this;
} | javascript | function(sFormatId) {
sFormatId = sFormatId ? sFormatId.toUpperCase() : "";
check(!sFormatId || M_ABAP_NUMBER_FORMAT_SYMBOLS.hasOwnProperty(sFormatId), "sFormatId must be one of [' ','X','Y'] or empty");
var mChanges = this.oConfiguration._collect();
this.sLegacyNumberFormat = mChanges.legacyNumberFormat = sFormatId;
this.setNumberSymbol("group", M_ABAP_NUMBER_FORMAT_SYMBOLS[sFormatId].groupingSeparator);
this.setNumberSymbol("decimal", M_ABAP_NUMBER_FORMAT_SYMBOLS[sFormatId].decimalSeparator);
this.oConfiguration._endCollect();
return this;
} | [
"function",
"(",
"sFormatId",
")",
"{",
"sFormatId",
"=",
"sFormatId",
"?",
"sFormatId",
".",
"toUpperCase",
"(",
")",
":",
"\"\"",
";",
"check",
"(",
"!",
"sFormatId",
"||",
"M_ABAP_NUMBER_FORMAT_SYMBOLS",
".",
"hasOwnProperty",
"(",
"sFormatId",
")",
",",
... | Allows to specify one of the legacy ABAP number format.
This method will modify the 'group' and 'decimal' symbols. When called with a null
or undefined format id, any previously applied format will be removed.
After changing the legacy number format, the framework tries to update localization
specific parts of the UI. See the documentation of {@link sap.ui.core.Configuration#setLanguage}
for details and restrictions.
@param {string} sFormatId id of the ABAP number format set (one of ' ','X','Y')
@return {sap.ui.core.Configuration.FormatSettings} Returns <code>this</code> to allow method chaining
@public | [
"Allows",
"to",
"specify",
"one",
"of",
"the",
"legacy",
"ABAP",
"number",
"format",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Configuration.js#L2126-L2135 | train | Sets the legacy number format | [
30522,
3853,
1006,
16420,
2953,
18900,
3593,
1007,
1063,
16420,
2953,
18900,
3593,
1027,
16420,
2953,
18900,
3593,
1029,
16420,
2953,
18900,
3593,
1012,
2000,
29547,
18992,
3366,
1006,
1007,
1024,
1000,
1000,
1025,
4638,
1006,
999,
16420,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
chartjs/Chart.js | src/core/core.tooltip.js | function(line) {
ctx.fillText(line, pt.x + xLinePadding, pt.y);
pt.y += bodyFontSize + bodySpacing;
} | javascript | function(line) {
ctx.fillText(line, pt.x + xLinePadding, pt.y);
pt.y += bodyFontSize + bodySpacing;
} | [
"function",
"(",
"line",
")",
"{",
"ctx",
".",
"fillText",
"(",
"line",
",",
"pt",
".",
"x",
"+",
"xLinePadding",
",",
"pt",
".",
"y",
")",
";",
"pt",
".",
"y",
"+=",
"bodyFontSize",
"+",
"bodySpacing",
";",
"}"
] | Before Body | [
"Before",
"Body"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.tooltip.js#L794-L797 | train | fill the line | [
30522,
3853,
1006,
2240,
1007,
1063,
14931,
2595,
1012,
6039,
18209,
1006,
2240,
1010,
13866,
1012,
1060,
1009,
28712,
3170,
15455,
4667,
1010,
13866,
1012,
1061,
1007,
1025,
13866,
1012,
1061,
1009,
1027,
2303,
14876,
7666,
4697,
1009,
230... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
fengyuanchen/cropper | dist/cropper.common.js | setData | function setData(element, name, data) {
if (isObject(data)) {
element[name] = data;
} else if (element.dataset) {
element.dataset[name] = data;
} else {
element.setAttribute('data-' + hyphenate(name), data);
}
} | javascript | function setData(element, name, data) {
if (isObject(data)) {
element[name] = data;
} else if (element.dataset) {
element.dataset[name] = data;
} else {
element.setAttribute('data-' + hyphenate(name), data);
}
} | [
"function",
"setData",
"(",
"element",
",",
"name",
",",
"data",
")",
"{",
"if",
"(",
"isObject",
"(",
"data",
")",
")",
"{",
"element",
"[",
"name",
"]",
"=",
"data",
";",
"}",
"else",
"if",
"(",
"element",
".",
"dataset",
")",
"{",
"element",
"... | Set data to the given element.
@param {Element} element - The target element.
@param {string} name - The data key to set.
@param {string} data - The data value. | [
"Set",
"data",
"to",
"the",
"given",
"element",
"."
] | 6677332a6a375b647f58808dfc24ea09f5804041 | https://github.com/fengyuanchen/cropper/blob/6677332a6a375b647f58808dfc24ea09f5804041/dist/cropper.common.js#L491-L499 | train | Set data on an element | [
30522,
3853,
2275,
2850,
2696,
1006,
5783,
1010,
2171,
1010,
2951,
1007,
1063,
2065,
1006,
11163,
2497,
20614,
1006,
2951,
1007,
1007,
1063,
5783,
1031,
2171,
1033,
1027,
2951,
1025,
1065,
2842,
2065,
1006,
5783,
1012,
2951,
13462,
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... |
aframevr/aframe | src/utils/styleParser.js | transformKeysToCamelCase | function transformKeysToCamelCase (obj) {
var camelKey;
var key;
for (key in obj) {
camelKey = toCamelCase(key);
if (key === camelKey) { continue; }
obj[camelKey] = obj[key];
delete obj[key];
}
return obj;
} | javascript | function transformKeysToCamelCase (obj) {
var camelKey;
var key;
for (key in obj) {
camelKey = toCamelCase(key);
if (key === camelKey) { continue; }
obj[camelKey] = obj[key];
delete obj[key];
}
return obj;
} | [
"function",
"transformKeysToCamelCase",
"(",
"obj",
")",
"{",
"var",
"camelKey",
";",
"var",
"key",
";",
"for",
"(",
"key",
"in",
"obj",
")",
"{",
"camelKey",
"=",
"toCamelCase",
"(",
"key",
")",
";",
"if",
"(",
"key",
"===",
"camelKey",
")",
"{",
"c... | Converts object's keys from hyphens to camelCase (e.g., `max-value` to
`maxValue`).
@param {object} obj - The object to camelCase keys.
@return {object} The object with keys camelCased. | [
"Converts",
"object",
"s",
"keys",
"from",
"hyphens",
"to",
"camelCase",
"(",
"e",
".",
"g",
".",
"max",
"-",
"value",
"to",
"maxValue",
")",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/styleParser.js#L53-L63 | train | Transform keys to camel case | [
30522,
3853,
10938,
14839,
16033,
28727,
2884,
18382,
1006,
27885,
3501,
1007,
1063,
13075,
19130,
14839,
1025,
13075,
3145,
1025,
2005,
1006,
3145,
1999,
27885,
3501,
1007,
1063,
19130,
14839,
1027,
2000,
28727,
2884,
18382,
1006,
3145,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | features/extra/cleanup.js | function(list, iter, callback) {
var item = list.shift();
iter(item, function(err) {
if (err) return callback(err);
else if (list.length) {
eachSeries(list, iter, callback);
} else {
return callback();
}
});
} | javascript | function(list, iter, callback) {
var item = list.shift();
iter(item, function(err) {
if (err) return callback(err);
else if (list.length) {
eachSeries(list, iter, callback);
} else {
return callback();
}
});
} | [
"function",
"(",
"list",
",",
"iter",
",",
"callback",
")",
"{",
"var",
"item",
"=",
"list",
".",
"shift",
"(",
")",
";",
"iter",
"(",
"item",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
... | Run bucket cleanup serially. | [
"Run",
"bucket",
"cleanup",
"serially",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/features/extra/cleanup.js#L48-L58 | train | iterate over the list and return the next result | [
30522,
3853,
1006,
2862,
1010,
2009,
2121,
1010,
2655,
5963,
1007,
1063,
13075,
8875,
1027,
2862,
1012,
5670,
1006,
1007,
1025,
2009,
2121,
1006,
8875,
1010,
3853,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
2709,
2655,
59... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
catapult-project/catapult | tracing/third_party/oboe/src/lists.js | foldR1 | function foldR1(fn, list) {
return tail(list)
? fn(foldR1(fn, tail(list)), head(list))
: head(list)
;
} | javascript | function foldR1(fn, list) {
return tail(list)
? fn(foldR1(fn, tail(list)), head(list))
: head(list)
;
} | [
"function",
"foldR1",
"(",
"fn",
",",
"list",
")",
"{",
"return",
"tail",
"(",
"list",
")",
"?",
"fn",
"(",
"foldR1",
"(",
"fn",
",",
"tail",
"(",
"list",
")",
")",
",",
"head",
"(",
"list",
")",
")",
":",
"head",
"(",
"list",
")",
";",
"}"
] | foldR implementation. Reduce a list down to a single value.
@pram {Function} fn (rightEval, curVal) -> result | [
"foldR",
"implementation",
".",
"Reduce",
"a",
"list",
"down",
"to",
"a",
"single",
"value",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/oboe/src/lists.js#L115-L121 | train | R1 folds the list in reverse order | [
30522,
3853,
10671,
2099,
2487,
1006,
1042,
2078,
1010,
2862,
1007,
1063,
2709,
5725,
1006,
2862,
1007,
1029,
1042,
2078,
1006,
10671,
2099,
2487,
1006,
1042,
2078,
1010,
5725,
1006,
2862,
1007,
1007,
1010,
2132,
1006,
2862,
1007,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/Support.js | setupDialog | function setupDialog() {
// setup e2e values as log level and content
if (dialog.traceXml) {
dialog.$(e2eTraceConst.taContent).text(dialog.traceXml);
}
if (dialog.e2eLogLevel) {
dialog.$(e2eTraceConst.selLevel).val(dialog.e2eLogLevel);
}
fillPanelContent(controlIDs.dvLoadedModules, oData.modules);
// bind button Start event
dialog.$(e2eTraceConst.btnStart).one("tap", function () {
dialog.e2eLogLevel = dialog.$(e2eTraceConst.selLevel).val();
dialog.$(e2eTraceConst.btnStart).addClass("sapUiSupportRunningTrace").text("Running...");
dialog.traceXml = "";
dialog.$(e2eTraceConst.taContent).text("");
sap.ui.core.support.trace.E2eTraceLib.start(dialog.e2eLogLevel, function (traceXml) {
dialog.traceXml = traceXml;
});
// show info message about the E2E trace activation
sap.m.MessageToast.show(e2eTraceConst.infoText, {duration: e2eTraceConst.infoDuration});
//close the dialog, but keep it for later use
dialog.close();
});
} | javascript | function setupDialog() {
// setup e2e values as log level and content
if (dialog.traceXml) {
dialog.$(e2eTraceConst.taContent).text(dialog.traceXml);
}
if (dialog.e2eLogLevel) {
dialog.$(e2eTraceConst.selLevel).val(dialog.e2eLogLevel);
}
fillPanelContent(controlIDs.dvLoadedModules, oData.modules);
// bind button Start event
dialog.$(e2eTraceConst.btnStart).one("tap", function () {
dialog.e2eLogLevel = dialog.$(e2eTraceConst.selLevel).val();
dialog.$(e2eTraceConst.btnStart).addClass("sapUiSupportRunningTrace").text("Running...");
dialog.traceXml = "";
dialog.$(e2eTraceConst.taContent).text("");
sap.ui.core.support.trace.E2eTraceLib.start(dialog.e2eLogLevel, function (traceXml) {
dialog.traceXml = traceXml;
});
// show info message about the E2E trace activation
sap.m.MessageToast.show(e2eTraceConst.infoText, {duration: e2eTraceConst.infoDuration});
//close the dialog, but keep it for later use
dialog.close();
});
} | [
"function",
"setupDialog",
"(",
")",
"{",
"// setup e2e values as log level and content",
"if",
"(",
"dialog",
".",
"traceXml",
")",
"{",
"dialog",
".",
"$",
"(",
"e2eTraceConst",
".",
"taContent",
")",
".",
"text",
"(",
"dialog",
".",
"traceXml",
")",
";",
... | setup dialog elements and bind some events | [
"setup",
"dialog",
"elements",
"and",
"bind",
"some",
"events"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/Support.js#L208-L238 | train | Setup the dialog | [
30522,
30524,
2504,
1998,
4180,
2065,
1006,
13764,
8649,
1012,
7637,
2595,
19968,
1007,
1063,
13764,
8649,
1012,
1002,
1006,
1041,
2475,
3388,
22903,
8663,
3367,
1012,
11937,
8663,
6528,
2102,
1007,
1012,
3793,
1006,
13764,
8649,
1012,
7637... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/utils.js | hasMatchingExtname | function hasMatchingExtname(pathname, exts) {
var suffix = path.extname(pathname).slice(1);
return exts.some(function(element) {
return suffix === element;
});
} | javascript | function hasMatchingExtname(pathname, exts) {
var suffix = path.extname(pathname).slice(1);
return exts.some(function(element) {
return suffix === element;
});
} | [
"function",
"hasMatchingExtname",
"(",
"pathname",
",",
"exts",
")",
"{",
"var",
"suffix",
"=",
"path",
".",
"extname",
"(",
"pathname",
")",
".",
"slice",
"(",
"1",
")",
";",
"return",
"exts",
".",
"some",
"(",
"function",
"(",
"element",
")",
"{",
... | Determines if pathname has a matching file extension.
@private
@param {string} pathname - Pathname to check for match.
@param {string[]} exts - List of file extensions (sans period).
@return {boolean} whether file extension matches.
@example
hasMatchingExtname('foo.html', ['js', 'css']); // => false | [
"Determines",
"if",
"pathname",
"has",
"a",
"matching",
"file",
"extension",
"."
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/utils.js#L530-L535 | train | Check if a pathname has a matching extension | [
30522,
3853,
2038,
18900,
8450,
10288,
2102,
18442,
1006,
4130,
18442,
1010,
4654,
3215,
1007,
1063,
13075,
16809,
1027,
4130,
1012,
4654,
2102,
18442,
1006,
4130,
18442,
1007,
1012,
14704,
1006,
1015,
1007,
1025,
2709,
4654,
3215,
1012,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js | setStylesheetText | function setStylesheetText(url, text, clients) {
return _send(
{
method: "CSS.setStylesheetText",
params: {
url: url,
text: text
}
}
);
} | javascript | function setStylesheetText(url, text, clients) {
return _send(
{
method: "CSS.setStylesheetText",
params: {
url: url,
text: text
}
}
);
} | [
"function",
"setStylesheetText",
"(",
"url",
",",
"text",
",",
"clients",
")",
"{",
"return",
"_send",
"(",
"{",
"method",
":",
"\"CSS.setStylesheetText\"",
",",
"params",
":",
"{",
"url",
":",
"url",
",",
"text",
":",
"text",
"}",
"}",
")",
";",
"}"
] | Protocol method. Reloads a CSS styleseet in the browser (by replacing its text) given its url.
@param {string} url Absolute URL of the stylesheet
@param {string} text The new text of the stylesheet
@param {number|Array.<number>} clients A client ID or array of client IDs that should evaluate
the script.
@return {$.Promise} A promise that's resolved with the return value from the first client that responds
to the evaluation. | [
"Protocol",
"method",
".",
"Reloads",
"a",
"CSS",
"styleseet",
"in",
"the",
"browser",
"(",
"by",
"replacing",
"its",
"text",
")",
"given",
"its",
"url",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js#L265-L275 | train | Set stylesheet text | [
30522,
3853,
4520,
27983,
4095,
15558,
18209,
1006,
24471,
2140,
1010,
3793,
1010,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(options) {
var nextSibling = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});
if (nextSibling && _isLineBreak(nextSibling)) {
nextSibling.parentNode.removeChild(nextSibling);
}
if (previousSibling && _isLineBreak(previousSibling)) {
previousSibling.parentNode.removeChild(previousSibling);
}
} | javascript | function(options) {
var nextSibling = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});
if (nextSibling && _isLineBreak(nextSibling)) {
nextSibling.parentNode.removeChild(nextSibling);
}
if (previousSibling && _isLineBreak(previousSibling)) {
previousSibling.parentNode.removeChild(previousSibling);
}
} | [
"function",
"(",
"options",
")",
"{",
"var",
"nextSibling",
"=",
"wysihtml5",
".",
"dom",
".",
"domNode",
"(",
"node",
")",
".",
"next",
"(",
"{",
"ignoreBlankTexts",
":",
"true",
"}",
")",
",",
"previousSibling",
"=",
"wysihtml5",
".",
"dom",
".",
"do... | /* wysihtml5.dom.lineBreaks(element).remove();
Removes line breaks before and after the given node | [
"/",
"*",
"wysihtml5",
".",
"dom",
".",
"lineBreaks",
"(",
"element",
")",
".",
"remove",
"()",
";"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L5746-L5756 | train | Remove the text nodes that are not blank | [
30522,
3853,
1006,
7047,
1007,
1063,
13075,
2279,
5332,
9709,
1027,
1059,
7274,
19190,
21246,
2140,
2629,
1012,
14383,
1012,
14383,
3630,
3207,
1006,
13045,
1007,
1012,
2279,
1006,
1063,
8568,
28522,
8950,
18209,
2015,
1024,
2995,
1065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/utils/PerfUtils.js | createPerfMeasurement | function createPerfMeasurement(id, name) {
var pm = new PerfMeasurement(id, name);
exports[id] = pm;
return pm;
} | javascript | function createPerfMeasurement(id, name) {
var pm = new PerfMeasurement(id, name);
exports[id] = pm;
return pm;
} | [
"function",
"createPerfMeasurement",
"(",
"id",
",",
"name",
")",
"{",
"var",
"pm",
"=",
"new",
"PerfMeasurement",
"(",
"id",
",",
"name",
")",
";",
"exports",
"[",
"id",
"]",
"=",
"pm",
";",
"return",
"pm",
";",
"}"
] | Create a new PerfMeasurement key. Adds itself to the module export.
Can be accessed on the module, e.g. PerfUtils.MY_PERF_KEY.
@param {!string} id Unique ID for this measurement name
@param {!name} name A short name for this measurement | [
"Create",
"a",
"new",
"PerfMeasurement",
"key",
".",
"Adds",
"itself",
"to",
"the",
"module",
"export",
".",
"Can",
"be",
"accessed",
"on",
"the",
"module",
"e",
".",
"g",
".",
"PerfUtils",
".",
"MY_PERF_KEY",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/PerfUtils.js#L103-L108 | train | Create a new PerfMeasurement instance | [
30522,
3853,
3443,
4842,
16715,
5243,
28632,
3672,
1006,
8909,
1010,
2171,
1007,
1063,
13075,
7610,
1027,
2047,
2566,
16715,
5243,
28632,
3672,
1006,
8909,
1010,
2171,
1007,
1025,
14338,
1031,
8909,
1033,
1027,
7610,
1025,
2709,
7610,
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... |
wuchangming/spy-debugger | buildin_modules/weinre/web/interfaces/interfaces.js | setUpShowCheckBox | function setUpShowCheckBox(element, key) {
var value = localStorage.getItem(key)
if (null == value)
value = true
else
value = (value == "true")
element.checked = value
element.storageKey = key
element.addEventListener("click", el_showCheckBoxClicked, false)
} | javascript | function setUpShowCheckBox(element, key) {
var value = localStorage.getItem(key)
if (null == value)
value = true
else
value = (value == "true")
element.checked = value
element.storageKey = key
element.addEventListener("click", el_showCheckBoxClicked, false)
} | [
"function",
"setUpShowCheckBox",
"(",
"element",
",",
"key",
")",
"{",
"var",
"value",
"=",
"localStorage",
".",
"getItem",
"(",
"key",
")",
"if",
"(",
"null",
"==",
"value",
")",
"value",
"=",
"true",
"else",
"value",
"=",
"(",
"value",
"==",
"\"true\... | ----------------------------------------------------------------------------- | [
"-----------------------------------------------------------------------------"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/interfaces/interfaces.js#L67-L78 | train | Set up the show checkbox | [
30522,
3853,
16437,
22231,
16526,
5369,
3600,
8758,
1006,
5783,
1010,
3145,
1007,
1063,
13075,
3643,
1027,
10575,
4263,
4270,
1012,
2131,
4221,
2213,
1006,
3145,
1007,
2065,
1006,
19701,
1027,
1027,
3643,
1007,
3643,
1027,
2995,
2842,
3643,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/json/encodeSummaryPart.js | encodeSummaryPart | function encodeSummaryPart(part) {
return {
title: part.getTitle(),
articles: part.getArticles()
.map(encodeSummaryArticle).toJS()
};
} | javascript | function encodeSummaryPart(part) {
return {
title: part.getTitle(),
articles: part.getArticles()
.map(encodeSummaryArticle).toJS()
};
} | [
"function",
"encodeSummaryPart",
"(",
"part",
")",
"{",
"return",
"{",
"title",
":",
"part",
".",
"getTitle",
"(",
")",
",",
"articles",
":",
"part",
".",
"getArticles",
"(",
")",
".",
"map",
"(",
"encodeSummaryArticle",
")",
".",
"toJS",
"(",
")",
"}"... | Encode a SummaryPart to JSON
@param {SummaryPart}
@return {Object} | [
"Encode",
"a",
"SummaryPart",
"to",
"JSON"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeSummaryPart.js#L9-L15 | train | Encode a summary part | [
30522,
3853,
4372,
23237,
2819,
7849,
22571,
8445,
1006,
2112,
1007,
1063,
2709,
1063,
2516,
1024,
2112,
1012,
2131,
3775,
9286,
1006,
1007,
1010,
4790,
1024,
2112,
1012,
2131,
8445,
20921,
1006,
1007,
1012,
4949,
1006,
4372,
23237,
2819,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/chart/chart.js | calcDSVDelta | function calcDSVDelta(code, delimiter) {
let rows, delta;
try {
csv.COLUMN_SEPARATOR = delimiter;
rows = csv.parse(code);
if (rows[0].length < 2) {
// parsing completely failed
throw new Error('parser fail');
}
// sum of all length difference of all rows
delta = rows.map(row => row.length)
.reduce((a, b) => ({
deltaSum: a.deltaSum + Math.abs(a.length - b),
length: b
}), {
deltaSum: 0,
length: rows[0].length
}).deltaSum;
} catch (e) {
delta = Infinity;
}
return delta;
} | javascript | function calcDSVDelta(code, delimiter) {
let rows, delta;
try {
csv.COLUMN_SEPARATOR = delimiter;
rows = csv.parse(code);
if (rows[0].length < 2) {
// parsing completely failed
throw new Error('parser fail');
}
// sum of all length difference of all rows
delta = rows.map(row => row.length)
.reduce((a, b) => ({
deltaSum: a.deltaSum + Math.abs(a.length - b),
length: b
}), {
deltaSum: 0,
length: rows[0].length
}).deltaSum;
} catch (e) {
delta = Infinity;
}
return delta;
} | [
"function",
"calcDSVDelta",
"(",
"code",
",",
"delimiter",
")",
"{",
"let",
"rows",
",",
"delta",
";",
"try",
"{",
"csv",
".",
"COLUMN_SEPARATOR",
"=",
"delimiter",
";",
"rows",
"=",
"csv",
".",
"parse",
"(",
"code",
")",
";",
"if",
"(",
"rows",
"[",... | calculate delta(sum of length difference of rows) values of given DSV
@param {string} code - code to be test
@param {string|RegExp} delimiter - delimiter to test
@returns {number} delta value for code
@ignore | [
"calculate",
"delta",
"(",
"sum",
"of",
"length",
"difference",
"of",
"rows",
")",
"values",
"of",
"given",
"DSV"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/chart/chart.js#L141-L167 | train | Calculates the delta of the DSV from the given CSV code. | [
30522,
3853,
10250,
19797,
2015,
16872,
20042,
2050,
1006,
3642,
1010,
3972,
27605,
3334,
1007,
1063,
2292,
10281,
1010,
7160,
1025,
3046,
1063,
20116,
2615,
1012,
5930,
1035,
19802,
25879,
2953,
1027,
3972,
27605,
3334,
1025,
10281,
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... |
eslint/eslint | lib/rules/semi.js | checkForSemicolon | function checkForSemicolon(node) {
const isSemi = astUtils.isSemicolonToken(sourceCode.getLastToken(node));
if (never) {
if (isSemi && canRemoveSemicolon(node)) {
report(node, true);
} else if (!isSemi && beforeStatementContinuationChars === "always" && maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
report(node);
}
} else {
const oneLinerBlock = (exceptOneLine && isOneLinerBlock(node));
if (isSemi && oneLinerBlock) {
report(node, true);
} else if (!isSemi && !oneLinerBlock) {
report(node);
}
}
} | javascript | function checkForSemicolon(node) {
const isSemi = astUtils.isSemicolonToken(sourceCode.getLastToken(node));
if (never) {
if (isSemi && canRemoveSemicolon(node)) {
report(node, true);
} else if (!isSemi && beforeStatementContinuationChars === "always" && maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
report(node);
}
} else {
const oneLinerBlock = (exceptOneLine && isOneLinerBlock(node));
if (isSemi && oneLinerBlock) {
report(node, true);
} else if (!isSemi && !oneLinerBlock) {
report(node);
}
}
} | [
"function",
"checkForSemicolon",
"(",
"node",
")",
"{",
"const",
"isSemi",
"=",
"astUtils",
".",
"isSemicolonToken",
"(",
"sourceCode",
".",
"getLastToken",
"(",
"node",
")",
")",
";",
"if",
"(",
"never",
")",
"{",
"if",
"(",
"isSemi",
"&&",
"canRemoveSemi... | Checks a node to see if it's followed by a semicolon.
@param {ASTNode} node The node to check.
@returns {void} | [
"Checks",
"a",
"node",
"to",
"see",
"if",
"it",
"s",
"followed",
"by",
"a",
"semicolon",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/semi.js#L265-L283 | train | Check if a semicolon is present in the source code | [
30522,
3853,
4638,
29278,
3366,
7712,
12898,
2078,
1006,
13045,
1007,
1063,
9530,
3367,
26354,
23238,
1027,
2004,
8525,
3775,
4877,
1012,
26354,
23238,
25778,
12162,
11045,
2078,
1006,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
13045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
LLK/scratch-blocks | blocks_horizontal/wedo.js | function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_slow.svg',
value: 'slow', width: 48, height: 48, alt: 'Slow'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_med.svg',
value: 'medium', width: 48, height: 48, alt: 'Medium'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_fast.svg',
value: 'fast', width: 48, height: 48, alt: 'Fast'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.motion.primary,
Blockly.Colours.motion.secondary,
Blockly.Colours.motion.tertiary
);
} | javascript | function() {
this.appendDummyInput()
.appendField(new Blockly.FieldIconMenu(
[
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_slow.svg',
value: 'slow', width: 48, height: 48, alt: 'Slow'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_med.svg',
value: 'medium', width: 48, height: 48, alt: 'Medium'},
{src: Blockly.mainWorkspace.options.pathToMedia + 'icons/wedo_motor-speed_fast.svg',
value: 'fast', width: 48, height: 48, alt: 'Fast'}
]), 'CHOICE');
this.setOutput(true);
this.setColour(Blockly.Colours.motion.primary,
Blockly.Colours.motion.secondary,
Blockly.Colours.motion.tertiary
);
} | [
"function",
"(",
")",
"{",
"this",
".",
"appendDummyInput",
"(",
")",
".",
"appendField",
"(",
"new",
"Blockly",
".",
"FieldIconMenu",
"(",
"[",
"{",
"src",
":",
"Blockly",
".",
"mainWorkspace",
".",
"options",
".",
"pathToMedia",
"+",
"'icons/wedo_motor-spe... | Block for motor speed drop-down (used for shadow).
@this Blockly.Block | [
"Block",
"for",
"motor",
"speed",
"drop",
"-",
"down",
"(",
"used",
"for",
"shadow",
")",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_horizontal/wedo.js#L175-L191 | train | Block for
onomic motors. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
10439,
10497,
8566,
18879,
2378,
18780,
1006,
1007,
1012,
10439,
10497,
3790,
1006,
2047,
3796,
2135,
1012,
2492,
28524,
3549,
2226,
1006,
1031,
1063,
5034,
2278,
1024,
3796,
2135,
1012,
2364,
9316... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/datepicker/js/calendar.spec.js | findYearElement | function findYearElement(parent, year) {
var node = parent[0] || parent;
var years = node.querySelectorAll('[md-calendar-year-body]');
var yearHeader = year.toString();
var target;
for (var i = 0; i < years.length; i++) {
target = years[i];
if (target.querySelector('.md-calendar-month-label').textContent === yearHeader) {
return target;
}
}
return null;
} | javascript | function findYearElement(parent, year) {
var node = parent[0] || parent;
var years = node.querySelectorAll('[md-calendar-year-body]');
var yearHeader = year.toString();
var target;
for (var i = 0; i < years.length; i++) {
target = years[i];
if (target.querySelector('.md-calendar-month-label').textContent === yearHeader) {
return target;
}
}
return null;
} | [
"function",
"findYearElement",
"(",
"parent",
",",
"year",
")",
"{",
"var",
"node",
"=",
"parent",
"[",
"0",
"]",
"||",
"parent",
";",
"var",
"years",
"=",
"node",
".",
"querySelectorAll",
"(",
"'[md-calendar-year-body]'",
")",
";",
"var",
"yearHeader",
"=... | Find the `tbody` for a year in the calendar. | [
"Find",
"the",
"tbody",
"for",
"a",
"year",
"in",
"the",
"calendar",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/datepicker/js/calendar.spec.js#L74-L87 | train | Find the year element in the specified calendar container | [
30522,
3853,
2424,
29100,
12260,
3672,
1006,
6687,
1010,
2095,
1007,
1063,
13075,
13045,
1027,
6687,
1031,
1014,
1033,
1064,
1064,
6687,
1025,
13075,
2086,
1027,
13045,
30524,
2095,
4974,
2121,
1027,
2095,
1012,
2000,
3367,
4892,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/view/ViewCommandHandlers.js | init | function init() {
currFontFamily = prefs.get("fontFamily");
_addDynamicFontFamily(currFontFamily);
currFontSize = prefs.get("fontSize");
_addDynamicFontSize(currFontSize);
_updateUI();
} | javascript | function init() {
currFontFamily = prefs.get("fontFamily");
_addDynamicFontFamily(currFontFamily);
currFontSize = prefs.get("fontSize");
_addDynamicFontSize(currFontSize);
_updateUI();
} | [
"function",
"init",
"(",
")",
"{",
"currFontFamily",
"=",
"prefs",
".",
"get",
"(",
"\"fontFamily\"",
")",
";",
"_addDynamicFontFamily",
"(",
"currFontFamily",
")",
";",
"currFontSize",
"=",
"prefs",
".",
"get",
"(",
"\"fontSize\"",
")",
";",
"_addDynamicFontS... | Initializes the different settings that need to loaded | [
"Initializes",
"the",
"different",
"settings",
"that",
"need",
"to",
"loaded"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/ViewCommandHandlers.js#L393-L399 | train | Initialize the language | [
30522,
3853,
1999,
4183,
1006,
1007,
1063,
12731,
12171,
14876,
3372,
7011,
4328,
2135,
1027,
3653,
10343,
1012,
2131,
1006,
1000,
15489,
7011,
4328,
2135,
1000,
1007,
1025,
1035,
5587,
5149,
28987,
2278,
14876,
3372,
7011,
4328,
2135,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/editor/Editor.js | _buildPreferencesContext | function _buildPreferencesContext(fullPath) {
return PreferencesManager._buildContext(fullPath,
fullPath ? LanguageManager.getLanguageForPath(fullPath).getId() : undefined);
} | javascript | function _buildPreferencesContext(fullPath) {
return PreferencesManager._buildContext(fullPath,
fullPath ? LanguageManager.getLanguageForPath(fullPath).getId() : undefined);
} | [
"function",
"_buildPreferencesContext",
"(",
"fullPath",
")",
"{",
"return",
"PreferencesManager",
".",
"_buildContext",
"(",
"fullPath",
",",
"fullPath",
"?",
"LanguageManager",
".",
"getLanguageForPath",
"(",
"fullPath",
")",
".",
"getId",
"(",
")",
":",
"undefi... | Helper function to build preferences context based on the full path of
the file.
@param {string} fullPath Full path of the file
@return {*} A context for the specified file name | [
"Helper",
"function",
"to",
"build",
"preferences",
"context",
"based",
"on",
"the",
"full",
"path",
"of",
"the",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/Editor.js#L292-L295 | train | Build preferences context for the given file | [
30522,
3853,
1035,
3857,
28139,
25523,
9363,
10111,
18413,
1006,
2440,
15069,
1007,
1063,
2709,
18394,
24805,
4590,
1012,
1035,
3857,
8663,
18209,
1006,
2440,
15069,
1010,
2440,
15069,
1029,
2653,
24805,
4590,
1012,
2131,
25023,
6692,
3351,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 (orig, response) {
if (!orig.id) {
console.log("[Brackets LiveDev] Trying to send a response for a message with no ID");
return;
}
response.id = orig.id;
this.send(response);
} | javascript | function (orig, response) {
if (!orig.id) {
console.log("[Brackets LiveDev] Trying to send a response for a message with no ID");
return;
}
response.id = orig.id;
this.send(response);
} | [
"function",
"(",
"orig",
",",
"response",
")",
"{",
"if",
"(",
"!",
"orig",
".",
"id",
")",
"{",
"console",
".",
"log",
"(",
"\"[Brackets LiveDev] Trying to send a response for a message with no ID\"",
")",
";",
"return",
";",
"}",
"response",
".",
"id",
"=",
... | Send a response of a particular message to the Editor.
Original message must provide an 'id' property
@param {Object} orig Original message.
@param {Object} response Message to be sent as the response. | [
"Send",
"a",
"response",
"of",
"a",
"particular",
"message",
"to",
"the",
"Editor",
".",
"Original",
"message",
"must",
"provide",
"an",
"id",
"property"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/remote/LiveDevProtocolRemote.js#L98-L105 | train | send a response | [
30522,
3853,
1006,
2030,
8004,
1010,
3433,
1007,
1063,
2065,
1006,
999,
2030,
8004,
1012,
8909,
1007,
1063,
10122,
1012,
8833,
1006,
1000,
1031,
19719,
2973,
6777,
1033,
2667,
2000,
4604,
1037,
3433,
2005,
1037,
4471,
2007,
2053,
8909,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/no-useless-escape.js | report | function report(node, startOffset, character) {
context.report({
node,
loc: sourceCode.getLocFromIndex(sourceCode.getIndexFromLoc(node.loc.start) + startOffset),
message: "Unnecessary escape character: \\{{character}}.",
data: { character }
});
} | javascript | function report(node, startOffset, character) {
context.report({
node,
loc: sourceCode.getLocFromIndex(sourceCode.getIndexFromLoc(node.loc.start) + startOffset),
message: "Unnecessary escape character: \\{{character}}.",
data: { character }
});
} | [
"function",
"report",
"(",
"node",
",",
"startOffset",
",",
"character",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"loc",
":",
"sourceCode",
".",
"getLocFromIndex",
"(",
"sourceCode",
".",
"getIndexFromLoc",
"(",
"node",
".",
"loc",
".",
... | Reports a node
@param {ASTNode} node The node to report
@param {number} startOffset The backslash's offset from the start of the node
@param {string} character The uselessly escaped character (not including the backslash)
@returns {void} | [
"Reports",
"a",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-useless-escape.js#L104-L111 | train | Reports an unclosed escape character in a node. | [
30522,
3853,
3189,
1006,
13045,
1010,
2707,
27475,
3388,
1010,
2839,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
8840,
2278,
1024,
3120,
16044,
1012,
2131,
4135,
2278,
19699,
20936,
13629,
2595,
1006,
3120,
16044,
1012,
2131,
222... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
radare/radare2 | shlr/www/graph/js-graph-it.js | Segment | function Segment(id, parentElement)
{
this.id = id;
this.htmlElement = document.createElement('div');
this.htmlElement.id = id;
this.htmlElement.style.position = 'absolute';
this.htmlElement.style.overflow = 'hidden';
parentElement.appendChild(this.htmlElement);
this.startX;
this.startY;
this.length;
this.thickness;
this.orientation;
this.nextSegment;
this.visible = true;
/**
* draw the segment. This operation is cascaded to next segment if any.
*/
this.draw = function()
{
// set properties to next segment
if(this.nextSegment)
{
this.nextSegment.startX = this.getEndX();
this.nextSegment.startY = this.getEndY();
}
this.htmlElement.style.display = this.visible?'block':'none';
switch (this.orientation) {
case LEFT:
this.htmlElement.style.left = (this.startX - this.length) + "px";
this.htmlElement.style.top = this.startY + "px";
this.htmlElement.style.width = this.length + "px";
this.htmlElement.style.height = this.thickness + "px";
break;
case RIGHT:
this.htmlElement.style.left = this.startX + "px";
this.htmlElement.style.top = this.startY + "px";
if(this.nextSegment)
this.htmlElement.style.width = this.length + this.thickness + "px";
else
this.htmlElement.style.width = this.length + "px";
this.htmlElement.style.height = this.thickness + "px";
break;
case UP:
this.htmlElement.style.left = this.startX + "px";
this.htmlElement.style.top = (this.startY - this.length) + "px";
this.htmlElement.style.width = this.thickness + "px";
this.htmlElement.style.height = this.length + "px";
break;
case DOWN:
this.htmlElement.style.left = this.startX + "px";
this.htmlElement.style.top = this.startY + "px";
this.htmlElement.style.width = this.thickness + "px";
if(this.nextSegment)
this.htmlElement.style.height = this.length + this.thickness + "px";
else
this.htmlElement.style.height = this.length + "px";
break;
}
if(this.nextSegment)
this.nextSegment.draw();
}
/**
* Returns the "left" coordinate of the end point of this segment
*/
this.getEndX = function()
{
switch(this.orientation)
{
case LEFT: return this.startX - this.length;
case RIGHT: return this.startX + this.length;
case DOWN: return this.startX;
case UP: return this.startX;
}
}
/**
* Returns the "top" coordinate of the end point of this segment
*/
this.getEndY = function() {
switch (this.orientation) {
case LEFT: return this.startY;
case RIGHT: return this.startY;
case DOWN: return this.startY + this.length;
case UP: return this.startY - this.length;
}
}
/**
* Append another segment to the end point of this.
* If another segment is already appended to this, cascades the operation so
* the given next segment will be appended to the tail of the segments chain.
*/
this.append = function(nextSegment) {
if(!nextSegment)
return;
if(!this.nextSegment) {
this.nextSegment = nextSegment;
this.nextSegment.startX = this.getEndX();
this.nextSegment.startY = this.getEndY();
} else this.nextSegment.append(nextSegment);
}
this.detach = function() {
var s = this.nextSegment;
this.nextSegment = null;
return s;
}
/**
* hides this segment and all the following
*/
this.cascadeHide = function() {
this.visible = false;
if(this.nextSegment)
this.nextSegment.cascadeHide();
}
} | javascript | function Segment(id, parentElement)
{
this.id = id;
this.htmlElement = document.createElement('div');
this.htmlElement.id = id;
this.htmlElement.style.position = 'absolute';
this.htmlElement.style.overflow = 'hidden';
parentElement.appendChild(this.htmlElement);
this.startX;
this.startY;
this.length;
this.thickness;
this.orientation;
this.nextSegment;
this.visible = true;
/**
* draw the segment. This operation is cascaded to next segment if any.
*/
this.draw = function()
{
// set properties to next segment
if(this.nextSegment)
{
this.nextSegment.startX = this.getEndX();
this.nextSegment.startY = this.getEndY();
}
this.htmlElement.style.display = this.visible?'block':'none';
switch (this.orientation) {
case LEFT:
this.htmlElement.style.left = (this.startX - this.length) + "px";
this.htmlElement.style.top = this.startY + "px";
this.htmlElement.style.width = this.length + "px";
this.htmlElement.style.height = this.thickness + "px";
break;
case RIGHT:
this.htmlElement.style.left = this.startX + "px";
this.htmlElement.style.top = this.startY + "px";
if(this.nextSegment)
this.htmlElement.style.width = this.length + this.thickness + "px";
else
this.htmlElement.style.width = this.length + "px";
this.htmlElement.style.height = this.thickness + "px";
break;
case UP:
this.htmlElement.style.left = this.startX + "px";
this.htmlElement.style.top = (this.startY - this.length) + "px";
this.htmlElement.style.width = this.thickness + "px";
this.htmlElement.style.height = this.length + "px";
break;
case DOWN:
this.htmlElement.style.left = this.startX + "px";
this.htmlElement.style.top = this.startY + "px";
this.htmlElement.style.width = this.thickness + "px";
if(this.nextSegment)
this.htmlElement.style.height = this.length + this.thickness + "px";
else
this.htmlElement.style.height = this.length + "px";
break;
}
if(this.nextSegment)
this.nextSegment.draw();
}
/**
* Returns the "left" coordinate of the end point of this segment
*/
this.getEndX = function()
{
switch(this.orientation)
{
case LEFT: return this.startX - this.length;
case RIGHT: return this.startX + this.length;
case DOWN: return this.startX;
case UP: return this.startX;
}
}
/**
* Returns the "top" coordinate of the end point of this segment
*/
this.getEndY = function() {
switch (this.orientation) {
case LEFT: return this.startY;
case RIGHT: return this.startY;
case DOWN: return this.startY + this.length;
case UP: return this.startY - this.length;
}
}
/**
* Append another segment to the end point of this.
* If another segment is already appended to this, cascades the operation so
* the given next segment will be appended to the tail of the segments chain.
*/
this.append = function(nextSegment) {
if(!nextSegment)
return;
if(!this.nextSegment) {
this.nextSegment = nextSegment;
this.nextSegment.startX = this.getEndX();
this.nextSegment.startY = this.getEndY();
} else this.nextSegment.append(nextSegment);
}
this.detach = function() {
var s = this.nextSegment;
this.nextSegment = null;
return s;
}
/**
* hides this segment and all the following
*/
this.cascadeHide = function() {
this.visible = false;
if(this.nextSegment)
this.nextSegment.cascadeHide();
}
} | [
"function",
"Segment",
"(",
"id",
",",
"parentElement",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"htmlElement",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"this",
".",
"htmlElement",
".",
"id",
"=",
"id",
";",
"th... | This class represents a connector segment, it is drawn via a div element.
A segment has a starting point defined by the properties startX and startY, a length,
a thickness and an orientation.
Allowed values for the orientation property are defined by the constants UP, LEFT, DOWN and RIGHT. | [
"This",
"class",
"represents",
"a",
"connector",
"segment",
"it",
"is",
"drawn",
"via",
"a",
"div",
"element",
".",
"A",
"segment",
"has",
"a",
"starting",
"point",
"defined",
"by",
"the",
"properties",
"startX",
"and",
"startY",
"a",
"length",
"a",
"thick... | bf5e3028810a0ec7c267c6fe4bfad639b4819e35 | https://github.com/radare/radare2/blob/bf5e3028810a0ec7c267c6fe4bfad639b4819e35/shlr/www/graph/js-graph-it.js#L513-L636 | train | This class is the base class for the segment | [
30522,
3853,
6903,
1006,
8909,
1010,
6687,
12260,
3672,
1007,
1063,
2023,
1012,
8909,
1027,
8909,
1025,
2023,
1012,
16129,
12260,
3672,
1027,
6254,
1012,
3443,
12260,
3672,
1006,
1005,
4487,
2615,
1005,
1007,
1025,
2023,
1012,
16129,
12260,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc | examples/node/dynamic_codegen/route_guide/route_guide_server.js | routeChat | function routeChat(call) {
call.on('data', function(note) {
var key = pointKey(note.location);
/* For each note sent, respond with all previous notes that correspond to
* the same point */
if (route_notes.hasOwnProperty(key)) {
_.each(route_notes[key], function(note) {
call.write(note);
});
} else {
route_notes[key] = [];
}
// Then add the new note to the list
route_notes[key].push(JSON.parse(JSON.stringify(note)));
});
call.on('end', function() {
call.end();
});
} | javascript | function routeChat(call) {
call.on('data', function(note) {
var key = pointKey(note.location);
/* For each note sent, respond with all previous notes that correspond to
* the same point */
if (route_notes.hasOwnProperty(key)) {
_.each(route_notes[key], function(note) {
call.write(note);
});
} else {
route_notes[key] = [];
}
// Then add the new note to the list
route_notes[key].push(JSON.parse(JSON.stringify(note)));
});
call.on('end', function() {
call.end();
});
} | [
"function",
"routeChat",
"(",
"call",
")",
"{",
"call",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"note",
")",
"{",
"var",
"key",
"=",
"pointKey",
"(",
"note",
".",
"location",
")",
";",
"/* For each note sent, respond with all previous notes that correspo... | routeChat handler. Receives a stream of message/location pairs, and responds
with a stream of all previous messages at each of those locations.
@param {Duplex} call The stream for incoming and outgoing messages | [
"routeChat",
"handler",
".",
"Receives",
"a",
"stream",
"of",
"message",
"/",
"location",
"pairs",
"and",
"responds",
"with",
"a",
"stream",
"of",
"all",
"previous",
"messages",
"at",
"each",
"of",
"those",
"locations",
"."
] | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/dynamic_codegen/route_guide/route_guide_server.js#L194-L212 | train | routeChat - Sends a note to the specified call | [
30522,
3853,
2799,
7507,
2102,
1006,
2655,
1007,
1063,
2655,
1012,
2006,
1006,
1005,
2951,
1005,
1010,
3853,
1006,
3602,
1007,
1063,
13075,
3145,
1027,
2391,
14839,
1006,
3602,
1012,
3295,
1007,
1025,
1013,
1008,
2005,
2169,
3602,
2741,
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... |
babel/babel | packages/babel-traverse/src/path/evaluation.js | evaluateCached | function evaluateCached(path, state) {
const { node } = path;
const { seen } = state;
if (seen.has(node)) {
const existing = seen.get(node);
if (existing.resolved) {
return existing.value;
} else {
deopt(path, state);
return;
}
} else {
const item = { resolved: false };
seen.set(node, item);
const val = _evaluate(path, state);
if (state.confident) {
item.resolved = true;
item.value = val;
}
return val;
}
} | javascript | function evaluateCached(path, state) {
const { node } = path;
const { seen } = state;
if (seen.has(node)) {
const existing = seen.get(node);
if (existing.resolved) {
return existing.value;
} else {
deopt(path, state);
return;
}
} else {
const item = { resolved: false };
seen.set(node, item);
const val = _evaluate(path, state);
if (state.confident) {
item.resolved = true;
item.value = val;
}
return val;
}
} | [
"function",
"evaluateCached",
"(",
"path",
",",
"state",
")",
"{",
"const",
"{",
"node",
"}",
"=",
"path",
";",
"const",
"{",
"seen",
"}",
"=",
"state",
";",
"if",
"(",
"seen",
".",
"has",
"(",
"node",
")",
")",
"{",
"const",
"existing",
"=",
"se... | We wrap the _evaluate method so we can track `seen` nodes, we push an item
to the map before we actually evaluate it so we can deopt on self recursive
nodes such as:
var g = a ? 1 : 2,
a = g * this.foo | [
"We",
"wrap",
"the",
"_evaluate",
"method",
"so",
"we",
"can",
"track",
"seen",
"nodes",
"we",
"push",
"an",
"item",
"to",
"the",
"map",
"before",
"we",
"actually",
"evaluate",
"it",
"so",
"we",
"can",
"deopt",
"on",
"self",
"recursive",
"nodes",
"such",... | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-traverse/src/path/evaluation.js#L48-L71 | train | evaluate cached value | [
30522,
3853,
16157,
3540,
7690,
1006,
4130,
1010,
2110,
1007,
1063,
9530,
3367,
1063,
13045,
1065,
1027,
4130,
1025,
9530,
3367,
1063,
2464,
1065,
1027,
2110,
1025,
2065,
1006,
2464,
1012,
2038,
1006,
13045,
1007,
1007,
1063,
9530,
3367,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js | function(oList, iWidth){
iWidth = ExactAttribute._checkWidth(iWidth);
var sPos = oList._bRTL ? "right" : "left";
oList._iCurrentWidth = iWidth;
oList._getAtt()._setWidth(oList._iCurrentWidth);
oList.$("lst").css("width", iWidth + "px");
oList.$("rsz").css(sPos, (iWidth - 4) + "px");
if (oList._isTop()) {
if (!isTopHidden(oList)) {
oList.$("head").css("width", iWidth + "px");
oList.$("cntnt").css(sPos, (iWidth + 8) + "px");
oList.$("scroll").css(sPos, (iWidth + 8) + "px");
}
} else {
if (!oList.$().hasClass("sapUiUx3ExactLstCollapsed")) {
oList.$("cntnt").css("margin-" + sPos, iWidth + "px");
}
}
} | javascript | function(oList, iWidth){
iWidth = ExactAttribute._checkWidth(iWidth);
var sPos = oList._bRTL ? "right" : "left";
oList._iCurrentWidth = iWidth;
oList._getAtt()._setWidth(oList._iCurrentWidth);
oList.$("lst").css("width", iWidth + "px");
oList.$("rsz").css(sPos, (iWidth - 4) + "px");
if (oList._isTop()) {
if (!isTopHidden(oList)) {
oList.$("head").css("width", iWidth + "px");
oList.$("cntnt").css(sPos, (iWidth + 8) + "px");
oList.$("scroll").css(sPos, (iWidth + 8) + "px");
}
} else {
if (!oList.$().hasClass("sapUiUx3ExactLstCollapsed")) {
oList.$("cntnt").css("margin-" + sPos, iWidth + "px");
}
}
} | [
"function",
"(",
"oList",
",",
"iWidth",
")",
"{",
"iWidth",
"=",
"ExactAttribute",
".",
"_checkWidth",
"(",
"iWidth",
")",
";",
"var",
"sPos",
"=",
"oList",
".",
"_bRTL",
"?",
"\"right\"",
":",
"\"left\"",
";",
"oList",
".",
"_iCurrentWidth",
"=",
"iWid... | Sets the width of the list to the given width (maybe the width is adapted to the allowed range (@see checkWidth)) | [
"Sets",
"the",
"width",
"of",
"the",
"list",
"to",
"the",
"given",
"width",
"(",
"maybe",
"the",
"width",
"is",
"adapted",
"to",
"the",
"allowed",
"range",
"("
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/ExactList.js#L1191-L1209 | train | Sets the width of the ExactList | [
30522,
3853,
1006,
19330,
2923,
1010,
1045,
9148,
11927,
2232,
1007,
1063,
1045,
9148,
11927,
2232,
1027,
6635,
19321,
3089,
8569,
2618,
1012,
1035,
4638,
9148,
11927,
2232,
1006,
1045,
9148,
11927,
2232,
1007,
1025,
13075,
11867,
2891,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/rest-spread-spacing.js | checkWhiteSpace | function checkWhiteSpace(node) {
const operator = sourceCode.getFirstToken(node),
nextToken = sourceCode.getTokenAfter(operator),
hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken);
let type;
switch (node.type) {
case "SpreadElement":
type = "spread";
if (node.parent.type === "ObjectExpression") {
type += " property";
}
break;
case "RestElement":
type = "rest";
if (node.parent.type === "ObjectPattern") {
type += " property";
}
break;
case "ExperimentalSpreadProperty":
type = "spread property";
break;
case "ExperimentalRestProperty":
type = "rest property";
break;
default:
return;
}
if (alwaysSpace && !hasWhitespace) {
context.report({
node,
loc: {
line: operator.loc.end.line,
column: operator.loc.end.column
},
message: "Expected whitespace after {{type}} operator.",
data: {
type
},
fix(fixer) {
return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
}
});
} else if (!alwaysSpace && hasWhitespace) {
context.report({
node,
loc: {
line: operator.loc.end.line,
column: operator.loc.end.column
},
message: "Unexpected whitespace after {{type}} operator.",
data: {
type
},
fix(fixer) {
return fixer.removeRange([operator.range[1], nextToken.range[0]]);
}
});
}
} | javascript | function checkWhiteSpace(node) {
const operator = sourceCode.getFirstToken(node),
nextToken = sourceCode.getTokenAfter(operator),
hasWhitespace = sourceCode.isSpaceBetweenTokens(operator, nextToken);
let type;
switch (node.type) {
case "SpreadElement":
type = "spread";
if (node.parent.type === "ObjectExpression") {
type += " property";
}
break;
case "RestElement":
type = "rest";
if (node.parent.type === "ObjectPattern") {
type += " property";
}
break;
case "ExperimentalSpreadProperty":
type = "spread property";
break;
case "ExperimentalRestProperty":
type = "rest property";
break;
default:
return;
}
if (alwaysSpace && !hasWhitespace) {
context.report({
node,
loc: {
line: operator.loc.end.line,
column: operator.loc.end.column
},
message: "Expected whitespace after {{type}} operator.",
data: {
type
},
fix(fixer) {
return fixer.replaceTextRange([operator.range[1], nextToken.range[0]], " ");
}
});
} else if (!alwaysSpace && hasWhitespace) {
context.report({
node,
loc: {
line: operator.loc.end.line,
column: operator.loc.end.column
},
message: "Unexpected whitespace after {{type}} operator.",
data: {
type
},
fix(fixer) {
return fixer.removeRange([operator.range[1], nextToken.range[0]]);
}
});
}
} | [
"function",
"checkWhiteSpace",
"(",
"node",
")",
"{",
"const",
"operator",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
")",
",",
"nextToken",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"operator",
")",
",",
"hasWhitespace",
"=",
"sourceCode",
".",... | -------------------------------------------------------------------------- Helpers --------------------------------------------------------------------------
Checks whitespace between rest/spread operators and their expressions
@param {ASTNode} node - The node to check
@returns {void} | [
"--------------------------------------------------------------------------",
"Helpers",
"--------------------------------------------------------------------------",
"Checks",
"whitespace",
"between",
"rest",
"/",
"spread",
"operators",
"and",
"their",
"expressions"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/rest-spread-spacing.js#L45-L105 | train | Check if whitespace is present in operator | [
30522,
3853,
4638,
2860,
16584,
2229,
15327,
1006,
13045,
1007,
1063,
9530,
3367,
6872,
1027,
3120,
16044,
1012,
2131,
8873,
12096,
18715,
2368,
1006,
13045,
1007,
1010,
2279,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
18715,
8189,
6199,
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... |
ColorlibHQ/AdminLTE | bower_components/jquery-sparkline/src/vcanvas-base.js | function (shapetype, shapeargs) {
var id = shapeCount++;
shapeargs.unshift(id);
return new VShape(this, id, shapetype, shapeargs);
} | javascript | function (shapetype, shapeargs) {
var id = shapeCount++;
shapeargs.unshift(id);
return new VShape(this, id, shapetype, shapeargs);
} | [
"function",
"(",
"shapetype",
",",
"shapeargs",
")",
"{",
"var",
"id",
"=",
"shapeCount",
"++",
";",
"shapeargs",
".",
"unshift",
"(",
"id",
")",
";",
"return",
"new",
"VShape",
"(",
"this",
",",
"id",
",",
"shapetype",
",",
"shapeargs",
")",
";",
"}... | Generate a shape object and id for later rendering | [
"Generate",
"a",
"shape",
"object",
"and",
"id",
"for",
"later",
"rendering"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/bower_components/jquery-sparkline/src/vcanvas-base.js#L99-L103 | train | Create a new VShape | [
30522,
3853,
1006,
4338,
13874,
1010,
4338,
2906,
5620,
1007,
1063,
13075,
8909,
1027,
4338,
3597,
16671,
1009,
1009,
1025,
4338,
2906,
5620,
1012,
4895,
6182,
6199,
1006,
8909,
1007,
1025,
2709,
2047,
5443,
3270,
5051,
1006,
2023,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
netlify/netlify-cms | packages/netlify-cms-core/src/lib/stringTemplate.js | getExplicitFieldReplacement | function getExplicitFieldReplacement(key, data) {
if (!key.startsWith(FIELD_PREFIX)) {
return;
}
const fieldName = key.substring(FIELD_PREFIX.length);
return data.get(fieldName, '');
} | javascript | function getExplicitFieldReplacement(key, data) {
if (!key.startsWith(FIELD_PREFIX)) {
return;
}
const fieldName = key.substring(FIELD_PREFIX.length);
return data.get(fieldName, '');
} | [
"function",
"getExplicitFieldReplacement",
"(",
"key",
",",
"data",
")",
"{",
"if",
"(",
"!",
"key",
".",
"startsWith",
"(",
"FIELD_PREFIX",
")",
")",
"{",
"return",
";",
"}",
"const",
"fieldName",
"=",
"key",
".",
"substring",
"(",
"FIELD_PREFIX",
".",
... | Allow `fields.` prefix in placeholder to override built in replacements like "slug" and "year" with values from fields of the same name. | [
"Allow",
"fields",
".",
"prefix",
"in",
"placeholder",
"to",
"override",
"built",
"in",
"replacements",
"like",
"slug",
"and",
"year",
"with",
"values",
"from",
"fields",
"of",
"the",
"same",
"name",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-core/src/lib/stringTemplate.js#L26-L32 | train | Get the replacement for a field | [
30522,
3853,
2131,
10288,
24759,
28775,
24475,
12891,
2890,
24759,
10732,
3672,
1006,
3145,
1010,
2951,
1007,
1063,
2065,
1006,
999,
3145,
1012,
4627,
24415,
1006,
2492,
1035,
17576,
1007,
1007,
1063,
2709,
1025,
1065,
9530,
3367,
2492,
184... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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-eval.js | isConstant | function isConstant(node, name) {
switch (node.type) {
case "Literal":
return node.value === name;
case "TemplateLiteral":
return (
node.expressions.length === 0 &&
node.quasis[0].value.cooked === name
);
default:
return false;
}
} | javascript | function isConstant(node, name) {
switch (node.type) {
case "Literal":
return node.value === name;
case "TemplateLiteral":
return (
node.expressions.length === 0 &&
node.quasis[0].value.cooked === name
);
default:
return false;
}
} | [
"function",
"isConstant",
"(",
"node",
",",
"name",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"\"Literal\"",
":",
"return",
"node",
".",
"value",
"===",
"name",
";",
"case",
"\"TemplateLiteral\"",
":",
"return",
"(",
"node",
".",
... | Checks a given node is a Literal node of the specified string value.
@param {ASTNode} node - A node to check.
@param {string} name - A name to check.
@returns {boolean} `true` if the node is a Literal node of the name. | [
"Checks",
"a",
"given",
"node",
"is",
"a",
"Literal",
"node",
"of",
"the",
"specified",
"string",
"value",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-eval.js#L41-L55 | train | Check if a node is constant | [
30522,
3853,
2003,
8663,
12693,
2102,
1006,
13045,
1010,
2171,
1007,
1063,
6942,
1006,
13045,
1012,
2828,
1007,
1063,
2553,
1000,
18204,
1000,
1024,
2709,
13045,
1012,
3643,
1027,
1027,
1027,
2171,
1025,
2553,
1000,
23561,
22779,
7941,
1000... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/MenuBar.js | function(oThis){
var iVisibleItems = 0;
var jAreaRef = oThis.$("area");
var jItems = jAreaRef.children();
var bRtl = sap.ui.getCore().getConfiguration().getRTL();
var lastOffsetLeft = (bRtl ? 100000 : 0);
jItems.each(function(iIdx) {
if (iIdx == 0) {
return true;
}
var currentOffsetLeft = this.offsetLeft;
var bLineBreak = (bRtl ? (currentOffsetLeft >= lastOffsetLeft) : (currentOffsetLeft <= lastOffsetLeft));
if (bLineBreak) {
iVisibleItems = iIdx;
return false;
} else if (jQuery(this).attr("id") == oThis.getId() + "-ovrflw") {
// This is the overflow button, there was no line break
iVisibleItems = iIdx;
return false;
} else {
// Regular item, to the right of the last one, so just proceed
lastOffsetLeft = currentOffsetLeft;
return true;
}
});
return iVisibleItems;
} | javascript | function(oThis){
var iVisibleItems = 0;
var jAreaRef = oThis.$("area");
var jItems = jAreaRef.children();
var bRtl = sap.ui.getCore().getConfiguration().getRTL();
var lastOffsetLeft = (bRtl ? 100000 : 0);
jItems.each(function(iIdx) {
if (iIdx == 0) {
return true;
}
var currentOffsetLeft = this.offsetLeft;
var bLineBreak = (bRtl ? (currentOffsetLeft >= lastOffsetLeft) : (currentOffsetLeft <= lastOffsetLeft));
if (bLineBreak) {
iVisibleItems = iIdx;
return false;
} else if (jQuery(this).attr("id") == oThis.getId() + "-ovrflw") {
// This is the overflow button, there was no line break
iVisibleItems = iIdx;
return false;
} else {
// Regular item, to the right of the last one, so just proceed
lastOffsetLeft = currentOffsetLeft;
return true;
}
});
return iVisibleItems;
} | [
"function",
"(",
"oThis",
")",
"{",
"var",
"iVisibleItems",
"=",
"0",
";",
"var",
"jAreaRef",
"=",
"oThis",
".",
"$",
"(",
"\"area\"",
")",
";",
"var",
"jItems",
"=",
"jAreaRef",
".",
"children",
"(",
")",
";",
"var",
"bRtl",
"=",
"sap",
".",
"ui",... | Compute actual number of items currently hidden due to overflow | [
"Compute",
"actual",
"number",
"of",
"items",
"currently",
"hidden",
"due",
"to",
"overflow"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/MenuBar.js#L446-L478 | train | Returns true if the item is visible | [
30522,
3853,
1006,
27178,
24158,
1007,
1063,
13075,
4921,
17417,
3468,
4221,
5244,
1027,
1014,
1025,
13075,
15723,
14644,
12879,
1027,
27178,
24158,
1012,
1002,
1006,
1000,
2181,
1000,
1007,
1025,
13075,
10147,
18532,
2015,
1027,
15723,
14644... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/cldr/extract.js | getDayPeriods | function getDayPeriods(localeData, dayPeriodsList) {
const dayPeriods = localeData.main(`dates/calendars/gregorian/dayPeriods`);
const result = {};
// cleaning up unused keys
Object.keys(dayPeriods).forEach(key1 => { // format / stand-alone
result[key1] = {};
Object.keys(dayPeriods[key1]).forEach(key2 => { // narrow / abbreviated / wide
result[key1][key2] = {};
Object.keys(dayPeriods[key1][key2]).forEach(key3 => {
if (dayPeriodsList.indexOf(key3) !== -1) {
result[key1][key2][key3] = dayPeriods[key1][key2][key3];
}
});
});
});
return result;
} | javascript | function getDayPeriods(localeData, dayPeriodsList) {
const dayPeriods = localeData.main(`dates/calendars/gregorian/dayPeriods`);
const result = {};
// cleaning up unused keys
Object.keys(dayPeriods).forEach(key1 => { // format / stand-alone
result[key1] = {};
Object.keys(dayPeriods[key1]).forEach(key2 => { // narrow / abbreviated / wide
result[key1][key2] = {};
Object.keys(dayPeriods[key1][key2]).forEach(key3 => {
if (dayPeriodsList.indexOf(key3) !== -1) {
result[key1][key2][key3] = dayPeriods[key1][key2][key3];
}
});
});
});
return result;
} | [
"function",
"getDayPeriods",
"(",
"localeData",
",",
"dayPeriodsList",
")",
"{",
"const",
"dayPeriods",
"=",
"localeData",
".",
"main",
"(",
"`",
"`",
")",
";",
"const",
"result",
"=",
"{",
"}",
";",
"// cleaning up unused keys",
"Object",
".",
"keys",
"(",
... | Returns data for the chosen day periods
@returns {format: {narrow / abbreviated / wide: [...]}, stand-alone: {narrow / abbreviated / wide: [...]}} | [
"Returns",
"data",
"for",
"the",
"chosen",
"day",
"periods"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/tools/gulp-tasks/cldr/extract.js#L245-L262 | train | Get day periods from a locale | [
30522,
3853,
2131,
10259,
4842,
3695,
5104,
1006,
2334,
11960,
2696,
1010,
2154,
4842,
3695,
5104,
9863,
1007,
1063,
9530,
3367,
2154,
4842,
3695,
5104,
1027,
2334,
11960,
2696,
1012,
2364,
1006,
1036,
5246,
1013,
8094,
2015,
1013,
25847,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getsentry/sentry-javascript | packages/raven-js/src/raven.js | function(breadcrumbs) {
// known breadcrumb properties with urls
// TODO: also consider arbitrary prop values that start with (https?)?://
var urlProps = ['to', 'from', 'url'],
urlProp,
crumb,
data;
for (var i = 0; i < breadcrumbs.values.length; ++i) {
crumb = breadcrumbs.values[i];
if (
!crumb.hasOwnProperty('data') ||
!isObject(crumb.data) ||
objectFrozen(crumb.data)
)
continue;
data = objectMerge({}, crumb.data);
for (var j = 0; j < urlProps.length; ++j) {
urlProp = urlProps[j];
if (data.hasOwnProperty(urlProp) && data[urlProp]) {
data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);
}
}
breadcrumbs.values[i].data = data;
}
} | javascript | function(breadcrumbs) {
// known breadcrumb properties with urls
// TODO: also consider arbitrary prop values that start with (https?)?://
var urlProps = ['to', 'from', 'url'],
urlProp,
crumb,
data;
for (var i = 0; i < breadcrumbs.values.length; ++i) {
crumb = breadcrumbs.values[i];
if (
!crumb.hasOwnProperty('data') ||
!isObject(crumb.data) ||
objectFrozen(crumb.data)
)
continue;
data = objectMerge({}, crumb.data);
for (var j = 0; j < urlProps.length; ++j) {
urlProp = urlProps[j];
if (data.hasOwnProperty(urlProp) && data[urlProp]) {
data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);
}
}
breadcrumbs.values[i].data = data;
}
} | [
"function",
"(",
"breadcrumbs",
")",
"{",
"// known breadcrumb properties with urls",
"// TODO: also consider arbitrary prop values that start with (https?)?://",
"var",
"urlProps",
"=",
"[",
"'to'",
",",
"'from'",
",",
"'url'",
"]",
",",
"urlProp",
",",
"crumb",
",",
"da... | Truncate breadcrumb values (right now just URLs) | [
"Truncate",
"breadcrumb",
"values",
"(",
"right",
"now",
"just",
"URLs",
")"
] | a872223343fecf7364473b78bede937f1eb57bd0 | https://github.com/getsentry/sentry-javascript/blob/a872223343fecf7364473b78bede937f1eb57bd0/packages/raven-js/src/raven.js#L1839-L1865 | train | Merge breadcrumbs with urls | [
30522,
3853,
1006,
7852,
26775,
25438,
2015,
1007,
1063,
1013,
1013,
2124,
7852,
26775,
25438,
5144,
2007,
24471,
4877,
1013,
1013,
28681,
2080,
1024,
2036,
5136,
15275,
17678,
5300,
2008,
2707,
2007,
1006,
16770,
1029,
1007,
1029,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Dogfalo/materialize | dist/js/materialize.js | destroy | function destroy() {
this._removeEventHandlers();
this.el.M_Materialbox = undefined;
// Unwrap image
$(this.placeholder).after(this.el).remove();
this.$el.removeAttr('style');
} | javascript | function destroy() {
this._removeEventHandlers();
this.el.M_Materialbox = undefined;
// Unwrap image
$(this.placeholder).after(this.el).remove();
this.$el.removeAttr('style');
} | [
"function",
"destroy",
"(",
")",
"{",
"this",
".",
"_removeEventHandlers",
"(",
")",
";",
"this",
".",
"el",
".",
"M_Materialbox",
"=",
"undefined",
";",
"// Unwrap image",
"$",
"(",
"this",
".",
"placeholder",
")",
".",
"after",
"(",
"this",
".",
"el",
... | Teardown component | [
"Teardown",
"component"
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/dist/js/materialize.js#L3369-L3377 | train | Destroys the materialbox | [
30522,
3853,
6033,
1006,
1007,
1063,
2023,
1012,
1035,
6366,
18697,
3372,
11774,
12910,
1006,
1007,
1025,
2023,
1012,
3449,
1012,
1049,
1035,
3430,
8758,
1027,
6151,
28344,
1025,
1013,
1013,
4895,
13088,
9331,
3746,
1002,
1006,
2023,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/wysiwygCommands/tableAlignCol.js | getSelectionInformation | function getSelectionInformation($table, rangeInformation) {
const columnLength = $table.find('tr').eq(0).find('td,th').length;
const {
from,
to
} = rangeInformation;
let startColumnIndex, endColumnIndex, isDivided;
if (from.row === to.row) {
startColumnIndex = from.cell;
endColumnIndex = to.cell;
} else if (from.row < to.row) {
if (from.cell <= to.cell) {
startColumnIndex = 0;
endColumnIndex = columnLength - 1;
} else {
startColumnIndex = from.cell;
endColumnIndex = to.cell;
isDivided = true;
}
}
return {
startColumnIndex,
endColumnIndex,
isDivided
};
} | javascript | function getSelectionInformation($table, rangeInformation) {
const columnLength = $table.find('tr').eq(0).find('td,th').length;
const {
from,
to
} = rangeInformation;
let startColumnIndex, endColumnIndex, isDivided;
if (from.row === to.row) {
startColumnIndex = from.cell;
endColumnIndex = to.cell;
} else if (from.row < to.row) {
if (from.cell <= to.cell) {
startColumnIndex = 0;
endColumnIndex = columnLength - 1;
} else {
startColumnIndex = from.cell;
endColumnIndex = to.cell;
isDivided = true;
}
}
return {
startColumnIndex,
endColumnIndex,
isDivided
};
} | [
"function",
"getSelectionInformation",
"(",
"$table",
",",
"rangeInformation",
")",
"{",
"const",
"columnLength",
"=",
"$table",
".",
"find",
"(",
"'tr'",
")",
".",
"eq",
"(",
"0",
")",
".",
"find",
"(",
"'td,th'",
")",
".",
"length",
";",
"const",
"{",
... | Return start, end column index and boolean value for whether range divided or not
@param {jQuery} $table jQuery wrapped TABLE
@param {{startColumnIndex: number, endColumnIndex: number}} rangeInformation Range information
@returns {{startColumnIndex: number, endColumnIndex: number, isDivided: boolean}} | [
"Return",
"start",
"end",
"column",
"index",
"and",
"boolean",
"value",
"for",
"whether",
"range",
"divided",
"or",
"not"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/tableAlignCol.js#L80-L107 | train | Get selection information | [
30522,
3853,
4152,
12260,
7542,
2378,
14192,
3370,
1006,
1002,
2795,
1010,
2846,
2378,
14192,
3370,
1007,
1063,
9530,
3367,
5930,
7770,
13512,
2232,
1027,
1002,
2795,
1012,
2424,
1006,
1005,
19817,
1005,
1007,
1012,
1041,
4160,
1006,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/Model.js | _traverseFilter | function _traverseFilter (vFilters, fnCheck) {
vFilters = vFilters || [];
if (vFilters instanceof Filter) {
vFilters = [vFilters];
}
// filter has more sub-filter instances (we ignore the subfilters below the any/all operators)
for (var i = 0; i < vFilters.length; i++) {
// check single Filter
var oFilter = vFilters[i];
fnCheck(oFilter);
// check subfilter for lambda expressions (e.g. Any, All, ...)
_traverseFilter(oFilter.oCondition, fnCheck);
// check multi filter if necessary
_traverseFilter(oFilter.aFilters, fnCheck);
}
} | javascript | function _traverseFilter (vFilters, fnCheck) {
vFilters = vFilters || [];
if (vFilters instanceof Filter) {
vFilters = [vFilters];
}
// filter has more sub-filter instances (we ignore the subfilters below the any/all operators)
for (var i = 0; i < vFilters.length; i++) {
// check single Filter
var oFilter = vFilters[i];
fnCheck(oFilter);
// check subfilter for lambda expressions (e.g. Any, All, ...)
_traverseFilter(oFilter.oCondition, fnCheck);
// check multi filter if necessary
_traverseFilter(oFilter.aFilters, fnCheck);
}
} | [
"function",
"_traverseFilter",
"(",
"vFilters",
",",
"fnCheck",
")",
"{",
"vFilters",
"=",
"vFilters",
"||",
"[",
"]",
";",
"if",
"(",
"vFilters",
"instanceof",
"Filter",
")",
"{",
"vFilters",
"=",
"[",
"vFilters",
"]",
";",
"}",
"// filter has more sub-filt... | Traverses the given filter tree.
@param {sap.ui.model.Filter[]|sap.ui.model.Filter} vFilters Array of filters or a single filter instance, which will be checked for unsupported filter operators
@param {function} fnCheck Check function which is called for each filter instance in the tree
@private | [
"Traverses",
"the",
"given",
"filter",
"tree",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/Model.js#L1030-L1049 | train | Traverse a filter | [
30522,
3853,
1035,
20811,
8873,
21928,
1006,
1058,
8873,
21928,
2015,
1010,
1042,
26091,
3600,
1007,
1063,
1058,
8873,
21928,
2015,
1027,
1058,
8873,
21928,
2015,
1064,
1064,
1031,
1033,
1025,
2065,
1006,
1058,
8873,
21928,
2015,
6013,
1125... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/closure/goog/base.js | addNewerLanguageTranspilationCheck | function addNewerLanguageTranspilationCheck(modeName, isSupported) {
if (transpilationRequiredForAllLaterModes) {
requiresTranspilation[modeName] = true;
} else if (isSupported()) {
requiresTranspilation[modeName] = false;
} else {
requiresTranspilation[modeName] = true;
transpilationRequiredForAllLaterModes = true;
}
} | javascript | function addNewerLanguageTranspilationCheck(modeName, isSupported) {
if (transpilationRequiredForAllLaterModes) {
requiresTranspilation[modeName] = true;
} else if (isSupported()) {
requiresTranspilation[modeName] = false;
} else {
requiresTranspilation[modeName] = true;
transpilationRequiredForAllLaterModes = true;
}
} | [
"function",
"addNewerLanguageTranspilationCheck",
"(",
"modeName",
",",
"isSupported",
")",
"{",
"if",
"(",
"transpilationRequiredForAllLaterModes",
")",
"{",
"requiresTranspilation",
"[",
"modeName",
"]",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"isSupported",
"("... | Adds an entry to requiresTranspliation for the given language mode.
IMPORTANT: Calls must be made in order from oldest to newest language
mode.
@param {string} modeName
@param {function(): boolean} isSupported Returns true if the JS engine
supports the given mode. | [
"Adds",
"an",
"entry",
"to",
"requiresTranspliation",
"for",
"the",
"given",
"language",
"mode",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/base.js#L2853-L2862 | train | Add newer language transpilation check | [
30522,
3853,
5587,
2638,
13777,
25023,
6692,
18150,
5521,
13102,
29545,
5403,
3600,
1006,
5549,
18442,
1010,
26354,
6279,
6442,
2098,
1007,
1063,
2065,
1006,
9099,
8197,
13490,
2890,
15549,
5596,
29278,
8095,
13806,
10867,
19847,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/FormattedTextView.js | function (tagName, attribs) {
var intPattern = /^[0-9]*$/;
for (var i = 0; i < attribs.length; i += 2) {
// attribs[i] is the name of the tag's attribute.
// attribs[i+1] is its corresponding value.
// (i.e. <span class="foo"> -> attribs[i] = "class" | attribs[i+1] =
// "foo")
var sAttribKey = tagName + "::" + attribs[i];
if (this._renderingRules.ATTRIBS[sAttribKey]) {
// keep the value of this class
if (tagName === "embed" && !(attribs[i + 1].match(intPattern))) {
return null;
}
} else {
var sWarning = '<' + tagName + '> with attribute [' + attribs[i] + '="' + attribs[i + 1] + '"] is not allowed and cut';
Log.warning(sWarning, this);
// to remove this attribute by the sanitizer the value has to be
// set to null
attribs[i + 1] = null;
}
}
return attribs;
} | javascript | function (tagName, attribs) {
var intPattern = /^[0-9]*$/;
for (var i = 0; i < attribs.length; i += 2) {
// attribs[i] is the name of the tag's attribute.
// attribs[i+1] is its corresponding value.
// (i.e. <span class="foo"> -> attribs[i] = "class" | attribs[i+1] =
// "foo")
var sAttribKey = tagName + "::" + attribs[i];
if (this._renderingRules.ATTRIBS[sAttribKey]) {
// keep the value of this class
if (tagName === "embed" && !(attribs[i + 1].match(intPattern))) {
return null;
}
} else {
var sWarning = '<' + tagName + '> with attribute [' + attribs[i] + '="' + attribs[i + 1] + '"] is not allowed and cut';
Log.warning(sWarning, this);
// to remove this attribute by the sanitizer the value has to be
// set to null
attribs[i + 1] = null;
}
}
return attribs;
} | [
"function",
"(",
"tagName",
",",
"attribs",
")",
"{",
"var",
"intPattern",
"=",
"/",
"^[0-9]*$",
"/",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"attribs",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"// attribs[i] is the name of the tag's... | Sanitizes attributes on an HTML tag.
@param {string} tagName An HTML tag name in lowercase
@param {array} attribs An array of alternating names and values
@return {array} The sanitized attributes as a list of alternating names and values. Null value means to omit the attribute
@private | [
"Sanitizes",
"attributes",
"on",
"an",
"HTML",
"tag",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/FormattedTextView.js#L159-L186 | train | This function is called by the renderer to add an attribute to a tag. | [
30522,
3853,
1006,
6415,
18442,
1010,
2012,
18886,
5910,
1007,
1063,
13075,
20014,
4502,
12079,
2078,
1027,
1013,
1034,
1031,
1014,
1011,
1023,
1033,
1008,
1002,
1013,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1025,
1045,
1026,
2012,
18886... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | function(largestPossibleRadius, furthestLimits, furthestAngles) {
var me = this;
var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t);
var radiusReductionBottom = -Math.max(furthestLimits.b - (me.height - me.paddingTop), 0) / Math.cos(furthestAngles.b);
radiusReductionLeft = numberOrZero(radiusReductionLeft);
radiusReductionRight = numberOrZero(radiusReductionRight);
radiusReductionTop = numberOrZero(radiusReductionTop);
radiusReductionBottom = numberOrZero(radiusReductionBottom);
me.drawingArea = Math.min(
Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
} | javascript | function(largestPossibleRadius, furthestLimits, furthestAngles) {
var me = this;
var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
var radiusReductionTop = -furthestLimits.t / Math.cos(furthestAngles.t);
var radiusReductionBottom = -Math.max(furthestLimits.b - (me.height - me.paddingTop), 0) / Math.cos(furthestAngles.b);
radiusReductionLeft = numberOrZero(radiusReductionLeft);
radiusReductionRight = numberOrZero(radiusReductionRight);
radiusReductionTop = numberOrZero(radiusReductionTop);
radiusReductionBottom = numberOrZero(radiusReductionBottom);
me.drawingArea = Math.min(
Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
} | [
"function",
"(",
"largestPossibleRadius",
",",
"furthestLimits",
",",
"furthestAngles",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"radiusReductionLeft",
"=",
"furthestLimits",
".",
"l",
"/",
"Math",
".",
"sin",
"(",
"furthestAngles",
".",
"l",
")",
";"... | Set radius reductions and determine new radius and center point
@private | [
"Set",
"radius",
"reductions",
"and",
"determine",
"new",
"radius",
"and",
"center",
"point"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/scales/scale.radialLinear.js#L396-L412 | train | Calculates the largest possible radius of the rectangle | [
30522,
3853,
1006,
2922,
6873,
18719,
16213,
17190,
2271,
1010,
6519,
20515,
17960,
12762,
1010,
6519,
20515,
5654,
4244,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
13075,
12177,
5596,
14194,
3508,
2571,
6199,
1027,
6519,
20515,
17960,
12762,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/routing/Router.js | function (sHash) {
return Object.keys(this._oRoutes).some(function(sRouteName) {
return this._oRoutes[sRouteName].match(sHash);
}.bind(this));
} | javascript | function (sHash) {
return Object.keys(this._oRoutes).some(function(sRouteName) {
return this._oRoutes[sRouteName].match(sHash);
}.bind(this));
} | [
"function",
"(",
"sHash",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"this",
".",
"_oRoutes",
")",
".",
"some",
"(",
"function",
"(",
"sRouteName",
")",
"{",
"return",
"this",
".",
"_oRoutes",
"[",
"sRouteName",
"]",
".",
"match",
"(",
"sHash",
... | Returns whether the given hash can be matched by any one of the Route in the Router.
@param {string} hash which will be tested by the Router
@return {boolean} whether the hash can be matched
@public
@since 1.58.0 | [
"Returns",
"whether",
"the",
"given",
"hash",
"can",
"be",
"matched",
"by",
"any",
"one",
"of",
"the",
"Route",
"in",
"the",
"Router",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/routing/Router.js#L535-L539 | train | Returns true if the route hash matches the hash | [
30522,
3853,
1006,
21146,
4095,
1007,
1063,
2709,
4874,
1012,
6309,
1006,
2023,
1012,
1035,
20298,
10421,
2015,
1007,
1012,
2070,
1006,
3853,
1006,
5034,
5833,
8189,
4168,
1007,
1063,
2709,
2023,
1012,
1035,
20298,
10421,
2015,
1031,
5034,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js | function (oPage, oData) {
var oContentModel = this.getView().getModel("content");
oContentModel.setData(oData);
oPage.setBusy(false);
this.filterListByQuery("");
this.byId("search").setValue("");
} | javascript | function (oPage, oData) {
var oContentModel = this.getView().getModel("content");
oContentModel.setData(oData);
oPage.setBusy(false);
this.filterListByQuery("");
this.byId("search").setValue("");
} | [
"function",
"(",
"oPage",
",",
"oData",
")",
"{",
"var",
"oContentModel",
"=",
"this",
".",
"getView",
"(",
")",
".",
"getModel",
"(",
"\"content\"",
")",
";",
"oContentModel",
".",
"setData",
"(",
"oData",
")",
";",
"oPage",
".",
"setBusy",
"(",
"fals... | Handler if content data was received;
Sets the received data to the current content model.
@param {Object} oPage
@param {Object} oData - data which is received from <code>LRepConnector</code> "getContent" promise
@private | [
"Handler",
"if",
"content",
"data",
"was",
"received",
";",
"Sets",
"the",
"received",
"data",
"to",
"the",
"current",
"content",
"model",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js#L72-L78 | train | Sets the data of the content model and sets busy flag | [
30522,
3853,
1006,
6728,
4270,
1010,
1051,
2850,
2696,
1007,
1063,
13075,
1051,
8663,
6528,
21246,
10244,
2140,
1027,
2023,
1012,
2131,
8584,
1006,
1007,
1012,
2131,
5302,
9247,
1006,
1000,
4180,
1000,
1007,
1025,
1051,
8663,
6528,
21246,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
sass/node-sass | lib/extensions.js | getBinaryUrl | function getBinaryUrl() {
var site = getArgument('--sass-binary-site') ||
process.env.SASS_BINARY_SITE ||
process.env.npm_config_sass_binary_site ||
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download';
return [site, 'v' + pkg.version, getBinaryName()].join('/');
} | javascript | function getBinaryUrl() {
var site = getArgument('--sass-binary-site') ||
process.env.SASS_BINARY_SITE ||
process.env.npm_config_sass_binary_site ||
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
'https://github.com/sass/node-sass/releases/download';
return [site, 'v' + pkg.version, getBinaryName()].join('/');
} | [
"function",
"getBinaryUrl",
"(",
")",
"{",
"var",
"site",
"=",
"getArgument",
"(",
"'--sass-binary-site'",
")",
"||",
"process",
".",
"env",
".",
"SASS_BINARY_SITE",
"||",
"process",
".",
"env",
".",
"npm_config_sass_binary_site",
"||",
"(",
"pkg",
".",
"nodeS... | Determine the URL to fetch binary file from.
By default fetch from the node-sass distribution
site on GitHub.
The default URL can be overriden using
the environment variable SASS_BINARY_SITE,
.npmrc variable sass_binary_site or
or a command line option --sass-binary-site:
node scripts/install.js --sass-binary-site http://example.com/
The URL should to the mirror of the repository
laid out as follows:
SASS_BINARY_SITE/
v3.0.0
v3.0.0/freebsd-x64-14_binding.node
....
v3.0.0
v3.0.0/freebsd-ia32-11_binding.node
v3.0.0/freebsd-x64-42_binding.node
... etc. for all supported versions and platforms
@api public | [
"Determine",
"the",
"URL",
"to",
"fetch",
"binary",
"file",
"from",
".",
"By",
"default",
"fetch",
"from",
"the",
"node",
"-",
"sass",
"distribution",
"site",
"on",
"GitHub",
"."
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L240-L248 | train | Get binary URL | [
30522,
3853,
2131,
21114,
2854,
3126,
2140,
1006,
1007,
1063,
13075,
2609,
1027,
2131,
2906,
22850,
4765,
1006,
1005,
1011,
1011,
21871,
2015,
1011,
12441,
1011,
2609,
1005,
1007,
1064,
1064,
2832,
1012,
4372,
2615,
1012,
21871,
2015,
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... |
adobe/brackets | src/extensions/samples/BracketsConfigCentral/main.js | _createConfigViewOf | function _createConfigViewOf(file, pane) {
var result = new $.Deferred(),
view = pane.findViewOfFile(file.fullPath);
if (view) {
// existing view, then just show it
pane.showView(view);
result.resolve(view.getFile());
} else {
DocumentManager.getDocumentForPath(file.fullPath)
.done(function (doc) {
var view = new ConfigView(doc, pane.$el);
pane.addView(view, true);
result.resolve(doc.file);
})
.fail(function (fileError) {
result.reject(fileError);
});
}
return result.promise();
} | javascript | function _createConfigViewOf(file, pane) {
var result = new $.Deferred(),
view = pane.findViewOfFile(file.fullPath);
if (view) {
// existing view, then just show it
pane.showView(view);
result.resolve(view.getFile());
} else {
DocumentManager.getDocumentForPath(file.fullPath)
.done(function (doc) {
var view = new ConfigView(doc, pane.$el);
pane.addView(view, true);
result.resolve(doc.file);
})
.fail(function (fileError) {
result.reject(fileError);
});
}
return result.promise();
} | [
"function",
"_createConfigViewOf",
"(",
"file",
",",
"pane",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"view",
"=",
"pane",
".",
"findViewOfFile",
"(",
"file",
".",
"fullPath",
")",
";",
"if",
"(",
"view",
")",
"{",
... | /*
Creates a view of a file (.brackets.json)
@param {!File} file - the file to create a view for
@param {!Pane} pane - the pane where to create the view
@private | [
"/",
"*",
"Creates",
"a",
"view",
"of",
"a",
"file",
"(",
".",
"brackets",
".",
"json",
")"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/samples/BracketsConfigCentral/main.js#L79-L99 | train | Create a ConfigView of a file | [
30522,
3853,
1035,
3443,
8663,
8873,
2290,
8584,
11253,
1006,
5371,
1010,
6090,
2063,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
3193,
1027,
6090,
2063,
1012,
2424,
8584,
7245,
9463,
1006,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RTCMultiConnection | dev/MediaStreamRecorder.js | MediaStreamRecorder | function MediaStreamRecorder(mediaStream) {
if (!mediaStream) {
throw 'MediaStream is mandatory.';
}
// void start(optional long timeSlice)
// timestamp to fire "ondataavailable"
this.start = function(timeSlice) {
var Recorder;
if (typeof MediaRecorder !== 'undefined') {
Recorder = MediaRecorderWrapper;
} else if (IsChrome || IsOpera || IsEdge) {
if (this.mimeType.indexOf('video') !== -1) {
Recorder = WhammyRecorder;
} else if (this.mimeType.indexOf('audio') !== -1) {
Recorder = StereoAudioRecorder;
}
}
// video recorder (in GIF format)
if (this.mimeType === 'image/gif') {
Recorder = GifRecorder;
}
// audio/wav is supported only via StereoAudioRecorder
// audio/pcm (int16) is supported only via StereoAudioRecorder
if (this.mimeType === 'audio/wav' || this.mimeType === 'audio/pcm') {
Recorder = StereoAudioRecorder;
}
// allows forcing StereoAudioRecorder.js on Edge/Firefox
if (this.recorderType) {
Recorder = this.recorderType;
}
mediaRecorder = new Recorder(mediaStream);
mediaRecorder.blobs = [];
var self = this;
mediaRecorder.ondataavailable = function(data) {
mediaRecorder.blobs.push(data);
self.ondataavailable(data);
};
mediaRecorder.onstop = this.onstop;
mediaRecorder.onStartedDrawingNonBlankFrames = this.onStartedDrawingNonBlankFrames;
// Merge all data-types except "function"
mediaRecorder = mergeProps(mediaRecorder, this);
mediaRecorder.start(timeSlice);
};
this.onStartedDrawingNonBlankFrames = function() {};
this.clearOldRecordedFrames = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.clearOldRecordedFrames();
};
this.stop = function() {
if (mediaRecorder) {
mediaRecorder.stop();
}
};
this.ondataavailable = function(blob) {
if (this.disableLogs) return;
console.log('ondataavailable..', blob);
};
this.onstop = function(error) {
console.warn('stopped..', error);
};
this.save = function(file, fileName) {
if (!file) {
if (!mediaRecorder) {
return;
}
ConcatenateBlobs(mediaRecorder.blobs, mediaRecorder.blobs[0].type, function(concatenatedBlob) {
invokeSaveAsDialog(concatenatedBlob);
});
return;
}
invokeSaveAsDialog(file, fileName);
};
this.pause = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.pause();
if (this.disableLogs) return;
console.log('Paused recording.', this.mimeType || mediaRecorder.mimeType);
};
this.resume = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.resume();
if (this.disableLogs) return;
console.log('Resumed recording.', this.mimeType || mediaRecorder.mimeType);
};
// StereoAudioRecorder || WhammyRecorder || MediaRecorderWrapper || GifRecorder
this.recorderType = null;
// video/webm or audio/webm or audio/ogg or audio/wav
this.mimeType = 'video/webm';
// logs are enabled by default
this.disableLogs = false;
// Reference to "MediaRecorder.js"
var mediaRecorder;
} | javascript | function MediaStreamRecorder(mediaStream) {
if (!mediaStream) {
throw 'MediaStream is mandatory.';
}
// void start(optional long timeSlice)
// timestamp to fire "ondataavailable"
this.start = function(timeSlice) {
var Recorder;
if (typeof MediaRecorder !== 'undefined') {
Recorder = MediaRecorderWrapper;
} else if (IsChrome || IsOpera || IsEdge) {
if (this.mimeType.indexOf('video') !== -1) {
Recorder = WhammyRecorder;
} else if (this.mimeType.indexOf('audio') !== -1) {
Recorder = StereoAudioRecorder;
}
}
// video recorder (in GIF format)
if (this.mimeType === 'image/gif') {
Recorder = GifRecorder;
}
// audio/wav is supported only via StereoAudioRecorder
// audio/pcm (int16) is supported only via StereoAudioRecorder
if (this.mimeType === 'audio/wav' || this.mimeType === 'audio/pcm') {
Recorder = StereoAudioRecorder;
}
// allows forcing StereoAudioRecorder.js on Edge/Firefox
if (this.recorderType) {
Recorder = this.recorderType;
}
mediaRecorder = new Recorder(mediaStream);
mediaRecorder.blobs = [];
var self = this;
mediaRecorder.ondataavailable = function(data) {
mediaRecorder.blobs.push(data);
self.ondataavailable(data);
};
mediaRecorder.onstop = this.onstop;
mediaRecorder.onStartedDrawingNonBlankFrames = this.onStartedDrawingNonBlankFrames;
// Merge all data-types except "function"
mediaRecorder = mergeProps(mediaRecorder, this);
mediaRecorder.start(timeSlice);
};
this.onStartedDrawingNonBlankFrames = function() {};
this.clearOldRecordedFrames = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.clearOldRecordedFrames();
};
this.stop = function() {
if (mediaRecorder) {
mediaRecorder.stop();
}
};
this.ondataavailable = function(blob) {
if (this.disableLogs) return;
console.log('ondataavailable..', blob);
};
this.onstop = function(error) {
console.warn('stopped..', error);
};
this.save = function(file, fileName) {
if (!file) {
if (!mediaRecorder) {
return;
}
ConcatenateBlobs(mediaRecorder.blobs, mediaRecorder.blobs[0].type, function(concatenatedBlob) {
invokeSaveAsDialog(concatenatedBlob);
});
return;
}
invokeSaveAsDialog(file, fileName);
};
this.pause = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.pause();
if (this.disableLogs) return;
console.log('Paused recording.', this.mimeType || mediaRecorder.mimeType);
};
this.resume = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.resume();
if (this.disableLogs) return;
console.log('Resumed recording.', this.mimeType || mediaRecorder.mimeType);
};
// StereoAudioRecorder || WhammyRecorder || MediaRecorderWrapper || GifRecorder
this.recorderType = null;
// video/webm or audio/webm or audio/ogg or audio/wav
this.mimeType = 'video/webm';
// logs are enabled by default
this.disableLogs = false;
// Reference to "MediaRecorder.js"
var mediaRecorder;
} | [
"function",
"MediaStreamRecorder",
"(",
"mediaStream",
")",
"{",
"if",
"(",
"!",
"mediaStream",
")",
"{",
"throw",
"'MediaStream is mandatory.'",
";",
"}",
"// void start(optional long timeSlice)",
"// timestamp to fire \"ondataavailable\"",
"this",
".",
"start",
"=",
"fu... | ______________________ MediaStreamRecorder.js | [
"______________________",
"MediaStreamRecorder",
".",
"js"
] | 2032ce949bde30b43a3d2666e0f1e5afbf337f3d | https://github.com/muaz-khan/RTCMultiConnection/blob/2032ce949bde30b43a3d2666e0f1e5afbf337f3d/dev/MediaStreamRecorder.js#L18-L140 | train | Recorder class for recording media | [
30522,
3853,
2865,
21422,
2890,
27108,
4063,
1006,
2865,
21422,
1007,
1063,
2065,
1006,
999,
2865,
21422,
1007,
1063,
5466,
1005,
2865,
21422,
2003,
10915,
1012,
1005,
1025,
1065,
1013,
1013,
11675,
2707,
1006,
11887,
2146,
2335,
13231,
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... |
GitbookIO/gitbook | lib/modifiers/summary/unshiftArticle.js | unshiftArticle | function unshiftArticle(summary, article) {
article = SummaryArticle(article);
var parts = summary.getParts();
var part = parts.get(0) || SummaryPart();
var articles = part.getArticles();
articles = articles.unshift(article);
part = part.set('articles', articles);
parts = parts.set(0, part);
summary = summary.set('parts', parts);
return indexLevels(summary);
} | javascript | function unshiftArticle(summary, article) {
article = SummaryArticle(article);
var parts = summary.getParts();
var part = parts.get(0) || SummaryPart();
var articles = part.getArticles();
articles = articles.unshift(article);
part = part.set('articles', articles);
parts = parts.set(0, part);
summary = summary.set('parts', parts);
return indexLevels(summary);
} | [
"function",
"unshiftArticle",
"(",
"summary",
",",
"article",
")",
"{",
"article",
"=",
"SummaryArticle",
"(",
"article",
")",
";",
"var",
"parts",
"=",
"summary",
".",
"getParts",
"(",
")",
";",
"var",
"part",
"=",
"parts",
".",
"get",
"(",
"0",
")",
... | Insert an article at the beginning of summary
@param {Summary} summary
@param {Article} article
@return {Summary} | [
"Insert",
"an",
"article",
"at",
"the",
"beginning",
"of",
"summary"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/unshiftArticle.js#L13-L27 | train | unshift an article to the beginning of summary | [
30522,
3853,
4895,
6182,
6199,
8445,
25128,
1006,
12654,
1010,
3720,
1007,
1063,
3720,
1027,
12654,
8445,
25128,
1006,
3720,
1007,
1025,
13075,
3033,
1027,
12654,
1012,
2131,
26950,
1006,
1007,
1025,
13075,
2112,
1027,
3033,
1012,
2131,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
juliangarnier/anime | lib/anime.js | anime | function anime(params) {
if ( params === void 0 ) params = {};
var startTime = 0, lastTime = 0, now = 0;
var children, childrenLength = 0;
var resolve = null;
function makePromise(instance) {
var promise = window.Promise && new Promise(function (_resolve) { return resolve = _resolve; });
instance.finished = promise;
return promise;
}
var instance = createNewInstance(params);
var promise = makePromise(instance);
function toggleInstanceDirection() {
var direction = instance.direction;
if (direction !== 'alternate') {
instance.direction = direction !== 'normal' ? 'normal' : 'reverse';
}
instance.reversed = !instance.reversed;
children.forEach(function (child) { return child.reversed = instance.reversed; });
}
function adjustTime(time) {
return instance.reversed ? instance.duration - time : time;
}
function resetTime() {
startTime = 0;
lastTime = adjustTime(instance.currentTime) * (1 / anime.speed);
}
function seekCild(time, child) {
if (child) { child.seek(time - child.timelineOffset); }
}
function syncInstanceChildren(time) {
if (!instance.reversePlayback) {
for (var i = 0; i < childrenLength; i++) { seekCild(time, children[i]); }
} else {
for (var i$1 = childrenLength; i$1--;) { seekCild(time, children[i$1]); }
}
}
function setAnimationsProgress(insTime) {
var i = 0;
var animations = instance.animations;
var animationsLength = animations.length;
while (i < animationsLength) {
var anim = animations[i];
var animatable = anim.animatable;
var tweens = anim.tweens;
var tweenLength = tweens.length - 1;
var tween = tweens[tweenLength];
// Only check for keyframes if there is more than one tween
if (tweenLength) { tween = filterArray(tweens, function (t) { return (insTime < t.end); })[0] || tween; }
var elapsed = minMax(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
var eased = isNaN(elapsed) ? 1 : tween.easing(elapsed);
var strings = tween.to.strings;
var round = tween.round;
var numbers = [];
var toNumbersLength = tween.to.numbers.length;
var progress = (void 0);
for (var n = 0; n < toNumbersLength; n++) {
var value = (void 0);
var toNumber = tween.to.numbers[n];
var fromNumber = tween.from.numbers[n] || 0;
if (!tween.isPath) {
value = fromNumber + (eased * (toNumber - fromNumber));
} else {
value = getPathProgress(tween.value, eased * toNumber);
}
if (round) {
if (!(tween.isColor && n > 2)) {
value = Math.round(value * round) / round;
}
}
numbers.push(value);
}
// Manual Array.reduce for better performances
var stringsLength = strings.length;
if (!stringsLength) {
progress = numbers[0];
} else {
progress = strings[0];
for (var s = 0; s < stringsLength; s++) {
var a = strings[s];
var b = strings[s + 1];
var n$1 = numbers[s];
if (!isNaN(n$1)) {
if (!b) {
progress += n$1 + ' ';
} else {
progress += n$1 + b;
}
}
}
}
setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
anim.currentValue = progress;
i++;
}
}
function setCallback(cb) {
if (instance[cb] && !instance.passThrough) { instance[cb](instance); }
}
function countIteration() {
if (instance.remaining && instance.remaining !== true) {
instance.remaining--;
}
}
function setInstanceProgress(engineTime) {
var insDuration = instance.duration;
var insDelay = instance.delay;
var insEndDelay = insDuration - instance.endDelay;
var insTime = adjustTime(engineTime);
instance.progress = minMax((insTime / insDuration) * 100, 0, 100);
instance.reversePlayback = insTime < instance.currentTime;
if (children) { syncInstanceChildren(insTime); }
if (!instance.began && instance.currentTime > 0) {
instance.began = true;
setCallback('begin');
setCallback('loopBegin');
}
if (insTime <= insDelay && instance.currentTime !== 0) {
setAnimationsProgress(0);
}
if ((insTime >= insEndDelay && instance.currentTime !== insDuration) || !insDuration) {
setAnimationsProgress(insDuration);
}
if (insTime > insDelay && insTime < insEndDelay) {
if (!instance.changeBegan) {
instance.changeBegan = true;
instance.changeCompleted = false;
setCallback('changeBegin');
}
setCallback('change');
setAnimationsProgress(insTime);
} else {
if (instance.changeBegan) {
instance.changeCompleted = true;
instance.changeBegan = false;
setCallback('changeComplete');
}
}
instance.currentTime = minMax(insTime, 0, insDuration);
if (instance.began) { setCallback('update'); }
if (engineTime >= insDuration) {
lastTime = 0;
countIteration();
if (instance.remaining) {
startTime = now;
setCallback('loopComplete');
setCallback('loopBegin');
if (instance.direction === 'alternate') { toggleInstanceDirection(); }
} else {
instance.paused = true;
if (!instance.completed) {
instance.completed = true;
setCallback('loopComplete');
setCallback('complete');
if (!instance.passThrough && 'Promise' in window) {
resolve();
promise = makePromise(instance);
}
}
}
}
}
instance.reset = function() {
var direction = instance.direction;
instance.passThrough = false;
instance.currentTime = 0;
instance.progress = 0;
instance.paused = true;
instance.began = false;
instance.changeBegan = false;
instance.completed = false;
instance.changeCompleted = false;
instance.reversePlayback = false;
instance.reversed = direction === 'reverse';
instance.remaining = instance.loop;
children = instance.children;
childrenLength = children.length;
for (var i = childrenLength; i--;) { instance.children[i].reset(); }
if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; }
setAnimationsProgress(0);
};
// Set Value helper
instance.set = function(targets, properties) {
setTargetsValue(targets, properties);
return instance;
};
instance.tick = function(t) {
now = t;
if (!startTime) { startTime = now; }
setInstanceProgress((now + (lastTime - startTime)) * anime.speed);
};
instance.seek = function(time) {
setInstanceProgress(adjustTime(time));
};
instance.pause = function() {
instance.paused = true;
resetTime();
};
instance.play = function() {
if (!instance.paused) { return; }
if (instance.completed) { instance.reset(); }
instance.paused = false;
activeInstances.push(instance);
resetTime();
if (!raf) { engine(); }
};
instance.reverse = function() {
toggleInstanceDirection();
resetTime();
};
instance.restart = function() {
instance.reset();
instance.play();
};
instance.reset();
if (instance.autoplay) { instance.play(); }
return instance;
} | javascript | function anime(params) {
if ( params === void 0 ) params = {};
var startTime = 0, lastTime = 0, now = 0;
var children, childrenLength = 0;
var resolve = null;
function makePromise(instance) {
var promise = window.Promise && new Promise(function (_resolve) { return resolve = _resolve; });
instance.finished = promise;
return promise;
}
var instance = createNewInstance(params);
var promise = makePromise(instance);
function toggleInstanceDirection() {
var direction = instance.direction;
if (direction !== 'alternate') {
instance.direction = direction !== 'normal' ? 'normal' : 'reverse';
}
instance.reversed = !instance.reversed;
children.forEach(function (child) { return child.reversed = instance.reversed; });
}
function adjustTime(time) {
return instance.reversed ? instance.duration - time : time;
}
function resetTime() {
startTime = 0;
lastTime = adjustTime(instance.currentTime) * (1 / anime.speed);
}
function seekCild(time, child) {
if (child) { child.seek(time - child.timelineOffset); }
}
function syncInstanceChildren(time) {
if (!instance.reversePlayback) {
for (var i = 0; i < childrenLength; i++) { seekCild(time, children[i]); }
} else {
for (var i$1 = childrenLength; i$1--;) { seekCild(time, children[i$1]); }
}
}
function setAnimationsProgress(insTime) {
var i = 0;
var animations = instance.animations;
var animationsLength = animations.length;
while (i < animationsLength) {
var anim = animations[i];
var animatable = anim.animatable;
var tweens = anim.tweens;
var tweenLength = tweens.length - 1;
var tween = tweens[tweenLength];
// Only check for keyframes if there is more than one tween
if (tweenLength) { tween = filterArray(tweens, function (t) { return (insTime < t.end); })[0] || tween; }
var elapsed = minMax(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
var eased = isNaN(elapsed) ? 1 : tween.easing(elapsed);
var strings = tween.to.strings;
var round = tween.round;
var numbers = [];
var toNumbersLength = tween.to.numbers.length;
var progress = (void 0);
for (var n = 0; n < toNumbersLength; n++) {
var value = (void 0);
var toNumber = tween.to.numbers[n];
var fromNumber = tween.from.numbers[n] || 0;
if (!tween.isPath) {
value = fromNumber + (eased * (toNumber - fromNumber));
} else {
value = getPathProgress(tween.value, eased * toNumber);
}
if (round) {
if (!(tween.isColor && n > 2)) {
value = Math.round(value * round) / round;
}
}
numbers.push(value);
}
// Manual Array.reduce for better performances
var stringsLength = strings.length;
if (!stringsLength) {
progress = numbers[0];
} else {
progress = strings[0];
for (var s = 0; s < stringsLength; s++) {
var a = strings[s];
var b = strings[s + 1];
var n$1 = numbers[s];
if (!isNaN(n$1)) {
if (!b) {
progress += n$1 + ' ';
} else {
progress += n$1 + b;
}
}
}
}
setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
anim.currentValue = progress;
i++;
}
}
function setCallback(cb) {
if (instance[cb] && !instance.passThrough) { instance[cb](instance); }
}
function countIteration() {
if (instance.remaining && instance.remaining !== true) {
instance.remaining--;
}
}
function setInstanceProgress(engineTime) {
var insDuration = instance.duration;
var insDelay = instance.delay;
var insEndDelay = insDuration - instance.endDelay;
var insTime = adjustTime(engineTime);
instance.progress = minMax((insTime / insDuration) * 100, 0, 100);
instance.reversePlayback = insTime < instance.currentTime;
if (children) { syncInstanceChildren(insTime); }
if (!instance.began && instance.currentTime > 0) {
instance.began = true;
setCallback('begin');
setCallback('loopBegin');
}
if (insTime <= insDelay && instance.currentTime !== 0) {
setAnimationsProgress(0);
}
if ((insTime >= insEndDelay && instance.currentTime !== insDuration) || !insDuration) {
setAnimationsProgress(insDuration);
}
if (insTime > insDelay && insTime < insEndDelay) {
if (!instance.changeBegan) {
instance.changeBegan = true;
instance.changeCompleted = false;
setCallback('changeBegin');
}
setCallback('change');
setAnimationsProgress(insTime);
} else {
if (instance.changeBegan) {
instance.changeCompleted = true;
instance.changeBegan = false;
setCallback('changeComplete');
}
}
instance.currentTime = minMax(insTime, 0, insDuration);
if (instance.began) { setCallback('update'); }
if (engineTime >= insDuration) {
lastTime = 0;
countIteration();
if (instance.remaining) {
startTime = now;
setCallback('loopComplete');
setCallback('loopBegin');
if (instance.direction === 'alternate') { toggleInstanceDirection(); }
} else {
instance.paused = true;
if (!instance.completed) {
instance.completed = true;
setCallback('loopComplete');
setCallback('complete');
if (!instance.passThrough && 'Promise' in window) {
resolve();
promise = makePromise(instance);
}
}
}
}
}
instance.reset = function() {
var direction = instance.direction;
instance.passThrough = false;
instance.currentTime = 0;
instance.progress = 0;
instance.paused = true;
instance.began = false;
instance.changeBegan = false;
instance.completed = false;
instance.changeCompleted = false;
instance.reversePlayback = false;
instance.reversed = direction === 'reverse';
instance.remaining = instance.loop;
children = instance.children;
childrenLength = children.length;
for (var i = childrenLength; i--;) { instance.children[i].reset(); }
if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; }
setAnimationsProgress(0);
};
// Set Value helper
instance.set = function(targets, properties) {
setTargetsValue(targets, properties);
return instance;
};
instance.tick = function(t) {
now = t;
if (!startTime) { startTime = now; }
setInstanceProgress((now + (lastTime - startTime)) * anime.speed);
};
instance.seek = function(time) {
setInstanceProgress(adjustTime(time));
};
instance.pause = function() {
instance.paused = true;
resetTime();
};
instance.play = function() {
if (!instance.paused) { return; }
if (instance.completed) { instance.reset(); }
instance.paused = false;
activeInstances.push(instance);
resetTime();
if (!raf) { engine(); }
};
instance.reverse = function() {
toggleInstanceDirection();
resetTime();
};
instance.restart = function() {
instance.reset();
instance.play();
};
instance.reset();
if (instance.autoplay) { instance.play(); }
return instance;
} | [
"function",
"anime",
"(",
"params",
")",
"{",
"if",
"(",
"params",
"===",
"void",
"0",
")",
"params",
"=",
"{",
"}",
";",
"var",
"startTime",
"=",
"0",
",",
"lastTime",
"=",
"0",
",",
"now",
"=",
"0",
";",
"var",
"children",
",",
"childrenLength",
... | Public Instance | [
"Public",
"Instance"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/lib/anime.js#L925-L1168 | train | Anime function | [
30522,
3853,
8750,
1006,
11498,
5244,
1007,
1063,
2065,
1006,
11498,
5244,
1027,
1027,
1027,
11675,
1014,
1007,
11498,
5244,
1027,
1063,
1065,
1025,
13075,
2707,
7292,
1027,
1014,
1010,
2197,
7292,
1027,
1014,
1010,
2085,
1027,
1014,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/angular | tools/gulp-tasks/cldr/extract.js | getPluralFunction | function getPluralFunction(locale) {
let fn = cldr.extractPluralRuleFunction(locale).toString();
if (fn === EMPTY_RULE) {
fn = DEFAULT_RULE;
}
fn = fn
.replace(
toRegExp('function anonymous(n\n/*``*/) {\n'),
'function plural(n: number): number {\n ')
.replace(toRegExp('var'), 'let')
.replace(toRegExp('if(typeof n==="string")n=parseInt(n,10);'), '')
.replace(toRegExp('\n}'), ';\n}');
// The replacement values must match the `Plural` enum from common.
// We do not use the enum directly to avoid depending on that package.
return fn
.replace(toRegExp('"zero"'), ' 0')
.replace(toRegExp('"one"'), ' 1')
.replace(toRegExp('"two"'), ' 2')
.replace(toRegExp('"few"'), ' 3')
.replace(toRegExp('"many"'), ' 4')
.replace(toRegExp('"other"'), ' 5');
} | javascript | function getPluralFunction(locale) {
let fn = cldr.extractPluralRuleFunction(locale).toString();
if (fn === EMPTY_RULE) {
fn = DEFAULT_RULE;
}
fn = fn
.replace(
toRegExp('function anonymous(n\n/*``*/) {\n'),
'function plural(n: number): number {\n ')
.replace(toRegExp('var'), 'let')
.replace(toRegExp('if(typeof n==="string")n=parseInt(n,10);'), '')
.replace(toRegExp('\n}'), ';\n}');
// The replacement values must match the `Plural` enum from common.
// We do not use the enum directly to avoid depending on that package.
return fn
.replace(toRegExp('"zero"'), ' 0')
.replace(toRegExp('"one"'), ' 1')
.replace(toRegExp('"two"'), ' 2')
.replace(toRegExp('"few"'), ' 3')
.replace(toRegExp('"many"'), ' 4')
.replace(toRegExp('"other"'), ' 5');
} | [
"function",
"getPluralFunction",
"(",
"locale",
")",
"{",
"let",
"fn",
"=",
"cldr",
".",
"extractPluralRuleFunction",
"(",
"locale",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"fn",
"===",
"EMPTY_RULE",
")",
"{",
"fn",
"=",
"DEFAULT_RULE",
";",
"}",... | Returns the plural function for a locale
todo(ocombe): replace "cldr" extractPluralRuleFunction with our own extraction using "CldrJS"
because the 2 libs can become out of sync if they use different versions of the cldr database | [
"Returns",
"the",
"plural",
"function",
"for",
"a",
"locale",
"todo",
"(",
"ocombe",
")",
":",
"replace",
"cldr",
"extractPluralRuleFunction",
"with",
"our",
"own",
"extraction",
"using",
"CldrJS",
"because",
"the",
"2",
"libs",
"can",
"become",
"out",
"of",
... | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/tools/gulp-tasks/cldr/extract.js#L510-L534 | train | Returns the plural function for the given locale | [
30522,
3853,
2131,
24759,
11137,
11263,
27989,
1006,
2334,
2063,
1007,
1063,
2292,
1042,
2078,
1027,
18856,
13626,
1012,
14817,
24759,
11137,
6820,
2571,
11263,
27989,
1006,
2334,
2063,
1007,
1012,
2000,
3367,
4892,
1006,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/services/s3.js | getSignedUrl | function getSignedUrl(operation, params, callback) {
params = AWS.util.copy(params || {});
var expires = params.Expires || 900;
delete params.Expires; // we can't validate this
var request = this.makeRequest(operation, params);
if (callback) {
AWS.util.defer(function() {
request.presign(expires, callback);
});
} else {
return request.presign(expires, callback);
}
} | javascript | function getSignedUrl(operation, params, callback) {
params = AWS.util.copy(params || {});
var expires = params.Expires || 900;
delete params.Expires; // we can't validate this
var request = this.makeRequest(operation, params);
if (callback) {
AWS.util.defer(function() {
request.presign(expires, callback);
});
} else {
return request.presign(expires, callback);
}
} | [
"function",
"getSignedUrl",
"(",
"operation",
",",
"params",
",",
"callback",
")",
"{",
"params",
"=",
"AWS",
".",
"util",
".",
"copy",
"(",
"params",
"||",
"{",
"}",
")",
";",
"var",
"expires",
"=",
"params",
".",
"Expires",
"||",
"900",
";",
"delet... | Get a pre-signed URL for a given operation name.
@note You must ensure that you have static or previously resolved
credentials if you call this method synchronously (with no callback),
otherwise it may not properly sign the request. If you cannot guarantee
this (you are using an asynchronous credential provider, i.e., EC2
IAM roles), you should always call this method with an asynchronous
callback.
@note Not all operation parameters are supported when using pre-signed
URLs. Certain parameters, such as `SSECustomerKey`, `ACL`, `Expires`,
`ContentLength`, or `Tagging` must be provided as headers when sending a
request. If you are using pre-signed URLs to upload from a browser and
need to use these fields, see {createPresignedPost}.
@note The default signer allows altering the request by adding corresponding
headers to set some parameters (e.g. Range) and these added parameters
won't be signed. You must use signatureVersion v4 to to include these
parameters in the signed portion of the URL and enforce exact matching
between headers and signed params in the URL.
@note This operation cannot be used with a promise. See note above regarding
asynchronous credentials and use with a callback.
@param operation [String] the name of the operation to call
@param params [map] parameters to pass to the operation. See the given
operation for the expected operation parameters. In addition, you can
also pass the "Expires" parameter to inform S3 how long the URL should
work for.
@option params Expires [Integer] (900) the number of seconds to expire
the pre-signed URL operation in. Defaults to 15 minutes.
@param callback [Function] if a callback is provided, this function will
pass the URL as the second parameter (after the error parameter) to
the callback function.
@return [String] if called synchronously (with no callback), returns the
signed URL.
@return [null] nothing is returned if a callback is provided.
@example Pre-signing a getObject operation (synchronously)
var params = {Bucket: 'bucket', Key: 'key'};
var url = s3.getSignedUrl('getObject', params);
console.log('The URL is', url);
@example Pre-signing a putObject (asynchronously)
var params = {Bucket: 'bucket', Key: 'key'};
s3.getSignedUrl('putObject', params, function (err, url) {
console.log('The URL is', url);
});
@example Pre-signing a putObject operation with a specific payload
var params = {Bucket: 'bucket', Key: 'key', Body: 'body'};
var url = s3.getSignedUrl('putObject', params);
console.log('The URL is', url);
@example Passing in a 1-minute expiry time for a pre-signed URL
var params = {Bucket: 'bucket', Key: 'key', Expires: 60};
var url = s3.getSignedUrl('getObject', params);
console.log('The URL is', url); // expires in 60 seconds | [
"Get",
"a",
"pre",
"-",
"signed",
"URL",
"for",
"a",
"given",
"operation",
"name",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/s3.js#L785-L798 | train | Get the signed URL for the specified resource | [
30522,
3853,
4152,
23773,
2098,
3126,
2140,
1006,
3169,
1010,
11498,
5244,
1010,
2655,
5963,
1007,
1063,
11498,
5244,
1027,
22091,
2015,
1012,
21183,
4014,
1012,
6100,
1006,
11498,
5244,
1064,
1064,
1063,
1065,
1007,
1025,
13075,
4654,
2078... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js | function (oPathValue) {
var oModel = oPathValue.model,
oPromise;
Basics.expectType(oPathValue, "string");
oPromise = oModel.fetchObject(oPathValue.path + "/$");
if (oPromise.isPending() && !oPathValue.$$valueAsPromise) {
oPromise.caught();
oPromise = SyncPromise.resolve();
}
return oPromise.then(function (oProperty) {
var mConstraints,
oCurrencyOrUnitPromise,
sType = oProperty && oProperty.$Type;
if (oProperty && oPathValue.complexBinding) {
mConstraints = oModel.getConstraints(oProperty, oPathValue.path);
oCurrencyOrUnitPromise
= Expression.fetchCurrencyOrUnit(oPathValue, sType, mConstraints);
}
return oCurrencyOrUnitPromise || {
constraints : mConstraints,
result : "binding",
type : sType,
value : oPathValue.prefix + oPathValue.value
};
});
} | javascript | function (oPathValue) {
var oModel = oPathValue.model,
oPromise;
Basics.expectType(oPathValue, "string");
oPromise = oModel.fetchObject(oPathValue.path + "/$");
if (oPromise.isPending() && !oPathValue.$$valueAsPromise) {
oPromise.caught();
oPromise = SyncPromise.resolve();
}
return oPromise.then(function (oProperty) {
var mConstraints,
oCurrencyOrUnitPromise,
sType = oProperty && oProperty.$Type;
if (oProperty && oPathValue.complexBinding) {
mConstraints = oModel.getConstraints(oProperty, oPathValue.path);
oCurrencyOrUnitPromise
= Expression.fetchCurrencyOrUnit(oPathValue, sType, mConstraints);
}
return oCurrencyOrUnitPromise || {
constraints : mConstraints,
result : "binding",
type : sType,
value : oPathValue.prefix + oPathValue.value
};
});
} | [
"function",
"(",
"oPathValue",
")",
"{",
"var",
"oModel",
"=",
"oPathValue",
".",
"model",
",",
"oPromise",
";",
"Basics",
".",
"expectType",
"(",
"oPathValue",
",",
"\"string\"",
")",
";",
"oPromise",
"=",
"oModel",
".",
"fetchObject",
"(",
"oPathValue",
... | Handling of "14.5.12 Expression edm:Path" and "14.5.13 Expression edm:PropertyPath".
If <code>oPathValue.path</code> references a property which has an
<code>Org.OData.Measures.V1.ISOCurrency</code> annotation, a composite result object for
a <code>sap.ui.model.odata.type.Currency</code> type with the currency, the currency code
and the currency customizing as parts is returned.
If <code>oPathValue.path</code> references a property which has an
<code>Org.OData.Measures.V1.Unit</code> annotation, a composite result object for a
<code>sap.ui.model.odata.type.Unit</code> type with the measures, the unit and the unit
customizing as parts is returned.
@param {object} oPathValue
model, path and value information pointing to the path (see Expression object)
@returns {sap.ui.base.SyncPromise}
a sync promise which resolves with the result object or is rejected with an error | [
"Handling",
"of",
"14",
".",
"5",
".",
"12",
"Expression",
"edm",
":",
"Path",
"and",
"14",
".",
"5",
".",
"13",
"Expression",
"edm",
":",
"PropertyPath",
".",
"If",
"<code",
">",
"oPathValue",
".",
"path<",
"/",
"code",
">",
"references",
"a",
"prop... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/_AnnotationHelperExpression.js#L720-L748 | train | Returns a promise that resolves to the property | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1007,
1063,
13075,
18168,
10244,
2140,
1027,
6728,
8988,
10175,
5657,
1012,
2944,
1010,
6728,
21716,
5562,
1025,
24078,
1012,
5987,
13874,
1006,
6728,
8988,
10175,
5657,
1010,
1000,
5164,
1000,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.