repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
berkeleybop/bbopx-js | npm/bbopx/bbopx.js | _rel_save_button_start | function _rel_save_button_start(){
//
//ll('looks like edge (in cb): ' + eeid);
var qstr ='input:radio[name=' + radio_name + ']:checked';
var rval = jQuery(qstr).val();
// ll('rval: ' + rval);
// // TODO: Should I report this too? Smells a
// // bit like the missing properties with
// // setParameter/s(),
/... | javascript | function _rel_save_button_start(){
//
//ll('looks like edge (in cb): ' + eeid);
var qstr ='input:radio[name=' + radio_name + ']:checked';
var rval = jQuery(qstr).val();
// ll('rval: ' + rval);
// // TODO: Should I report this too? Smells a
// // bit like the missing properties with
// // setParameter/s(),
/... | [
"function",
"_rel_save_button_start",
"(",
")",
"{",
"//",
"//ll('looks like edge (in cb): ' + eeid);",
"var",
"qstr",
"=",
"'input:radio[name='",
"+",
"radio_name",
"+",
"']:checked'",
";",
"var",
"rval",
"=",
"jQuery",
"(",
"qstr",
")",
".",
"val",
"(",
")",
"... | Add action listener to the save button. | [
"Add",
"action",
"listener",
"to",
"the",
"save",
"button",
"."
] | 847d87f5980f144c19c4caef3786044930fe51db | https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/npm/bbopx/bbopx.js#L5824-L5849 | train |
skerit/hawkejs | lib/client/is_visible.js | isChild | function isChild(child, parent) {
while (child = child.parentNode) {
if (child == parent) {
return true;
}
}
return false;
} | javascript | function isChild(child, parent) {
while (child = child.parentNode) {
if (child == parent) {
return true;
}
}
return false;
} | [
"function",
"isChild",
"(",
"child",
",",
"parent",
")",
"{",
"while",
"(",
"child",
"=",
"child",
".",
"parentNode",
")",
"{",
"if",
"(",
"child",
"==",
"parent",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if one element is a child of the other
@author Jelle De Loecker <jelle@develry.be>
@since 1.2.2
@version 1.2.2
@param {HTMLElement} element
@return {Boolean} | [
"Returns",
"true",
"if",
"one",
"element",
"is",
"a",
"child",
"of",
"the",
"other"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L61-L69 | train |
skerit/hawkejs | lib/client/is_visible.js | isHidden | function isHidden(element) {
var parent_styles,
overflow_x,
overflow_y,
overflow,
parent = element.parentNode,
styles;
if (!parent) {
return true;
}
// Always return false for the document element
if (isDocumentElement(parent)) {
return false;
}
// Get the computed styles of the ... | javascript | function isHidden(element) {
var parent_styles,
overflow_x,
overflow_y,
overflow,
parent = element.parentNode,
styles;
if (!parent) {
return true;
}
// Always return false for the document element
if (isDocumentElement(parent)) {
return false;
}
// Get the computed styles of the ... | [
"function",
"isHidden",
"(",
"element",
")",
"{",
"var",
"parent_styles",
",",
"overflow_x",
",",
"overflow_y",
",",
"overflow",
",",
"parent",
"=",
"element",
".",
"parentNode",
",",
"styles",
";",
"if",
"(",
"!",
"parent",
")",
"{",
"return",
"true",
"... | Returns true if the element or its parents
has no opacity, visibility or display
@author Jelle De Loecker <jelle@develry.be>
@since 1.2.2
@version 1.2.2
@param {HTMLElement} element
@return {Boolean} | [
"Returns",
"true",
"if",
"the",
"element",
"or",
"its",
"parents",
"has",
"no",
"opacity",
"visibility",
"or",
"display"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L83-L112 | train |
skerit/hawkejs | lib/client/is_visible.js | isDocumentElement | function isDocumentElement(element) {
if ( element == document.body
|| element.nodeType === 9
|| (element.nodeType == 1 && element.nodeName == 'HTML')) {
return true;
}
return false;
} | javascript | function isDocumentElement(element) {
if ( element == document.body
|| element.nodeType === 9
|| (element.nodeType == 1 && element.nodeName == 'HTML')) {
return true;
}
return false;
} | [
"function",
"isDocumentElement",
"(",
"element",
")",
"{",
"if",
"(",
"element",
"==",
"document",
".",
"body",
"||",
"element",
".",
"nodeType",
"===",
"9",
"||",
"(",
"element",
".",
"nodeType",
"==",
"1",
"&&",
"element",
".",
"nodeName",
"==",
"'HTML... | Returns true if the element is the body or document or html element
@author Jelle De Loecker <jelle@develry.be>
@since 1.2.2
@version 1.2.2
@param {HTMLElement} element
@return {Boolean} | [
"Returns",
"true",
"if",
"the",
"element",
"is",
"the",
"body",
"or",
"document",
"or",
"html",
"element"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L125-L133 | train |
skerit/hawkejs | lib/client/is_visible.js | collides | function collides(element_one, element_two) {
var result,
rect1,
rect2;
if (element_one.nodeName) {
rect1 = element_one.getBoundingClientRect();
} else {
rect1 = element_one;
}
if (element_two.nodeName) {
rect2 = element_two.getBoundingClientRect();
} else {
rect2 = element_two;
}
result =... | javascript | function collides(element_one, element_two) {
var result,
rect1,
rect2;
if (element_one.nodeName) {
rect1 = element_one.getBoundingClientRect();
} else {
rect1 = element_one;
}
if (element_two.nodeName) {
rect2 = element_two.getBoundingClientRect();
} else {
rect2 = element_two;
}
result =... | [
"function",
"collides",
"(",
"element_one",
",",
"element_two",
")",
"{",
"var",
"result",
",",
"rect1",
",",
"rect2",
";",
"if",
"(",
"element_one",
".",
"nodeName",
")",
"{",
"rect1",
"=",
"element_one",
".",
"getBoundingClientRect",
"(",
")",
";",
"}",
... | Returns true if the two elements or rectangles collide
@author Jelle De Loecker <jelle@develry.be>
@since 1.2.2
@version 1.2.2
@param {HTMLElement} element_one
@param {HTMLElement} element_two
@return {Boolean} | [
"Returns",
"true",
"if",
"the",
"two",
"elements",
"or",
"rectangles",
"collide"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L147-L173 | train |
skerit/hawkejs | lib/client/is_visible.js | elementAtRectPoints | function elementAtRectPoints(element, rect) {
var sample;
// Get the first sample
sample = document.elementFromPoint(rect.left, ~~rect.top);
if (sample == element || isChild(element, sample)) {
return true;
}
// Get the second sample
sample = document.elementFromPoint(rect.left, ~~rect.bottom);
if (sampl... | javascript | function elementAtRectPoints(element, rect) {
var sample;
// Get the first sample
sample = document.elementFromPoint(rect.left, ~~rect.top);
if (sample == element || isChild(element, sample)) {
return true;
}
// Get the second sample
sample = document.elementFromPoint(rect.left, ~~rect.bottom);
if (sampl... | [
"function",
"elementAtRectPoints",
"(",
"element",
",",
"rect",
")",
"{",
"var",
"sample",
";",
"// Get the first sample",
"sample",
"=",
"document",
".",
"elementFromPoint",
"(",
"rect",
".",
"left",
",",
"~",
"~",
"rect",
".",
"top",
")",
";",
"if",
"(",... | See if the element can be found at any of the rect's points
@author Jelle De Loecker <jelle@develry.be>
@since 1.2.2
@version 1.2.2
@param {HTMLElement} element
@param {Object} rect
@return {Boolean} | [
"See",
"if",
"the",
"element",
"can",
"be",
"found",
"at",
"any",
"of",
"the",
"rect",
"s",
"points"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L233-L266 | train |
skerit/hawkejs | lib/client/is_visible.js | _isVisible | function _isVisible(start_element, padding) {
var real_rect,
sample,
result,
rect;
// Check if the start element is in the document
if (!elementInDocument(start_element)) {
return false;
}
// Check if the element is explicitly hidden
if (isHidden(start_element)) {
return false;
}
if (padd... | javascript | function _isVisible(start_element, padding) {
var real_rect,
sample,
result,
rect;
// Check if the start element is in the document
if (!elementInDocument(start_element)) {
return false;
}
// Check if the element is explicitly hidden
if (isHidden(start_element)) {
return false;
}
if (padd... | [
"function",
"_isVisible",
"(",
"start_element",
",",
"padding",
")",
"{",
"var",
"real_rect",
",",
"sample",
",",
"result",
",",
"rect",
";",
"// Check if the start element is in the document",
"if",
"(",
"!",
"elementInDocument",
"(",
"start_element",
")",
")",
"... | The actual visibility checking
@author Jelle De Loecker <jelle@develry.be>
@since 1.2.2
@version 1.2.2
@param {HTMLElement} element
@param {Number} padding
@return {Boolean} | [
"The",
"actual",
"visibility",
"checking"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/client/is_visible.js#L280-L375 | train |
pixelsandbytes/h2o | examples/basic/server.js | defineApp | function defineApp(app) {
app.use('/foo', function appFoo(req, res) {
if (req.xhr) {
var body = {
foo: 'bar'
};
responseSender.sendJSON(res, body);
} else {
responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200);
}
});
... | javascript | function defineApp(app) {
app.use('/foo', function appFoo(req, res) {
if (req.xhr) {
var body = {
foo: 'bar'
};
responseSender.sendJSON(res, body);
} else {
responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200);
}
});
... | [
"function",
"defineApp",
"(",
"app",
")",
"{",
"app",
".",
"use",
"(",
"'/foo'",
",",
"function",
"appFoo",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"req",
".",
"xhr",
")",
"{",
"var",
"body",
"=",
"{",
"foo",
":",
"'bar'",
"}",
";",
"respo... | Defines the express application that your server will run
a.k.a. the routes, logic, etc. of your web application.
Simply setup the application exactly as you would when using express directly.
@param an express application, which this function will manipulate and augment | [
"Defines",
"the",
"express",
"application",
"that",
"your",
"server",
"will",
"run",
"a",
".",
"k",
".",
"a",
".",
"the",
"routes",
"logic",
"etc",
".",
"of",
"your",
"web",
"application",
".",
"Simply",
"setup",
"the",
"application",
"exactly",
"as",
"y... | 496e81d68f7765c53c4f24c73e8eeab74a4f532a | https://github.com/pixelsandbytes/h2o/blob/496e81d68f7765c53c4f24c73e8eeab74a4f532a/examples/basic/server.js#L20-L48 | train |
wavesoft/jbb-profile-three | profile-loader.js | function( cb ) {
// If we are running in node.js replace the THREE.js XHRLoader
// with an offline version.
var isBrowser=new Function("try {return this===window;}catch(e){ return false;}"); // browser exclude
if (!isBrowser()) {
// Expose 'THREE' for non-compatible scripts
global.THREE = THREE;
// ... | javascript | function( cb ) {
// If we are running in node.js replace the THREE.js XHRLoader
// with an offline version.
var isBrowser=new Function("try {return this===window;}catch(e){ return false;}"); // browser exclude
if (!isBrowser()) {
// Expose 'THREE' for non-compatible scripts
global.THREE = THREE;
// ... | [
"function",
"(",
"cb",
")",
"{",
"// If we are running in node.js replace the THREE.js XHRLoader",
"// with an offline version.",
"var",
"isBrowser",
"=",
"new",
"Function",
"(",
"\"try {return this===window;}catch(e){ return false;}\"",
")",
";",
"// browser exclude",
"if",
"(",... | Initialize profile loader | [
"Initialize",
"profile",
"loader"
] | 8539cfbb2d04b67999eee6e530fcaf03083e0e04 | https://github.com/wavesoft/jbb-profile-three/blob/8539cfbb2d04b67999eee6e530fcaf03083e0e04/profile-loader.js#L40-L58 | train | |
LINKIWI/react-loading-hoc | src/hoc.js | hoc | function hoc(Component) {
return class HOC extends React.Component {
/**
* Create a new instance of the HOC with state defaults.
*
* @param {Object} props Props passed from other HOCs.
*/
constructor(props) {
super(props);
this.state = {isLoading: false};
}
/**
*... | javascript | function hoc(Component) {
return class HOC extends React.Component {
/**
* Create a new instance of the HOC with state defaults.
*
* @param {Object} props Props passed from other HOCs.
*/
constructor(props) {
super(props);
this.state = {isLoading: false};
}
/**
*... | [
"function",
"hoc",
"(",
"Component",
")",
"{",
"return",
"class",
"HOC",
"extends",
"React",
".",
"Component",
"{",
"/**\n * Create a new instance of the HOC with state defaults.\n *\n * @param {Object} props Props passed from other HOCs.\n */",
"constructor",
"(",
... | Create a higher-order component wrapping a child component, passing along all props as a proxy.
@param {XML} Component The React component to wrap.
@returns {HOC} A wrapper component that exposes additional component props accessible via the
child component. | [
"Create",
"a",
"higher",
"-",
"order",
"component",
"wrapping",
"a",
"child",
"component",
"passing",
"along",
"all",
"props",
"as",
"a",
"proxy",
"."
] | 3f521ec7897813df54935e9cfd6336f97c9bec80 | https://github.com/LINKIWI/react-loading-hoc/blob/3f521ec7897813df54935e9cfd6336f97c9bec80/src/hoc.js#L10-L61 | train |
redisjs/jsr-format | lib/format.js | repeat | function repeat(str, amount) {
var s = ''
, i;
for(i = 0;i < amount;i++) {
s += str;
}
return s;
} | javascript | function repeat(str, amount) {
var s = ''
, i;
for(i = 0;i < amount;i++) {
s += str;
}
return s;
} | [
"function",
"repeat",
"(",
"str",
",",
"amount",
")",
"{",
"var",
"s",
"=",
"''",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"amount",
";",
"i",
"++",
")",
"{",
"s",
"+=",
"str",
";",
"}",
"return",
"s",
";",
"}"
] | Repeat a string by amount. | [
"Repeat",
"a",
"string",
"by",
"amount",
"."
] | 375142a4c0b177cd1a69947a4d4880839f964d73 | https://github.com/redisjs/jsr-format/blob/375142a4c0b177cd1a69947a4d4880839f964d73/lib/format.js#L10-L17 | train |
antoniobrandao/mongoose3-bsonfix-bson | lib/bson/bson.js | function(string, start, end) {
var crc = 0
var x = 0;
var y = 0;
crc = crc ^ (-1);
for(var i = start, iTop = end; i < iTop;i++) {
y = (crc ^ string[i]) & 0xFF;
x = table[y];
crc = (crc >>> 8) ^ x;
}
return crc ^ (-1);
} | javascript | function(string, start, end) {
var crc = 0
var x = 0;
var y = 0;
crc = crc ^ (-1);
for(var i = start, iTop = end; i < iTop;i++) {
y = (crc ^ string[i]) & 0xFF;
x = table[y];
crc = (crc >>> 8) ^ x;
}
return crc ^ (-1);
} | [
"function",
"(",
"string",
",",
"start",
",",
"end",
")",
"{",
"var",
"crc",
"=",
"0",
"var",
"x",
"=",
"0",
";",
"var",
"y",
"=",
"0",
";",
"crc",
"=",
"crc",
"^",
"(",
"-",
"1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"start",
",",
"iTop... | CRC32 hash method, Fast and enough versitility for our usage
@ignore
@api private | [
"CRC32",
"hash",
"method",
"Fast",
"and",
"enough",
"versitility",
"for",
"our",
"usage"
] | b0eae261710704de70f6f282669cf020dbd6a490 | https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/bson.js#L1063-L1076 | train | |
antoniobrandao/mongoose3-bsonfix-bson | lib/bson/bson.js | function(functionCache, hash, functionString, object) {
// Contains the value we are going to set
var value = null;
// Check for cache hit, eval if missing and return cached function
if(functionCache[hash] == null) {
eval("value = " + functionString);
functionCache[hash] = value;
}
// Set the objec... | javascript | function(functionCache, hash, functionString, object) {
// Contains the value we are going to set
var value = null;
// Check for cache hit, eval if missing and return cached function
if(functionCache[hash] == null) {
eval("value = " + functionString);
functionCache[hash] = value;
}
// Set the objec... | [
"function",
"(",
"functionCache",
",",
"hash",
",",
"functionString",
",",
"object",
")",
"{",
"// Contains the value we are going to set",
"var",
"value",
"=",
"null",
";",
"// Check for cache hit, eval if missing and return cached function",
"if",
"(",
"functionCache",
"[... | Ensure eval is isolated.
@ignore
@api private | [
"Ensure",
"eval",
"is",
"isolated",
"."
] | b0eae261710704de70f6f282669cf020dbd6a490 | https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/bson.js#L1122-L1133 | train | |
antoniobrandao/mongoose3-bsonfix-bson | lib/bson/bson.js | function() {
// Get the start search index
var i = index;
// Locate the end of the c string
while(buffer[i] !== 0x00 && i < buffer.length) {
i++
}
// If are at the end of the buffer there is a problem with the document
if(i >= buffer.length) throw new Error("Bad BSON Document: illega... | javascript | function() {
// Get the start search index
var i = index;
// Locate the end of the c string
while(buffer[i] !== 0x00 && i < buffer.length) {
i++
}
// If are at the end of the buffer there is a problem with the document
if(i >= buffer.length) throw new Error("Bad BSON Document: illega... | [
"function",
"(",
")",
"{",
"// Get the start search index",
"var",
"i",
"=",
"index",
";",
"// Locate the end of the c string",
"while",
"(",
"buffer",
"[",
"i",
"]",
"!==",
"0x00",
"&&",
"i",
"<",
"buffer",
".",
"length",
")",
"{",
"i",
"++",
"}",
"// If ... | Reads in a C style string | [
"Reads",
"in",
"a",
"C",
"style",
"string"
] | b0eae261710704de70f6f282669cf020dbd6a490 | https://github.com/antoniobrandao/mongoose3-bsonfix-bson/blob/b0eae261710704de70f6f282669cf020dbd6a490/lib/bson/bson.js#L1197-L1212 | train | |
0of/grunt-env-config | index.js | enableEnvConfig | function enableEnvConfig (grunt, opts) {
var options = opts || {};
var cacheConfig = options.cache;
var getRaw = grunt.config.getRaw;
grunt.config.getRaw = function getRawWrapper (prop) {
if (prop) {
prop = grunt.config.getPropString(prop);
var required = propRequire(p... | javascript | function enableEnvConfig (grunt, opts) {
var options = opts || {};
var cacheConfig = options.cache;
var getRaw = grunt.config.getRaw;
grunt.config.getRaw = function getRawWrapper (prop) {
if (prop) {
prop = grunt.config.getPropString(prop);
var required = propRequire(p... | [
"function",
"enableEnvConfig",
"(",
"grunt",
",",
"opts",
")",
"{",
"var",
"options",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"cacheConfig",
"=",
"options",
".",
"cache",
";",
"var",
"getRaw",
"=",
"grunt",
".",
"config",
".",
"getRaw",
";",
"grunt",
... | enable env config
@param {Object}[grunt] grunt object
@param {Object} [opts]
@param {Boolean} [options.cache] replace $require template string by required result
@public | [
"enable",
"env",
"config"
] | d2d7d3499ac9136c85e8e72ca008721e3821acf7 | https://github.com/0of/grunt-env-config/blob/d2d7d3499ac9136c85e8e72ca008721e3821acf7/index.js#L11-L92 | train |
ryanramage/schema-couch-boilerplate | jam/json.edit/addons/adsafe/lib/jslint.js | one_space | function one_space(left, right) {
left = left || token;
right = right || next_token;
if (right.id !== '(end)' && !option.white &&
(token.line !== right.line ||
token.thru + 1 !== right.from)) {
warn('expected_space_a_b', right, artifact(token), artifac... | javascript | function one_space(left, right) {
left = left || token;
right = right || next_token;
if (right.id !== '(end)' && !option.white &&
(token.line !== right.line ||
token.thru + 1 !== right.from)) {
warn('expected_space_a_b', right, artifact(token), artifac... | [
"function",
"one_space",
"(",
"left",
",",
"right",
")",
"{",
"left",
"=",
"left",
"||",
"token",
";",
"right",
"=",
"right",
"||",
"next_token",
";",
"if",
"(",
"right",
".",
"id",
"!==",
"'(end)'",
"&&",
"!",
"option",
".",
"white",
"&&",
"(",
"t... | Functions for conformance of whitespace. | [
"Functions",
"for",
"conformance",
"of",
"whitespace",
"."
] | c323516f02c90101aa6b21592bfdd2a6f2e47680 | https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/json.edit/addons/adsafe/lib/jslint.js#L2026-L2034 | train |
ryanramage/schema-couch-boilerplate | jam/json.edit/addons/adsafe/lib/jslint.js | symbol | function symbol(s, p) {
var x = syntax[s];
if (!x || typeof x !== 'object') {
syntax[s] = x = {
id: s,
lbp: p || 0,
string: s
};
}
return x;
} | javascript | function symbol(s, p) {
var x = syntax[s];
if (!x || typeof x !== 'object') {
syntax[s] = x = {
id: s,
lbp: p || 0,
string: s
};
}
return x;
} | [
"function",
"symbol",
"(",
"s",
",",
"p",
")",
"{",
"var",
"x",
"=",
"syntax",
"[",
"s",
"]",
";",
"if",
"(",
"!",
"x",
"||",
"typeof",
"x",
"!==",
"'object'",
")",
"{",
"syntax",
"[",
"s",
"]",
"=",
"x",
"=",
"{",
"id",
":",
"s",
",",
"l... | Functional constructors for making the symbols that will be inherited by tokens. | [
"Functional",
"constructors",
"for",
"making",
"the",
"symbols",
"that",
"will",
"be",
"inherited",
"by",
"tokens",
"."
] | c323516f02c90101aa6b21592bfdd2a6f2e47680 | https://github.com/ryanramage/schema-couch-boilerplate/blob/c323516f02c90101aa6b21592bfdd2a6f2e47680/jam/json.edit/addons/adsafe/lib/jslint.js#L2232-L2242 | train |
lokijs/fenrir-core | client/entityTracker.js | onEntityDraw | function onEntityDraw(entity, context) {
context.save();
if (selectionService.isSelected(entity)) {
context.strokeStyle = '#f33';
} else {
context.strokeStyle = '#666';
}
context.strokeRect(
entity.pos.x, entity.pos.y, entity.size.x, entity.size.y);
context.re... | javascript | function onEntityDraw(entity, context) {
context.save();
if (selectionService.isSelected(entity)) {
context.strokeStyle = '#f33';
} else {
context.strokeStyle = '#666';
}
context.strokeRect(
entity.pos.x, entity.pos.y, entity.size.x, entity.size.y);
context.re... | [
"function",
"onEntityDraw",
"(",
"entity",
",",
"context",
")",
"{",
"context",
".",
"save",
"(",
")",
";",
"if",
"(",
"selectionService",
".",
"isSelected",
"(",
"entity",
")",
")",
"{",
"context",
".",
"strokeStyle",
"=",
"'#f33'",
";",
"}",
"else",
... | Subscribed to entity draw event. | [
"Subscribed",
"to",
"entity",
"draw",
"event",
"."
] | 15aea869eb74b5bb998e07328aee6b1c6fe21d80 | https://github.com/lokijs/fenrir-core/blob/15aea869eb74b5bb998e07328aee6b1c6fe21d80/client/entityTracker.js#L22-L32 | train |
duniter/duniter-common | lib/crypto/keyring.js | verify | function verify(rawMsg, rawSig, rawPub) {
const msg = nacl.util.decodeUTF8(rawMsg);
const sig = nacl.util.decodeBase64(rawSig);
const pub = base58.decode(rawPub);
const m = new Uint8Array(crypto_sign_BYTES + msg.length);
const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
let i;
for (i = 0; i < cry... | javascript | function verify(rawMsg, rawSig, rawPub) {
const msg = nacl.util.decodeUTF8(rawMsg);
const sig = nacl.util.decodeBase64(rawSig);
const pub = base58.decode(rawPub);
const m = new Uint8Array(crypto_sign_BYTES + msg.length);
const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
let i;
for (i = 0; i < cry... | [
"function",
"verify",
"(",
"rawMsg",
",",
"rawSig",
",",
"rawPub",
")",
"{",
"const",
"msg",
"=",
"nacl",
".",
"util",
".",
"decodeUTF8",
"(",
"rawMsg",
")",
";",
"const",
"sig",
"=",
"nacl",
".",
"util",
".",
"decodeBase64",
"(",
"rawSig",
")",
";",... | Verify a signature against data & public key.
Return true of false as callback argument. | [
"Verify",
"a",
"signature",
"against",
"data",
"&",
"public",
"key",
".",
"Return",
"true",
"of",
"false",
"as",
"callback",
"argument",
"."
] | 4f5b64150379c81f9175c37fa4f043835213b0d9 | https://github.com/duniter/duniter-common/blob/4f5b64150379c81f9175c37fa4f043835213b0d9/lib/crypto/keyring.js#L15-L27 | train |
hypergroup/hyper-path | build/build.js | require | function require(name) {
var module = require.modules[name];
if (!module) throw new Error('failed to require "' + name + '"');
if (!('exports' in module) && typeof module.definition === 'function') {
module.client = module.component = true;
module.definition.call(this, module.exports = {}, module);
d... | javascript | function require(name) {
var module = require.modules[name];
if (!module) throw new Error('failed to require "' + name + '"');
if (!('exports' in module) && typeof module.definition === 'function') {
module.client = module.component = true;
module.definition.call(this, module.exports = {}, module);
d... | [
"function",
"require",
"(",
"name",
")",
"{",
"var",
"module",
"=",
"require",
".",
"modules",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"module",
")",
"throw",
"new",
"Error",
"(",
"'failed to require \"'",
"+",
"name",
"+",
"'\"'",
")",
";",
"if",
"("... | Require the module at `name`.
@param {String} name
@return {Object} exports
@api public | [
"Require",
"the",
"module",
"at",
"name",
"."
] | 937490d22316d00fae60be0562e690d338c27b35 | https://github.com/hypergroup/hyper-path/blob/937490d22316d00fae60be0562e690d338c27b35/build/build.js#L12-L23 | train |
hypergroup/hyper-path | build/build.js | Request | function Request(path, client, delim) {
if (!(this instanceof Request)) return new Request(path, client);
// init client
this.client = client;
if (!this.client) throw new Error('hyper-path requires a client to be passed as the second argument');
this.delim = delim || '.';
this.parse(path);
this._listen... | javascript | function Request(path, client, delim) {
if (!(this instanceof Request)) return new Request(path, client);
// init client
this.client = client;
if (!this.client) throw new Error('hyper-path requires a client to be passed as the second argument');
this.delim = delim || '.';
this.parse(path);
this._listen... | [
"function",
"Request",
"(",
"path",
",",
"client",
",",
"delim",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Request",
")",
")",
"return",
"new",
"Request",
"(",
"path",
",",
"client",
")",
";",
"// init client",
"this",
".",
"client",
"=",
... | Create a hyper-path request
@param {String} path
@param {Client} client | [
"Create",
"a",
"hyper",
"-",
"path",
"request"
] | 937490d22316d00fae60be0562e690d338c27b35 | https://github.com/hypergroup/hyper-path/blob/937490d22316d00fae60be0562e690d338c27b35/build/build.js#L163-L176 | train |
hypergroup/hyper-path | build/build.js | firstDefined | function firstDefined() {
for (var i = 0, l = arguments.length, v; i < l; i++) {
v = arguments[i];
if (typeof v !== 'undefined') return v;
}
return v;
} | javascript | function firstDefined() {
for (var i = 0, l = arguments.length, v; i < l; i++) {
v = arguments[i];
if (typeof v !== 'undefined') return v;
}
return v;
} | [
"function",
"firstDefined",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"arguments",
".",
"length",
",",
"v",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"v",
"=",
"arguments",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
... | Choose the first defined value
@api private | [
"Choose",
"the",
"first",
"defined",
"value"
] | 937490d22316d00fae60be0562e690d338c27b35 | https://github.com/hypergroup/hyper-path/blob/937490d22316d00fae60be0562e690d338c27b35/build/build.js#L536-L542 | train |
klesh/bblib | textlines.js | process | async function process({inputStream, skip, lineHandler, quiet, throttle}) {
skip = skip || 0;
throttle = throttle || Number.MAX_VALUE;
return await new P((resolve, reject) => {
let cursor = 0;
let concurrency = 0;
const errors = [];
const reader = readline.createInterface({input: inputStream});
... | javascript | async function process({inputStream, skip, lineHandler, quiet, throttle}) {
skip = skip || 0;
throttle = throttle || Number.MAX_VALUE;
return await new P((resolve, reject) => {
let cursor = 0;
let concurrency = 0;
const errors = [];
const reader = readline.createInterface({input: inputStream});
... | [
"async",
"function",
"process",
"(",
"{",
"inputStream",
",",
"skip",
",",
"lineHandler",
",",
"quiet",
",",
"throttle",
"}",
")",
"{",
"skip",
"=",
"skip",
"||",
"0",
";",
"throttle",
"=",
"throttle",
"||",
"Number",
".",
"MAX_VALUE",
";",
"return",
"... | process lines concurrently
@param {object} opts
@param {ReadableStream} opts.inputStream - stream to be read from
@param {function(line:string, cursor:number)} opts.lineHandler
@param {number} [opts.skip=0] - number of lines to be skipped
@param {boolean} [opts.quiet=false] - suppress all errors threw by lineHandler
@... | [
"process",
"lines",
"concurrently"
] | 5059964fc41b45c1ab87dd9ae9863b3fac1ee470 | https://github.com/klesh/bblib/blob/5059964fc41b45c1ab87dd9ae9863b3fac1ee470/textlines.js#L15-L59 | train |
kerryhatcher/AdminJS-core-navigation | hawtio-core-navigation.js | itemIsValid | function itemIsValid(item) {
if (!('isValid' in item)) {
return true;
}
if (_.isFunction(item.isValid)) {
return item.isValid();
}
return false;
} | javascript | function itemIsValid(item) {
if (!('isValid' in item)) {
return true;
}
if (_.isFunction(item.isValid)) {
return item.isValid();
}
return false;
} | [
"function",
"itemIsValid",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"(",
"'isValid'",
"in",
"item",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"_",
".",
"isFunction",
"(",
"item",
".",
"isValid",
")",
")",
"{",
"return",
"item",
".",
"is... | helper function for testing nav items | [
"helper",
"function",
"for",
"testing",
"nav",
"items"
] | 8911560391491ff425c5c323b727401510a38b7d | https://github.com/kerryhatcher/AdminJS-core-navigation/blob/8911560391491ff425c5c323b727401510a38b7d/hawtio-core-navigation.js#L650-L658 | train |
OffByNone/Omniscience-UPnP | Chrome_module.js | mine | function mine(js) {
var names = [];
var state = 0;
var ident;
var quote;
var name;
var isIdent = /[a-z0-9_.]/i;
var isWhitespace = /[ \r\n\t]/;
function $start(char) {
if (char === "/") {
return $slash;
}
if (char === "'" || char === '"') {
quote = char;
return $string;
}
if... | javascript | function mine(js) {
var names = [];
var state = 0;
var ident;
var quote;
var name;
var isIdent = /[a-z0-9_.]/i;
var isWhitespace = /[ \r\n\t]/;
function $start(char) {
if (char === "/") {
return $slash;
}
if (char === "'" || char === '"') {
quote = char;
return $string;
}
if... | [
"function",
"mine",
"(",
"js",
")",
"{",
"var",
"names",
"=",
"[",
"]",
";",
"var",
"state",
"=",
"0",
";",
"var",
"ident",
";",
"var",
"quote",
";",
"var",
"name",
";",
"var",
"isIdent",
"=",
"/",
"[a-z0-9_.]",
"/",
"i",
";",
"var",
"isWhitespac... | Mine a string for require calls and export the module names Extract all require calls using a proper state-machine parser. | [
"Mine",
"a",
"string",
"for",
"require",
"calls",
"and",
"export",
"the",
"module",
"names",
"Extract",
"all",
"require",
"calls",
"using",
"a",
"proper",
"state",
"-",
"machine",
"parser",
"."
] | 4a6da31f5898bd32d44e8fbad312444cc30809bf | https://github.com/OffByNone/Omniscience-UPnP/blob/4a6da31f5898bd32d44e8fbad312444cc30809bf/Chrome_module.js#L281-L386 | train |
wshager/js-rrb-vector | src/concat.js | allocate | function allocate(height, length) {
var node = new Array(length);
node.height = height;
if (height > 0) {
node.sizes = new Array(length);
}
return node;
} | javascript | function allocate(height, length) {
var node = new Array(length);
node.height = height;
if (height > 0) {
node.sizes = new Array(length);
}
return node;
} | [
"function",
"allocate",
"(",
"height",
",",
"length",
")",
"{",
"var",
"node",
"=",
"new",
"Array",
"(",
"length",
")",
";",
"node",
".",
"height",
"=",
"height",
";",
"if",
"(",
"height",
">",
"0",
")",
"{",
"node",
".",
"sizes",
"=",
"new",
"Ar... | Creates a node or leaf with a given length at their arrays for performance. Is only used by shuffle. | [
"Creates",
"a",
"node",
"or",
"leaf",
"with",
"a",
"given",
"length",
"at",
"their",
"arrays",
"for",
"performance",
".",
"Is",
"only",
"used",
"by",
"shuffle",
"."
] | 766c3c12f658cc251dce028460c4eca4e33d5254 | https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/src/concat.js#L225-L232 | train |
wshager/js-rrb-vector | src/concat.js | saveSlot | function saveSlot(aList, bList, index, slot) {
setEither(aList, bList, index, slot);
var isInFirst = (index === 0 || index === aList.sizes.length);
var len = isInFirst ? 0 : getEither(aList.sizes, bList.sizes, index - 1);
setEither(aList.sizes, bList.sizes, index, len + length(slot));
} | javascript | function saveSlot(aList, bList, index, slot) {
setEither(aList, bList, index, slot);
var isInFirst = (index === 0 || index === aList.sizes.length);
var len = isInFirst ? 0 : getEither(aList.sizes, bList.sizes, index - 1);
setEither(aList.sizes, bList.sizes, index, len + length(slot));
} | [
"function",
"saveSlot",
"(",
"aList",
",",
"bList",
",",
"index",
",",
"slot",
")",
"{",
"setEither",
"(",
"aList",
",",
"bList",
",",
"index",
",",
"slot",
")",
";",
"var",
"isInFirst",
"=",
"(",
"index",
"===",
"0",
"||",
"index",
"===",
"aList",
... | helper for setting picking a slot between to nodes
@param {Node} aList - a non-leaf node
@param {Node} bList - a non-leaf node
@param {number} index
@param {Node} slot | [
"helper",
"for",
"setting",
"picking",
"a",
"slot",
"between",
"to",
"nodes"
] | 766c3c12f658cc251dce028460c4eca4e33d5254 | https://github.com/wshager/js-rrb-vector/blob/766c3c12f658cc251dce028460c4eca4e33d5254/src/concat.js#L241-L248 | train |
raincatcher-beta/raincatcher-result | lib/client/result-client/index.js | start | function start() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TO... | javascript | function start() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TO... | [
"function",
"start",
"(",
")",
"{",
"var",
"donePromise",
"=",
"mediator",
".",
"promise",
"(",
"resultSyncSubscribers",
".",
"getTopic",
"(",
"CONSTANTS",
".",
"TOPICS",
".",
"START",
",",
"CONSTANTS",
".",
"DONE_PREFIX",
")",
")",
";",
"var",
"errorPromise... | Starting the synchronisation process for results. | [
"Starting",
"the",
"synchronisation",
"process",
"for",
"results",
"."
] | 8ed874f22aecb8105998635b2cee6b13abe01647 | https://github.com/raincatcher-beta/raincatcher-result/blob/8ed874f22aecb8105998635b2cee6b13abe01647/lib/client/result-client/index.js#L123-L132 | train |
raincatcher-beta/raincatcher-result | lib/client/result-client/index.js | stop | function stop() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS... | javascript | function stop() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS... | [
"function",
"stop",
"(",
")",
"{",
"var",
"donePromise",
"=",
"mediator",
".",
"promise",
"(",
"resultSyncSubscribers",
".",
"getTopic",
"(",
"CONSTANTS",
".",
"TOPICS",
".",
"STOP",
",",
"CONSTANTS",
".",
"DONE_PREFIX",
")",
")",
";",
"var",
"errorPromise",... | Stopping the synchronisation process for results. | [
"Stopping",
"the",
"synchronisation",
"process",
"for",
"results",
"."
] | 8ed874f22aecb8105998635b2cee6b13abe01647 | https://github.com/raincatcher-beta/raincatcher-result/blob/8ed874f22aecb8105998635b2cee6b13abe01647/lib/client/result-client/index.js#L137-L145 | train |
raincatcher-beta/raincatcher-result | lib/client/result-client/index.js | forceSync | function forceSync() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic... | javascript | function forceSync() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic... | [
"function",
"forceSync",
"(",
")",
"{",
"var",
"donePromise",
"=",
"mediator",
".",
"promise",
"(",
"resultSyncSubscribers",
".",
"getTopic",
"(",
"CONSTANTS",
".",
"TOPICS",
".",
"FORCE_SYNC",
",",
"CONSTANTS",
".",
"DONE_PREFIX",
")",
")",
";",
"var",
"err... | Forcing the results to sync to the remote store. | [
"Forcing",
"the",
"results",
"to",
"sync",
"to",
"the",
"remote",
"store",
"."
] | 8ed874f22aecb8105998635b2cee6b13abe01647 | https://github.com/raincatcher-beta/raincatcher-result/blob/8ed874f22aecb8105998635b2cee6b13abe01647/lib/client/result-client/index.js#L150-L158 | train |
cli-kit/cli-help | lib/doc/markdown.js | function() {
this.colon = false;
HelpDocument.apply(this, arguments);
this.format = fmt.MARKDOWN_FORMAT;
this.vanilla = true;
this.useCustom = true;
// disable columns
this.use = false;
var format = '* `%s`: %s';
var overrides = {
synopsis: '```synopsis\n%s\n```'
}
this.markdown = {};
var co... | javascript | function() {
this.colon = false;
HelpDocument.apply(this, arguments);
this.format = fmt.MARKDOWN_FORMAT;
this.vanilla = true;
this.useCustom = true;
// disable columns
this.use = false;
var format = '* `%s`: %s';
var overrides = {
synopsis: '```synopsis\n%s\n```'
}
this.markdown = {};
var co... | [
"function",
"(",
")",
"{",
"this",
".",
"colon",
"=",
"false",
";",
"HelpDocument",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"format",
"=",
"fmt",
".",
"MARKDOWN_FORMAT",
";",
"this",
".",
"vanilla",
"=",
"true",
";",
"this... | Help document that outputs as markdown. | [
"Help",
"document",
"that",
"outputs",
"as",
"markdown",
"."
] | 09613efdd753452b466d4deb7c5391c4926e3f04 | https://github.com/cli-kit/cli-help/blob/09613efdd753452b466d4deb7c5391c4926e3f04/lib/doc/markdown.js#L13-L32 | train | |
yefremov/aggregatejs | average.js | average | function average(array) {
var length = array.length;
if (length === 0) {
throw new RangeError("Error");
}
var index = -1;
var result = 0;
while (++index < length) {
result += array[index];
}
return result / length;
} | javascript | function average(array) {
var length = array.length;
if (length === 0) {
throw new RangeError("Error");
}
var index = -1;
var result = 0;
while (++index < length) {
result += array[index];
}
return result / length;
} | [
"function",
"average",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"RangeError",
"(",
"\"Error\"",
")",
";",
"}",
"var",
"index",
"=",
"-",
"1",
";",
"var",
... | Returns the average of the numbers in `array`.
@param {Array} array Range of numbers to get the average.
@return {number}
@example
average([100, -100, 150, -50, 100, 250]);
// => 75 | [
"Returns",
"the",
"average",
"of",
"the",
"numbers",
"in",
"array",
"."
] | 932b28a15a5707135e7095950000a838db409511 | https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/average.js#L19-L34 | train |
tolokoban/ToloFrameWork | lib/configuration-loader.js | checkCompilationType | function checkCompilationType( config ) {
if ( config.tfw.compile.type === 'firefoxos' ) {
config.tfw.compile.type = 'web';
} else {
config.tfw.compile.type = 'desktop';
}
} | javascript | function checkCompilationType( config ) {
if ( config.tfw.compile.type === 'firefoxos' ) {
config.tfw.compile.type = 'web';
} else {
config.tfw.compile.type = 'desktop';
}
} | [
"function",
"checkCompilationType",
"(",
"config",
")",
"{",
"if",
"(",
"config",
".",
"tfw",
".",
"compile",
".",
"type",
"===",
"'firefoxos'",
")",
"{",
"config",
".",
"tfw",
".",
"compile",
".",
"type",
"=",
"'web'",
";",
"}",
"else",
"{",
"config",... | Prior to version 0.46, compilation types were `firefoxos` and `nodewebkit`.
Now, we use `web` and `desktop`.
@param {object} config - Configuration as object.
@returns {undefined} | [
"Prior",
"to",
"version",
"0",
".",
"46",
"compilation",
"types",
"were",
"firefoxos",
"and",
"nodewebkit",
".",
"Now",
"we",
"use",
"web",
"and",
"desktop",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/configuration-loader.js#L151-L157 | train |
darkoverlordofdata/liquid.coffee | example/scrumptious/public/js/main.js | handleStatusChange | function handleStatusChange(response) {
if (response.authResponse) {
logResponse(response);
window.location.hash = '#menu';
updateUserInfo(response);
} else {
window.location.hash = '#login';
}
} | javascript | function handleStatusChange(response) {
if (response.authResponse) {
logResponse(response);
window.location.hash = '#menu';
updateUserInfo(response);
} else {
window.location.hash = '#login';
}
} | [
"function",
"handleStatusChange",
"(",
"response",
")",
"{",
"if",
"(",
"response",
".",
"authResponse",
")",
"{",
"logResponse",
"(",
"response",
")",
";",
"window",
".",
"location",
".",
"hash",
"=",
"'#menu'",
";",
"updateUserInfo",
"(",
"response",
")",
... | AUTHENTICATION Handle status changes | [
"AUTHENTICATION",
"Handle",
"status",
"changes"
] | 7480f98580f3b9e6358e564e6d9d1a7ecd562bb8 | https://github.com/darkoverlordofdata/liquid.coffee/blob/7480f98580f3b9e6358e564e6d9d1a7ecd562bb8/example/scrumptious/public/js/main.js#L182-L190 | train |
darkoverlordofdata/liquid.coffee | example/scrumptious/public/js/main.js | displayMealList | function displayMealList() {
// Meal list
logResponse("[displayMealList] displaying meal list.");
var tmpl = $("#meal_list_tmpl").html();
var output = Mustache.to_html(tmpl, meals);
$("#meal-list").html(output).listview('refresh');
} | javascript | function displayMealList() {
// Meal list
logResponse("[displayMealList] displaying meal list.");
var tmpl = $("#meal_list_tmpl").html();
var output = Mustache.to_html(tmpl, meals);
$("#meal-list").html(output).listview('refresh');
} | [
"function",
"displayMealList",
"(",
")",
"{",
"// Meal list",
"logResponse",
"(",
"\"[displayMealList] displaying meal list.\"",
")",
";",
"var",
"tmpl",
"=",
"$",
"(",
"\"#meal_list_tmpl\"",
")",
".",
"html",
"(",
")",
";",
"var",
"output",
"=",
"Mustache",
"."... | DATA FETCH AND DISPLAY Meals | [
"DATA",
"FETCH",
"AND",
"DISPLAY",
"Meals"
] | 7480f98580f3b9e6358e564e6d9d1a7ecd562bb8 | https://github.com/darkoverlordofdata/liquid.coffee/blob/7480f98580f3b9e6358e564e6d9d1a7ecd562bb8/example/scrumptious/public/js/main.js#L324-L330 | train |
buzzin0609/tagbuildr | src/appendChildren.js | appendChildren | function appendChildren(children, el) {
ensureArray(children)
.forEach(append.bind(el));
return el;
} | javascript | function appendChildren(children, el) {
ensureArray(children)
.forEach(append.bind(el));
return el;
} | [
"function",
"appendChildren",
"(",
"children",
",",
"el",
")",
"{",
"ensureArray",
"(",
"children",
")",
".",
"forEach",
"(",
"append",
".",
"bind",
"(",
"el",
")",
")",
";",
"return",
"el",
";",
"}"
] | Convenience function to add multiple children nodes to the element
@param {Array} children a mixed array of strings|elements|html to add to the element
@param {Element} el the dom element | [
"Convenience",
"function",
"to",
"add",
"multiple",
"children",
"nodes",
"to",
"the",
"element"
] | 9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542 | https://github.com/buzzin0609/tagbuildr/blob/9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542/src/appendChildren.js#L8-L12 | train |
vindm/procss | example/plugin.js | function(scope) {
console.log(
'Before start to process input files:',
scope.files.map(function(file) {
var rulesCount = file.parsed.rules.length;
rulesCount += ' rule' + (rulesCount > 1 ? 's' : '');
return '\n' + rulesCount + ' in ' + fi... | javascript | function(scope) {
console.log(
'Before start to process input files:',
scope.files.map(function(file) {
var rulesCount = file.parsed.rules.length;
rulesCount += ' rule' + (rulesCount > 1 ? 's' : '');
return '\n' + rulesCount + ' in ' + fi... | [
"function",
"(",
"scope",
")",
"{",
"console",
".",
"log",
"(",
"'Before start to process input files:'",
",",
"scope",
".",
"files",
".",
"map",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"rulesCount",
"=",
"file",
".",
"parsed",
".",
"rules",
".",
... | Will be called before start to process input files
@param {Object} scope
@param {File[]} scope.files Parsed input files | [
"Will",
"be",
"called",
"before",
"start",
"to",
"process",
"input",
"files"
] | b08e2169f23a9648a9c10fe800e077d1392bbfe5 | https://github.com/vindm/procss/blob/b08e2169f23a9648a9c10fe800e077d1392bbfe5/example/plugin.js#L35-L46 | train | |
vindm/procss | example/plugin.js | function(scope, config) {
var isAngry = config.mood === 'angry',
isColorExist;
console.log(
'\nProcessing command: ' + scope.command.name
);
if (scope.decl.prop === 'content') {
scope.decl.value = isAngry ?
'"BAD BAD NOT GOOD"' :
... | javascript | function(scope, config) {
var isAngry = config.mood === 'angry',
isColorExist;
console.log(
'\nProcessing command: ' + scope.command.name
);
if (scope.decl.prop === 'content') {
scope.decl.value = isAngry ?
'"BAD BAD NOT GOOD"' :
... | [
"function",
"(",
"scope",
",",
"config",
")",
"{",
"var",
"isAngry",
"=",
"config",
".",
"mood",
"===",
"'angry'",
",",
"isColorExist",
";",
"console",
".",
"log",
"(",
"'\\nProcessing command: '",
"+",
"scope",
".",
"command",
".",
"name",
")",
";",
"if... | Will be called on each parsed command
@param {Object} scope
@param {File[]} scope.files Parsed input files
@param {File} scope.file Current processing file node
@param {Rule} scope.rule Current processing rule node
@param {Decl} scope.decl Current processing declaration node
@param {Command} scope.command Current proce... | [
"Will",
"be",
"called",
"on",
"each",
"parsed",
"command"
] | b08e2169f23a9648a9c10fe800e077d1392bbfe5 | https://github.com/vindm/procss/blob/b08e2169f23a9648a9c10fe800e077d1392bbfe5/example/plugin.js#L72-L107 | train | |
GerHobbelt/jison-helpers-lib | dist/helpers-lib-umd.js | dquote | function dquote(s) {
var sq = (s.indexOf('\'') >= 0);
var dq = (s.indexOf('"') >= 0);
if (sq && dq) {
s = s.replace(/"/g, '\\"');
dq = false;
}
if (dq) {
s = '\'' + s + '\'';
}
else {
s = '"' + s + '"';
}
return s;
} | javascript | function dquote(s) {
var sq = (s.indexOf('\'') >= 0);
var dq = (s.indexOf('"') >= 0);
if (sq && dq) {
s = s.replace(/"/g, '\\"');
dq = false;
}
if (dq) {
s = '\'' + s + '\'';
}
else {
s = '"' + s + '"';
}
return s;
} | [
"function",
"dquote",
"(",
"s",
")",
"{",
"var",
"sq",
"=",
"(",
"s",
".",
"indexOf",
"(",
"'\\''",
")",
">=",
"0",
")",
";",
"var",
"dq",
"=",
"(",
"s",
".",
"indexOf",
"(",
"'\"'",
")",
">=",
"0",
")",
";",
"if",
"(",
"sq",
"&&",
"dq",
... | properly quote and escape the given input string | [
"properly",
"quote",
"and",
"escape",
"the",
"given",
"input",
"string"
] | cbde7b780c2f6613027730403ed1b3908daf1007 | https://github.com/GerHobbelt/jison-helpers-lib/blob/cbde7b780c2f6613027730403ed1b3908daf1007/dist/helpers-lib-umd.js#L112-L126 | train |
steveesamson/slicks-bee | libs/server.js | function (i) {
workers[i] = cluster.fork();
console.log('Creating Worker: ', workers[i].process.pid);
workers[i].on('message', m => {
switch (m.type) {
case 'STARTED':
!starte... | javascript | function (i) {
workers[i] = cluster.fork();
console.log('Creating Worker: ', workers[i].process.pid);
workers[i].on('message', m => {
switch (m.type) {
case 'STARTED':
!starte... | [
"function",
"(",
"i",
")",
"{",
"workers",
"[",
"i",
"]",
"=",
"cluster",
".",
"fork",
"(",
")",
";",
"console",
".",
"log",
"(",
"'Creating Worker: '",
",",
"workers",
"[",
"i",
"]",
".",
"process",
".",
"pid",
")",
";",
"workers",
"[",
"i",
"]"... | This stores our workers. We need to keep them to be able to reference them based on source IP address. It's also useful for auto-restart, for example. | [
"This",
"stores",
"our",
"workers",
".",
"We",
"need",
"to",
"keep",
"them",
"to",
"be",
"able",
"to",
"reference",
"them",
"based",
"on",
"source",
"IP",
"address",
".",
"It",
"s",
"also",
"useful",
"for",
"auto",
"-",
"restart",
"for",
"example",
"."... | ebec403c21fa37ffec727aed1a92567679853e40 | https://github.com/steveesamson/slicks-bee/blob/ebec403c21fa37ffec727aed1a92567679853e40/libs/server.js#L61-L77 | train | |
gethuman/pancakes-angular | lib/transformers/ng.uipart.transformer.js | parseNames | function parseNames(filePath, prefix, defaultAppName) {
var appName = this.getAppName(filePath, defaultAppName);
var names = {
appShortName: appName,
appName: this.getAppModuleName(prefix, appName),
isPartial: !!filePath.match(/^.*\.partial\.js/)
};
names.isPage = !names.isPa... | javascript | function parseNames(filePath, prefix, defaultAppName) {
var appName = this.getAppName(filePath, defaultAppName);
var names = {
appShortName: appName,
appName: this.getAppModuleName(prefix, appName),
isPartial: !!filePath.match(/^.*\.partial\.js/)
};
names.isPage = !names.isPa... | [
"function",
"parseNames",
"(",
"filePath",
",",
"prefix",
",",
"defaultAppName",
")",
"{",
"var",
"appName",
"=",
"this",
".",
"getAppName",
"(",
"filePath",
",",
"defaultAppName",
")",
";",
"var",
"names",
"=",
"{",
"appShortName",
":",
"appName",
",",
"a... | Using the file path, parse out all the names needed for the UI part template
@param filePath
@param prefix
@param defaultAppName | [
"Using",
"the",
"file",
"path",
"parse",
"out",
"all",
"the",
"names",
"needed",
"for",
"the",
"UI",
"part",
"template"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.uipart.transformer.js#L63-L90 | train |
gethuman/pancakes-angular | lib/transformers/ng.uipart.transformer.js | getHtml | function getHtml(uipart, options) {
options = options || {};
var me = this;
// if any subviews, add them as dependencies
var model = {
isMobile: options.isMobile,
appName: options.appName,
pageCssId: options.appName + 'PageCssId'
};
var deps = _.extend({
subviews... | javascript | function getHtml(uipart, options) {
options = options || {};
var me = this;
// if any subviews, add them as dependencies
var model = {
isMobile: options.isMobile,
appName: options.appName,
pageCssId: options.appName + 'PageCssId'
};
var deps = _.extend({
subviews... | [
"function",
"getHtml",
"(",
"uipart",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"me",
"=",
"this",
";",
"// if any subviews, add them as dependencies",
"var",
"model",
"=",
"{",
"isMobile",
":",
"options",
".",
"isMobil... | Get the HTML for a given ui part
@param uipart
@param options
@returns {string} | [
"Get",
"the",
"HTML",
"for",
"a",
"given",
"ui",
"part"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/transformers/ng.uipart.transformer.js#L195-L224 | train |
flacnut/npm-dependencies-spreadsheet | index.js | ensureRowsDeleted | function ensureRowsDeleted(rows) {
async.whilst(
() => rows.length,
(cb) => {
rows[0].del(() => {
sheet.getRows(query_options, (err, _rows) => {
rows = _rows;
cb();
});
});
},
next);
} | javascript | function ensureRowsDeleted(rows) {
async.whilst(
() => rows.length,
(cb) => {
rows[0].del(() => {
sheet.getRows(query_options, (err, _rows) => {
rows = _rows;
cb();
});
});
},
next);
} | [
"function",
"ensureRowsDeleted",
"(",
"rows",
")",
"{",
"async",
".",
"whilst",
"(",
"(",
")",
"=>",
"rows",
".",
"length",
",",
"(",
"cb",
")",
"=>",
"{",
"rows",
"[",
"0",
"]",
".",
"del",
"(",
"(",
")",
"=>",
"{",
"sheet",
".",
"getRows",
"(... | Once you delete a row, google API may incorrectly delete future rows. The only garuntee is to fetch a single row then delete it. | [
"Once",
"you",
"delete",
"a",
"row",
"google",
"API",
"may",
"incorrectly",
"delete",
"future",
"rows",
".",
"The",
"only",
"garuntee",
"is",
"to",
"fetch",
"a",
"single",
"row",
"then",
"delete",
"it",
"."
] | 691f5f93aae2cd868ee34d0ee597d87df7d0a4e6 | https://github.com/flacnut/npm-dependencies-spreadsheet/blob/691f5f93aae2cd868ee34d0ee597d87df7d0a4e6/index.js#L139-L151 | train |
xiamidaxia/xiami | meteor/livedata/server/livedata_server.js | function () {
var self = this;
// Already destroyed.
if (!self.inQueue)
return;
if (self.heartbeat) {
self.heartbeat.stop();
self.heartbeat = null;
}
if (self.socket) {
self.socket.close();
self.socket._meteorSession = null;
}
// Drop the merge box data ... | javascript | function () {
var self = this;
// Already destroyed.
if (!self.inQueue)
return;
if (self.heartbeat) {
self.heartbeat.stop();
self.heartbeat = null;
}
if (self.socket) {
self.socket.close();
self.socket._meteorSession = null;
}
// Drop the merge box data ... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Already destroyed.",
"if",
"(",
"!",
"self",
".",
"inQueue",
")",
"return",
";",
"if",
"(",
"self",
".",
"heartbeat",
")",
"{",
"self",
".",
"heartbeat",
".",
"stop",
"(",
")",
";",
"s... | Destroy this session. Stop all processing and tear everything down. If a socket was attached, close it. | [
"Destroy",
"this",
"session",
".",
"Stop",
"all",
"processing",
"and",
"tear",
"everything",
"down",
".",
"If",
"a",
"socket",
"was",
"attached",
"close",
"it",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L424-L460 | train | |
xiamidaxia/xiami | meteor/livedata/server/livedata_server.js | function () {
var self = this;
// For the reported client address for a connection to be correct,
// the developer must set the HTTP_FORWARDED_COUNT environment
// variable to an integer representing the number of hops they
// expect in the `x-forwarded-for` header. E.g., set to "1" if the
// s... | javascript | function () {
var self = this;
// For the reported client address for a connection to be correct,
// the developer must set the HTTP_FORWARDED_COUNT environment
// variable to an integer representing the number of hops they
// expect in the `x-forwarded-for` header. E.g., set to "1" if the
// s... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// For the reported client address for a connection to be correct,",
"// the developer must set the HTTP_FORWARDED_COUNT environment",
"// variable to an integer representing the number of hops they",
"// expect in the `x-forwarded... | Determine the remote client's IP address, based on the HTTP_FORWARDED_COUNT environment variable representing how many proxies the server is behind. | [
"Determine",
"the",
"remote",
"client",
"s",
"IP",
"address",
"based",
"on",
"the",
"HTTP_FORWARDED_COUNT",
"environment",
"variable",
"representing",
"how",
"many",
"proxies",
"the",
"server",
"is",
"behind",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L827-L860 | train | |
xiamidaxia/xiami | meteor/livedata/server/livedata_server.js | function (name, handler, options) {
var self = this;
options = options || {};
if (name && name in self.publish_handlers) {
Meteor._debug("Ignoring duplicate publish named '" + name + "'");
return;
}
if (Package.autopublish && !options.is_auto) {
// They have autopublish on, yet ... | javascript | function (name, handler, options) {
var self = this;
options = options || {};
if (name && name in self.publish_handlers) {
Meteor._debug("Ignoring duplicate publish named '" + name + "'");
return;
}
if (Package.autopublish && !options.is_auto) {
// They have autopublish on, yet ... | [
"function",
"(",
"name",
",",
"handler",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"name",
"&&",
"name",
"in",
"self",
".",
"publish_handlers",
")",
"{",
"Meteor",
".",
"_d... | Register a publish handler function.
@param name {String} identifier for query
@param handler {Function} publish handler
@param options {Object}
Server will call handler function on each new subscription,
either when receiving DDP sub message for a named subscription, or on
DDP connect for a universal subscription.
... | [
"Register",
"a",
"publish",
"handler",
"function",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L1290-L1340 | train | |
xiamidaxia/xiami | meteor/livedata/server/livedata_server.js | function (exception, context) {
if (!exception || exception instanceof Meteor.Error)
return exception;
// Did the error contain more details that could have been useful if caught in
// server code (or if thrown from non-client-originated code), but also
// provided a "sanitized" version with more context t... | javascript | function (exception, context) {
if (!exception || exception instanceof Meteor.Error)
return exception;
// Did the error contain more details that could have been useful if caught in
// server code (or if thrown from non-client-originated code), but also
// provided a "sanitized" version with more context t... | [
"function",
"(",
"exception",
",",
"context",
")",
"{",
"if",
"(",
"!",
"exception",
"||",
"exception",
"instanceof",
"Meteor",
".",
"Error",
")",
"return",
"exception",
";",
"// Did the error contain more details that could have been useful if caught in",
"// server code... | "blind" exceptions other than those that were deliberately thrown to signal errors to the client | [
"blind",
"exceptions",
"other",
"than",
"those",
"that",
"were",
"deliberately",
"thrown",
"to",
"signal",
"errors",
"to",
"the",
"client"
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/livedata/server/livedata_server.js#L1472-L1493 | train | |
zeropaper/git-beat | lib/git-beat.js | GitBeat | function GitBeat(options) {
var self = this;
var url;
options = options || {};
if (typeof options === 'string') {
url = options;
options = {};
}
this.cwd = path.resolve(options.cwd || '');
this.logger = options.logger || noop;
url = url || options.url;
this.isCloned = false;
if (url) {
... | javascript | function GitBeat(options) {
var self = this;
var url;
options = options || {};
if (typeof options === 'string') {
url = options;
options = {};
}
this.cwd = path.resolve(options.cwd || '');
this.logger = options.logger || noop;
url = url || options.url;
this.isCloned = false;
if (url) {
... | [
"function",
"GitBeat",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"url",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"options",
"===",
"'string'",
")",
"{",
"url",
"=",
"options",
";",
"options",
... | GitBeat is aimed to take the pulse of Git repositories.
@param {Object|String} options is either an object or the URL of a repository
@param {String} [options.cwd] to set the working directory path
@param {Function} [options.logger] a function to log | [
"GitBeat",
"is",
"aimed",
"to",
"take",
"the",
"pulse",
"of",
"Git",
"repositories",
"."
] | 380e8af87b527287380345303566bd7b27e6c799 | https://github.com/zeropaper/git-beat/blob/380e8af87b527287380345303566bd7b27e6c799/lib/git-beat.js#L23-L44 | train |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/aside/dox.FormSpirit.js | function () {
this._super.onenter ();
this.element.action = "javascript:void(0)";
this._scrollbar ( gui.Client.scrollBarSize );
this._flexboxerize (
this.dom.q ( "label" ),
this.dom.q ( "input" )
);
} | javascript | function () {
this._super.onenter ();
this.element.action = "javascript:void(0)";
this._scrollbar ( gui.Client.scrollBarSize );
this._flexboxerize (
this.dom.q ( "label" ),
this.dom.q ( "input" )
);
} | [
"function",
"(",
")",
"{",
"this",
".",
"_super",
".",
"onenter",
"(",
")",
";",
"this",
".",
"element",
".",
"action",
"=",
"\"javascript:void(0)\"",
";",
"this",
".",
"_scrollbar",
"(",
"gui",
".",
"Client",
".",
"scrollBarSize",
")",
";",
"this",
".... | Layout fixes on startup. | [
"Layout",
"fixes",
"on",
"startup",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/aside/dox.FormSpirit.js#L10-L18 | train | |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/aside/dox.FormSpirit.js | function ( label, input ) {
var avail = this.box.width - label.offsetWidth;
var space = gui.Client.isGecko ? 6 : 4;
input.style.width = avail - space + "px";
} | javascript | function ( label, input ) {
var avail = this.box.width - label.offsetWidth;
var space = gui.Client.isGecko ? 6 : 4;
input.style.width = avail - space + "px";
} | [
"function",
"(",
"label",
",",
"input",
")",
"{",
"var",
"avail",
"=",
"this",
".",
"box",
".",
"width",
"-",
"label",
".",
"offsetWidth",
";",
"var",
"space",
"=",
"gui",
".",
"Client",
".",
"isGecko",
"?",
"6",
":",
"4",
";",
"input",
".",
"sty... | Something that should go to CSS.
@param {HTMLLabelElement} label
@param {HTMLInputElement} input | [
"Something",
"that",
"should",
"go",
"to",
"CSS",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/aside/dox.FormSpirit.js#L40-L44 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | function(clazz, metaData) {
// Apply clazz interface
if (!clazz.__isClazz) {
_.extend(clazz, this.clazz_interface);
}
// Apply interface common for clazz and its prototype
if (!clazz.__interfaces) {
clazz.__interfaces = [];
clazz.prototype.__... | javascript | function(clazz, metaData) {
// Apply clazz interface
if (!clazz.__isClazz) {
_.extend(clazz, this.clazz_interface);
}
// Apply interface common for clazz and its prototype
if (!clazz.__interfaces) {
clazz.__interfaces = [];
clazz.prototype.__... | [
"function",
"(",
"clazz",
",",
"metaData",
")",
"{",
"// Apply clazz interface",
"if",
"(",
"!",
"clazz",
".",
"__isClazz",
")",
"{",
"_",
".",
"extend",
"(",
"clazz",
",",
"this",
".",
"clazz_interface",
")",
";",
"}",
"// Apply interface common for clazz and... | Process meta data for specified clazz
@param {clazz} clazz Clazz
@param {object} metaData Meta data
@throw {Error} if wrong meta data are passed
@this {metaProcessor} | [
"Process",
"meta",
"data",
"for",
"specified",
"clazz"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L29-L69 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | function() {
var processors = this._processors;
_.each(processors, function(processor, name) {
if (_.isString(processor)) {
processors[name] = meta(processor);
}
});
return processors;
} | javascript | function() {
var processors = this._processors;
_.each(processors, function(processor, name) {
if (_.isString(processor)) {
processors[name] = meta(processor);
}
});
return processors;
} | [
"function",
"(",
")",
"{",
"var",
"processors",
"=",
"this",
".",
"_processors",
";",
"_",
".",
"each",
"(",
"processors",
",",
"function",
"(",
"processor",
",",
"name",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"processor",
")",
")",
"{",
"... | Gets sub processors
@returns {array} Sub processors
@this {metaProcessor} | [
"Gets",
"sub",
"processors"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L78-L88 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | function(processors) {
var that = this;
_.each(processors, function(processor, name) {
if (name in that._processors) {
throw new Error('Processor "' + name + '" already exists!');
}
that._processors[name] = processor;
});
return this;
... | javascript | function(processors) {
var that = this;
_.each(processors, function(processor, name) {
if (name in that._processors) {
throw new Error('Processor "' + name + '" already exists!');
}
that._processors[name] = processor;
});
return this;
... | [
"function",
"(",
"processors",
")",
"{",
"var",
"that",
"=",
"this",
";",
"_",
".",
"each",
"(",
"processors",
",",
"function",
"(",
"processor",
",",
"name",
")",
"{",
"if",
"(",
"name",
"in",
"that",
".",
"_processors",
")",
"{",
"throw",
"new",
... | Sets sub processors
@param {array} processors Sub processors
@returns {metaProcessor} this
@throws {Error} if sub processor already exist
@this {metaProcessor} | [
"Sets",
"sub",
"processors"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L100-L110 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | function(parent) {
var clazzParent = this;
while (clazzParent) {
if (clazzParent === parent || clazzParent.__name === parent) {
return true;
}
clazzParent = clazzParent.__parent;
}
return false;
... | javascript | function(parent) {
var clazzParent = this;
while (clazzParent) {
if (clazzParent === parent || clazzParent.__name === parent) {
return true;
}
clazzParent = clazzParent.__parent;
}
return false;
... | [
"function",
"(",
"parent",
")",
"{",
"var",
"clazzParent",
"=",
"this",
";",
"while",
"(",
"clazzParent",
")",
"{",
"if",
"(",
"clazzParent",
"===",
"parent",
"||",
"clazzParent",
".",
"__name",
"===",
"parent",
")",
"{",
"return",
"true",
";",
"}",
"c... | Checks whether this clazz is sub clazz of specified one
@param {clazz|string} parent Parent clazz
@returns {boolean} true if this clazz is sub clazz of specified one
@this {clazz} | [
"Checks",
"whether",
"this",
"clazz",
"is",
"sub",
"clazz",
"of",
"specified",
"one"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L184-L195 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | function(property) {
if (this.hasOwnProperty(property) && !_.isUndefined(this[property])) {
return this[property];
}
if (this.__proto && this.__proto.hasOwnProperty(property) && !_.isUndefined(this.__proto[property])) {
return this.__proto[property];
... | javascript | function(property) {
if (this.hasOwnProperty(property) && !_.isUndefined(this[property])) {
return this[property];
}
if (this.__proto && this.__proto.hasOwnProperty(property) && !_.isUndefined(this.__proto[property])) {
return this.__proto[property];
... | [
"function",
"(",
"property",
")",
"{",
"if",
"(",
"this",
".",
"hasOwnProperty",
"(",
"property",
")",
"&&",
"!",
"_",
".",
"isUndefined",
"(",
"this",
"[",
"property",
"]",
")",
")",
"{",
"return",
"this",
"[",
"property",
"]",
";",
"}",
"if",
"("... | Collects all property value from current and parent clazzes
@param {string} property Property name
@returns {*} Property value
@this {clazz|object} | [
"Collects",
"all",
"property",
"value",
"from",
"current",
"and",
"parent",
"clazzes"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L241-L258 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | function(property, level /* fields */) {
var propertyContainers = [];
if (this.hasOwnProperty(property)) {
propertyContainers.push(this[property]);
}
if (this.__proto && this.__proto.hasOwnProperty(property)) {
propertyContainers.push(th... | javascript | function(property, level /* fields */) {
var propertyContainers = [];
if (this.hasOwnProperty(property)) {
propertyContainers.push(this[property]);
}
if (this.__proto && this.__proto.hasOwnProperty(property)) {
propertyContainers.push(th... | [
"function",
"(",
"property",
",",
"level",
"/* fields */",
")",
"{",
"var",
"propertyContainers",
"=",
"[",
"]",
";",
"if",
"(",
"this",
".",
"hasOwnProperty",
"(",
"property",
")",
")",
"{",
"propertyContainers",
".",
"push",
"(",
"this",
"[",
"property",... | Collect all property values from current and parent clazzes
@param {string} property Property name
@param {number} level Level of property search depth
@returns {*} Collected property values
@this {clazz|object} | [
"Collect",
"all",
"property",
"values",
"from",
"current",
"and",
"parent",
"clazzes"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L269-L298 | train | |
alexpods/ClazzJS | src/components/meta/Base.js | self | function self(collector, container, level, fields, reverse) {
fields = [].concat(fields || []);
_.each(container, function(value, name) {
if (fields[0] && (name !== fields[0])) {
return;
}
if (level > 1 && _.isSimpleObject(val... | javascript | function self(collector, container, level, fields, reverse) {
fields = [].concat(fields || []);
_.each(container, function(value, name) {
if (fields[0] && (name !== fields[0])) {
return;
}
if (level > 1 && _.isSimpleObject(val... | [
"function",
"self",
"(",
"collector",
",",
"container",
",",
"level",
",",
"fields",
",",
"reverse",
")",
"{",
"fields",
"=",
"[",
"]",
".",
"concat",
"(",
"fields",
"||",
"[",
"]",
")",
";",
"_",
".",
"each",
"(",
"container",
",",
"function",
"("... | Collect values to specified collector
@param {object} collector Collected values will be added to it
@param {object} container Searched for specified fields
@param {number} level Lever of property search depth
@param {array} fields Searching
@param {boolean} reverse If true overwrite collector property v... | [
"Collect",
"values",
"to",
"specified",
"collector"
] | 2f94496019669813c8246d48fcceb12a3e68a870 | https://github.com/alexpods/ClazzJS/blob/2f94496019669813c8246d48fcceb12a3e68a870/src/components/meta/Base.js#L313-L332 | train |
JamesMGreene/node-playerglobal-latest | index.js | function(FLEX_HOME, done) {
var playersDir = path.join(FLEX_HOME, 'frameworks', 'libs', 'player');
if (fs.existsSync(playersDir) && fs.statSync(playersDir).isDirectory()) {
var tmpDirRoot = os.tmpdir ? os.tmpdir() : os.tmpDir();
var tmpOldPlayersDir = path.join(tmpDirRoot, 'node-playerglobal');
... | javascript | function(FLEX_HOME, done) {
var playersDir = path.join(FLEX_HOME, 'frameworks', 'libs', 'player');
if (fs.existsSync(playersDir) && fs.statSync(playersDir).isDirectory()) {
var tmpDirRoot = os.tmpdir ? os.tmpdir() : os.tmpDir();
var tmpOldPlayersDir = path.join(tmpDirRoot, 'node-playerglobal');
... | [
"function",
"(",
"FLEX_HOME",
",",
"done",
")",
"{",
"var",
"playersDir",
"=",
"path",
".",
"join",
"(",
"FLEX_HOME",
",",
"'frameworks'",
",",
"'libs'",
",",
"'player'",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"playersDir",
")",
"&&",
"fs",... | Install these "playerglobal.swc" files into the appropriate location within a Flex SDK directory | [
"Install",
"these",
"playerglobal",
".",
"swc",
"files",
"into",
"the",
"appropriate",
"location",
"within",
"a",
"Flex",
"SDK",
"directory"
] | 600426fb30f62f013f9bcf966115c5cce90a076d | https://github.com/JamesMGreene/node-playerglobal-latest/blob/600426fb30f62f013f9bcf966115c5cce90a076d/index.js#L24-L87 | train | |
wunderbyte/grunt-spiritual-dox | src/js/guidox@wunderbyte.com/spirits/main/dox.MainSpirit.js | function () {
this._super.onready ();
this.element.tabIndex = 0;
this._doctitle ( location.hash );
this.event.add ( "hashchange", window );
} | javascript | function () {
this._super.onready ();
this.element.tabIndex = 0;
this._doctitle ( location.hash );
this.event.add ( "hashchange", window );
} | [
"function",
"(",
")",
"{",
"this",
".",
"_super",
".",
"onready",
"(",
")",
";",
"this",
".",
"element",
".",
"tabIndex",
"=",
"0",
";",
"this",
".",
"_doctitle",
"(",
"location",
".",
"hash",
")",
";",
"this",
".",
"event",
".",
"add",
"(",
"\"h... | Support focus transfer to MAIN
whenever the ASIDE gets closed. | [
"Support",
"focus",
"transfer",
"to",
"MAIN",
"whenever",
"the",
"ASIDE",
"gets",
"closed",
"."
] | 5afcfe31ddbf7d654166aa15b938553b61de5811 | https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/main/dox.MainSpirit.js#L10-L15 | train | |
junosuarez/prometido | index.js | when | function when(promises) {
promises = arrayify(promises);
var whenPromise = new PromiseFactory();
var pending = promises.length;
var results = [];
var resolve = function (i) {
return function (val) {
results[i] = val;
pending--;
if (pending === 0) {
whenPromise.resolve(results);
}
};
};
pr... | javascript | function when(promises) {
promises = arrayify(promises);
var whenPromise = new PromiseFactory();
var pending = promises.length;
var results = [];
var resolve = function (i) {
return function (val) {
results[i] = val;
pending--;
if (pending === 0) {
whenPromise.resolve(results);
}
};
};
pr... | [
"function",
"when",
"(",
"promises",
")",
"{",
"promises",
"=",
"arrayify",
"(",
"promises",
")",
";",
"var",
"whenPromise",
"=",
"new",
"PromiseFactory",
"(",
")",
";",
"var",
"pending",
"=",
"promises",
".",
"length",
";",
"var",
"results",
"=",
"[",
... | Aggregates an array of promises into one promise which is resolved
when every constituent promise is resolved or rejected when some
constituent promise is rejected
@param {Promise|Array.<Promise>} promises
@return {Promise} | [
"Aggregates",
"an",
"array",
"of",
"promises",
"into",
"one",
"promise",
"which",
"is",
"resolved",
"when",
"every",
"constituent",
"promise",
"is",
"resolved",
"or",
"rejected",
"when",
"some",
"constituent",
"promise",
"is",
"rejected"
] | 20ff7a41b355e60d13859770956090cd098ac5c2 | https://github.com/junosuarez/prometido/blob/20ff7a41b355e60d13859770956090cd098ac5c2/index.js#L20-L45 | train |
junosuarez/prometido | index.js | PromiseFactory | function PromiseFactory() {
var deferred = whenjs.defer();
//var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000);
this.reject = function (err) {
deferred.reject(err);
};
this.resolve = function (val) {
// clearTimeout(timeout);
deferred.resolve(val);
};
this.promise = functio... | javascript | function PromiseFactory() {
var deferred = whenjs.defer();
//var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000);
this.reject = function (err) {
deferred.reject(err);
};
this.resolve = function (val) {
// clearTimeout(timeout);
deferred.resolve(val);
};
this.promise = functio... | [
"function",
"PromiseFactory",
"(",
")",
"{",
"var",
"deferred",
"=",
"whenjs",
".",
"defer",
"(",
")",
";",
"//var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000);",
"this",
".",
"reject",
"=",
"function",
"(",
"err",
")",
"{",
"deferred... | Make an object with properly-bound `resolve` and `reject` | [
"Make",
"an",
"object",
"with",
"properly",
"-",
"bound",
"resolve",
"and",
"reject"
] | 20ff7a41b355e60d13859770956090cd098ac5c2 | https://github.com/junosuarez/prometido/blob/20ff7a41b355e60d13859770956090cd098ac5c2/index.js#L92-L106 | train |
junosuarez/prometido | index.js | asPromise | function asPromise (val) {
if (val && typeof val.then === 'function') {
return val;
}
var deferred = new PromiseFactory();
deferred.resolve(val);
return deferred.promise();
} | javascript | function asPromise (val) {
if (val && typeof val.then === 'function') {
return val;
}
var deferred = new PromiseFactory();
deferred.resolve(val);
return deferred.promise();
} | [
"function",
"asPromise",
"(",
"val",
")",
"{",
"if",
"(",
"val",
"&&",
"typeof",
"val",
".",
"then",
"===",
"'function'",
")",
"{",
"return",
"val",
";",
"}",
"var",
"deferred",
"=",
"new",
"PromiseFactory",
"(",
")",
";",
"deferred",
".",
"resolve",
... | Helper function to return a resolved promise with a given value | [
"Helper",
"function",
"to",
"return",
"a",
"resolved",
"promise",
"with",
"a",
"given",
"value"
] | 20ff7a41b355e60d13859770956090cd098ac5c2 | https://github.com/junosuarez/prometido/blob/20ff7a41b355e60d13859770956090cd098ac5c2/index.js#L111-L118 | train |
lisplate/lisplate | spec/lib/jsreporter.js | failures | function failures (items) {
var fs = [], i, v;
for (i = 0; i < items.length; i += 1) {
v = items[i];
if (!v.passed_) {
fs.push(v);
}
}
return fs;
} | javascript | function failures (items) {
var fs = [], i, v;
for (i = 0; i < items.length; i += 1) {
v = items[i];
if (!v.passed_) {
fs.push(v);
}
}
return fs;
} | [
"function",
"failures",
"(",
"items",
")",
"{",
"var",
"fs",
"=",
"[",
"]",
",",
"i",
",",
"v",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"v",
"=",
"items",
"[",
"i",
"]",
";",
... | Create a new array which contains only the failed items.
@param items Items which will be filtered
@returns {Array} of failed items | [
"Create",
"a",
"new",
"array",
"which",
"contains",
"only",
"the",
"failed",
"items",
"."
] | 75ae58facbe52158270fd40bb9a9d650c97d2ed9 | https://github.com/lisplate/lisplate/blob/75ae58facbe52158270fd40bb9a9d650c97d2ed9/spec/lib/jsreporter.js#L64-L73 | train |
wbyoung/corazon | lib/mixin.js | function() {
return this.__all__.reduce(function(all, mixin) {
return mixin instanceof Mixin.__class__ ?
all.concat(mixin.__flatten__()) :
all.concat([mixin]);
}, []);
} | javascript | function() {
return this.__all__.reduce(function(all, mixin) {
return mixin instanceof Mixin.__class__ ?
all.concat(mixin.__flatten__()) :
all.concat([mixin]);
}, []);
} | [
"function",
"(",
")",
"{",
"return",
"this",
".",
"__all__",
".",
"reduce",
"(",
"function",
"(",
"all",
",",
"mixin",
")",
"{",
"return",
"mixin",
"instanceof",
"Mixin",
".",
"__class__",
"?",
"all",
".",
"concat",
"(",
"mixin",
".",
"__flatten__",
"(... | Create a flattened array of properties are required to be mixed into a
class in the order in which they should be mixed in.
@method
@private
@return {Array.<Object>} The properties | [
"Create",
"a",
"flattened",
"array",
"of",
"properties",
"are",
"required",
"to",
"be",
"mixed",
"into",
"a",
"class",
"in",
"the",
"order",
"in",
"which",
"they",
"should",
"be",
"mixed",
"in",
"."
] | c3cc87f3de28f8e40ab091c8f215479c9e61f379 | https://github.com/wbyoung/corazon/blob/c3cc87f3de28f8e40ab091c8f215479c9e61f379/lib/mixin.js#L38-L44 | train | |
wbyoung/corazon | lib/mixin.js | function(reopen, name) {
return function() {
// the `reopen` function that was passed in to this function will continue
// the process of reopening to the function that this is monkey-patching.
// it is not a recursive call.
// the `recursiveReopen` function, on the other hand, is the reopen
// f... | javascript | function(reopen, name) {
return function() {
// the `reopen` function that was passed in to this function will continue
// the process of reopening to the function that this is monkey-patching.
// it is not a recursive call.
// the `recursiveReopen` function, on the other hand, is the reopen
// f... | [
"function",
"(",
"reopen",
",",
"name",
")",
"{",
"return",
"function",
"(",
")",
"{",
"// the `reopen` function that was passed in to this function will continue",
"// the process of reopening to the function that this is monkey-patching.",
"// it is not a recursive call.",
"// the `r... | Shared function for supporting mixins via `reopen` and `reopenClass`.
@memberof Mixin~ClassPatching
@type function
@private | [
"Shared",
"function",
"for",
"supporting",
"mixins",
"via",
"reopen",
"and",
"reopenClass",
"."
] | c3cc87f3de28f8e40ab091c8f215479c9e61f379 | https://github.com/wbyoung/corazon/blob/c3cc87f3de28f8e40ab091c8f215479c9e61f379/lib/mixin.js#L100-L124 | train | |
loomio/router | docs/traceur-package/services/atParser.js | parseModule | function parseModule(fileInfo) {
var moduleName = file2modulename(fileInfo.relativePath);
var sourceFile = new SourceFile(moduleName, fileInfo.content);
var comments = [];
var moduleTree;
var parser = new Parser(sourceFile);
// Configure the parser
parser.handleComment = function(range) {
... | javascript | function parseModule(fileInfo) {
var moduleName = file2modulename(fileInfo.relativePath);
var sourceFile = new SourceFile(moduleName, fileInfo.content);
var comments = [];
var moduleTree;
var parser = new Parser(sourceFile);
// Configure the parser
parser.handleComment = function(range) {
... | [
"function",
"parseModule",
"(",
"fileInfo",
")",
"{",
"var",
"moduleName",
"=",
"file2modulename",
"(",
"fileInfo",
".",
"relativePath",
")",
";",
"var",
"sourceFile",
"=",
"new",
"SourceFile",
"(",
"moduleName",
",",
"fileInfo",
".",
"content",
")",
";",
"v... | Parse the contents of the file using traceur | [
"Parse",
"the",
"contents",
"of",
"the",
"file",
"using",
"traceur"
] | 4af3b95674216b6a415b802322f5e44b78351d06 | https://github.com/loomio/router/blob/4af3b95674216b6a415b802322f5e44b78351d06/docs/traceur-package/services/atParser.js#L30-L64 | train |
dalekjs/dalek-driver-sauce | lib/commands/cookie.js | function (name, contents, hash) {
this.actionQueue.push(this.webdriverClient.setCookie.bind(this.webdriverClient, {name: name, value: contents}));
this.actionQueue.push(this._setCookieCb.bind(this, name, contents, hash));
return this;
} | javascript | function (name, contents, hash) {
this.actionQueue.push(this.webdriverClient.setCookie.bind(this.webdriverClient, {name: name, value: contents}));
this.actionQueue.push(this._setCookieCb.bind(this, name, contents, hash));
return this;
} | [
"function",
"(",
"name",
",",
"contents",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"setCookie",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"{",
"name",
":",
"name",
",",
"valu... | Sets an cookie
@method setCookie
@param {string} name Name of the cookie
@param {string} contents Contents of the cookie
@param {string} hash Unique hash of that fn call
@chainable | [
"Sets",
"an",
"cookie"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/cookie.js#L50-L54 | train | |
dalekjs/dalek-driver-sauce | lib/commands/cookie.js | function (name, cookie, hash) {
this.actionQueue.push(this.webdriverClient.getCookie.bind(this.webdriverClient, name));
this.actionQueue.push(this._cookieCb.bind(this, name, hash));
return this;
} | javascript | function (name, cookie, hash) {
this.actionQueue.push(this.webdriverClient.getCookie.bind(this.webdriverClient, name));
this.actionQueue.push(this._cookieCb.bind(this, name, hash));
return this;
} | [
"function",
"(",
"name",
",",
"cookie",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"getCookie",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"name",
")",
")",
";",
"this",
".",
... | Retrieves an cookie
@method cookie
@param {string} name Name of the cookie
@param {string} cookie Expected contents of the cookie
@param {string} hash Unique hash of that fn call
@chainable | [
"Retrieves",
"an",
"cookie"
] | 4b3ef87a0c35a91db8456d074b0d47a3e0df58f7 | https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/cookie.js#L84-L88 | train | |
jgnewman/brightsocket.io | src/socketpool.js | send | function send(pool, id, event, message) {
const socket = pool.sockets.connected[id];
if (socket) {
return socket.emit(event, message);
} else {
console.log(`Cannot send ${event} to disconnected socket ${id}`);
}
} | javascript | function send(pool, id, event, message) {
const socket = pool.sockets.connected[id];
if (socket) {
return socket.emit(event, message);
} else {
console.log(`Cannot send ${event} to disconnected socket ${id}`);
}
} | [
"function",
"send",
"(",
"pool",
",",
"id",
",",
"event",
",",
"message",
")",
"{",
"const",
"socket",
"=",
"pool",
".",
"sockets",
".",
"connected",
"[",
"id",
"]",
";",
"if",
"(",
"socket",
")",
"{",
"return",
"socket",
".",
"emit",
"(",
"event",... | Sends a message to a single socket connected to socket.io.
@param {Object} pool The socket.io connection pool.
@param {String} id The socket's ID.
@param {String} event The name of the event to emit.
@param {Any} message The serializable message to send.
@return {undefined} | [
"Sends",
"a",
"message",
"to",
"a",
"single",
"socket",
"connected",
"to",
"socket",
".",
"io",
"."
] | 19ec67d69946ab09ca389143ebbdcb0a7f22f950 | https://github.com/jgnewman/brightsocket.io/blob/19ec67d69946ab09ca389143ebbdcb0a7f22f950/src/socketpool.js#L59-L66 | train |
pdubroy/jsjoins | index.js | newChannel | function newChannel() {
let chan = new Channel();
let result = chan.send.bind(chan);
result._inst = chan;
return result;
} | javascript | function newChannel() {
let chan = new Channel();
let result = chan.send.bind(chan);
result._inst = chan;
return result;
} | [
"function",
"newChannel",
"(",
")",
"{",
"let",
"chan",
"=",
"new",
"Channel",
"(",
")",
";",
"let",
"result",
"=",
"chan",
".",
"send",
".",
"bind",
"(",
"chan",
")",
";",
"result",
".",
"_inst",
"=",
"chan",
";",
"return",
"result",
";",
"}"
] | Create a new synchronous channel, and return a function which sends a message on that channel. | [
"Create",
"a",
"new",
"synchronous",
"channel",
"and",
"return",
"a",
"function",
"which",
"sends",
"a",
"message",
"on",
"that",
"channel",
"."
] | 5848fe6e9695f4af7254be8cb7f6b5c61db577eb | https://github.com/pdubroy/jsjoins/blob/5848fe6e9695f4af7254be8cb7f6b5c61db577eb/index.js#L249-L254 | train |
yefremov/aggregatejs | variance.js | variance | function variance(array) {
var length = array.length;
if (length === 0) {
throw new RangeError('Error');
}
var index = -1;
var mean = 0;
while (++index < length) {
mean += array[index] / length;
}
var result = 0;
for (var i = 0; i < length; i++) {
result += Math.pow(array[i] - mean, 2... | javascript | function variance(array) {
var length = array.length;
if (length === 0) {
throw new RangeError('Error');
}
var index = -1;
var mean = 0;
while (++index < length) {
mean += array[index] / length;
}
var result = 0;
for (var i = 0; i < length; i++) {
result += Math.pow(array[i] - mean, 2... | [
"function",
"variance",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"RangeError",
"(",
"'Error'",
")",
";",
"}",
"var",
"index",
"=",
"-",
"1",
";",
"var",
... | Returns the variance population of the numbers in `array`.
@param {Array} array
@return {number}
@example
variance([2, 4, 4, 4, 5, 5, 7, 9]);
// => 4 | [
"Returns",
"the",
"variance",
"population",
"of",
"the",
"numbers",
"in",
"array",
"."
] | 932b28a15a5707135e7095950000a838db409511 | https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/variance.js#L19-L40 | train |
derdesign/protos | engines/swig.js | Swig | function Swig() {
var opts = (app.config.engines && app.config.engines.swig) || {};
this.options = protos.extend({
cache: false
}, opts);
swig.setDefaults(this.options); // Set options for swig
this.module = swig;
this.multiPart = true;
this.extensions = ['swig', 'swig.html'];
} | javascript | function Swig() {
var opts = (app.config.engines && app.config.engines.swig) || {};
this.options = protos.extend({
cache: false
}, opts);
swig.setDefaults(this.options); // Set options for swig
this.module = swig;
this.multiPart = true;
this.extensions = ['swig', 'swig.html'];
} | [
"function",
"Swig",
"(",
")",
"{",
"var",
"opts",
"=",
"(",
"app",
".",
"config",
".",
"engines",
"&&",
"app",
".",
"config",
".",
"engines",
".",
"swig",
")",
"||",
"{",
"}",
";",
"this",
".",
"options",
"=",
"protos",
".",
"extend",
"(",
"{",
... | Swig engine class
https://github.com/paularmstrong/swig | [
"Swig",
"engine",
"class"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/engines/swig.js#L14-L28 | train |
warmsea/WarmseaJS | src/debug.js | function(name) {
if (debuggers[name]) {
return debuggers[name];
}
var dbg = function(fmt) {
// if this debugger is not enabled, do nothing.
// Check it every time so we can enable or disable a debugger at runtime.
// It won't be slow.
if (!enableStatus[this._nam... | javascript | function(name) {
if (debuggers[name]) {
return debuggers[name];
}
var dbg = function(fmt) {
// if this debugger is not enabled, do nothing.
// Check it every time so we can enable or disable a debugger at runtime.
// It won't be slow.
if (!enableStatus[this._nam... | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"debuggers",
"[",
"name",
"]",
")",
"{",
"return",
"debuggers",
"[",
"name",
"]",
";",
"}",
"var",
"dbg",
"=",
"function",
"(",
"fmt",
")",
"{",
"// if this debugger is not enabled, do nothing.",
"// Check it eve... | Create a debugger function with a name.
@param {string} name
@return {function} | [
"Create",
"a",
"debugger",
"function",
"with",
"a",
"name",
"."
] | 58c32c75b26647bbec39dc401a78b0fdb5896c8d | https://github.com/warmsea/WarmseaJS/blob/58c32c75b26647bbec39dc401a78b0fdb5896c8d/src/debug.js#L81-L116 | train | |
warmsea/WarmseaJS | src/debug.js | function(fmt) {
if (fmt instanceof Error) {
return fmt.stack || fmt.message;
} else {
return w.format.apply(this, arguments);
}
} | javascript | function(fmt) {
if (fmt instanceof Error) {
return fmt.stack || fmt.message;
} else {
return w.format.apply(this, arguments);
}
} | [
"function",
"(",
"fmt",
")",
"{",
"if",
"(",
"fmt",
"instanceof",
"Error",
")",
"{",
"return",
"fmt",
".",
"stack",
"||",
"fmt",
".",
"message",
";",
"}",
"else",
"{",
"return",
"w",
".",
"format",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
... | Coerce `fmt`. | [
"Coerce",
"fmt",
"."
] | 58c32c75b26647bbec39dc401a78b0fdb5896c8d | https://github.com/warmsea/WarmseaJS/blob/58c32c75b26647bbec39dc401a78b0fdb5896c8d/src/debug.js#L121-L127 | train | |
warmsea/WarmseaJS | src/debug.js | function(ms) {
var sec = 1000;
var min = 60 * 1000;
var hour = 60 * min;
if (ms >= hour) {
return (ms / hour).toFixed(1) + 'h';
}
if (ms >= min) {
return (ms / min).toFixed(1) + 'm';
}
if (ms >= sec) {
return (ms / sec | 0) + 's';
}
re... | javascript | function(ms) {
var sec = 1000;
var min = 60 * 1000;
var hour = 60 * min;
if (ms >= hour) {
return (ms / hour).toFixed(1) + 'h';
}
if (ms >= min) {
return (ms / min).toFixed(1) + 'm';
}
if (ms >= sec) {
return (ms / sec | 0) + 's';
}
re... | [
"function",
"(",
"ms",
")",
"{",
"var",
"sec",
"=",
"1000",
";",
"var",
"min",
"=",
"60",
"*",
"1000",
";",
"var",
"hour",
"=",
"60",
"*",
"min",
";",
"if",
"(",
"ms",
">=",
"hour",
")",
"{",
"return",
"(",
"ms",
"/",
"hour",
")",
".",
"toF... | Humanize the given milliseconds.
@param {number} ms number of milliseconds.
@return {string} A human readable representation. | [
"Humanize",
"the",
"given",
"milliseconds",
"."
] | 58c32c75b26647bbec39dc401a78b0fdb5896c8d | https://github.com/warmsea/WarmseaJS/blob/58c32c75b26647bbec39dc401a78b0fdb5896c8d/src/debug.js#L141-L156 | train | |
rabbitlive/rabbitpack | src/entry.js | wxappEntry | function wxappEntry() {
const regex = /src\/pages\/([^\/]+)\/[^\.]+.js/;
return {
entry: () => {
let pages = {}
let core = []
glob.sync(`./src/pages/**/*.js`).forEach(x => {
const name = x.match(regex)[1]
const key = `pages/${name}/${name}`
pages[key] = x
})... | javascript | function wxappEntry() {
const regex = /src\/pages\/([^\/]+)\/[^\.]+.js/;
return {
entry: () => {
let pages = {}
let core = []
glob.sync(`./src/pages/**/*.js`).forEach(x => {
const name = x.match(regex)[1]
const key = `pages/${name}/${name}`
pages[key] = x
})... | [
"function",
"wxappEntry",
"(",
")",
"{",
"const",
"regex",
"=",
"/",
"src\\/pages\\/([^\\/]+)\\/[^\\.]+.js",
"/",
";",
"return",
"{",
"entry",
":",
"(",
")",
"=>",
"{",
"let",
"pages",
"=",
"{",
"}",
"let",
"core",
"=",
"[",
"]",
"glob",
".",
"sync",
... | WeChat app looks like multi entries app.
@see https://github.com/rabbitlive/rabbitinit/tree/master/wxapp | [
"WeChat",
"app",
"looks",
"like",
"multi",
"entries",
"app",
"."
] | 8d572a88e660cc4bcf67a39f9c877f8213ded845 | https://github.com/rabbitlive/rabbitpack/blob/8d572a88e660cc4bcf67a39f9c877f8213ded845/src/entry.js#L70-L95 | train |
SebastianOsuna/configure.js | bin/configure.js | setup | function setup() {
// check if config directory is given
if( _config_path !== -1 ) {
// get path
var config_path = path.resolve( process.argv[ _config_path + 1 ] );
// check if directory exists and is a valid directory
fs.stat( config_path, function( err, stats ) {
if( err && ... | javascript | function setup() {
// check if config directory is given
if( _config_path !== -1 ) {
// get path
var config_path = path.resolve( process.argv[ _config_path + 1 ] );
// check if directory exists and is a valid directory
fs.stat( config_path, function( err, stats ) {
if( err && ... | [
"function",
"setup",
"(",
")",
"{",
"// check if config directory is given",
"if",
"(",
"_config_path",
"!==",
"-",
"1",
")",
"{",
"// get path",
"var",
"config_path",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"argv",
"[",
"_config_path",
"+",
"1",
"... | Starts the config files setup process. It first asks for the configuration file directory. It then fetches for all
configuration files in the given directory and starts asking for the user values of each entry in each found file. | [
"Starts",
"the",
"config",
"files",
"setup",
"process",
".",
"It",
"first",
"asks",
"for",
"the",
"configuration",
"file",
"directory",
".",
"It",
"then",
"fetches",
"for",
"all",
"configuration",
"files",
"in",
"the",
"given",
"directory",
"and",
"starts",
... | 39551c58d92a4ce065df25e6b9999b8495ca4833 | https://github.com/SebastianOsuna/configure.js/blob/39551c58d92a4ce065df25e6b9999b8495ca4833/bin/configure.js#L106-L135 | train |
SebastianOsuna/configure.js | bin/configure.js | handleConfigEntry | function handleConfigEntry ( defaults, values, parent_name, cb ) {
var entries = Object.keys( defaults ),
c = 0;
var cont = function () { // entry handling function
if( c < entries.length ) {
var key = entries[ c ],
entry = defaults[ key ];
if ( typeof... | javascript | function handleConfigEntry ( defaults, values, parent_name, cb ) {
var entries = Object.keys( defaults ),
c = 0;
var cont = function () { // entry handling function
if( c < entries.length ) {
var key = entries[ c ],
entry = defaults[ key ];
if ( typeof... | [
"function",
"handleConfigEntry",
"(",
"defaults",
",",
"values",
",",
"parent_name",
",",
"cb",
")",
"{",
"var",
"entries",
"=",
"Object",
".",
"keys",
"(",
"defaults",
")",
",",
"c",
"=",
"0",
";",
"var",
"cont",
"=",
"function",
"(",
")",
"{",
"// ... | Recursive handling of config object. It asks the user for values of the each attribute of the config.defaults object.
If the user skips an attribute, the default value is taken.
@param defaults Configuration default values.
@param values Configuration user given values.
@param parent_name Current config object parent n... | [
"Recursive",
"handling",
"of",
"config",
"object",
".",
"It",
"asks",
"the",
"user",
"for",
"values",
"of",
"the",
"each",
"attribute",
"of",
"the",
"config",
".",
"defaults",
"object",
".",
"If",
"the",
"user",
"skips",
"an",
"attribute",
"the",
"default"... | 39551c58d92a4ce065df25e6b9999b8495ca4833 | https://github.com/SebastianOsuna/configure.js/blob/39551c58d92a4ce065df25e6b9999b8495ca4833/bin/configure.js#L145-L209 | train |
beeblebrox3/super-helpers | src/object/index.js | function (paths, obj, defaultValue = null) {
if (!Array.isArray(paths)) {
throw new Error("paths must be an array of strings");
}
let res = defaultValue;
paths.some(path => {
const result = this.getFlattened(path, obj, defaultValue);
if (result !== de... | javascript | function (paths, obj, defaultValue = null) {
if (!Array.isArray(paths)) {
throw new Error("paths must be an array of strings");
}
let res = defaultValue;
paths.some(path => {
const result = this.getFlattened(path, obj, defaultValue);
if (result !== de... | [
"function",
"(",
"paths",
",",
"obj",
",",
"defaultValue",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"paths",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"paths must be an array of strings\"",
")",
";",
"}",
"let",
"res",
... | Receives a list of paths and use getFlattened to get the first existent value
@param {String[]} paths
@param {Object} obj
@param {any} defaultValue
@return {any}
@see getFlattened
@memberof object | [
"Receives",
"a",
"list",
"of",
"paths",
"and",
"use",
"getFlattened",
"to",
"get",
"the",
"first",
"existent",
"value"
] | 15deaf3509bfe47817e6dd3ecd3e6879743b7dd9 | https://github.com/beeblebrox3/super-helpers/blob/15deaf3509bfe47817e6dd3ecd3e6879743b7dd9/src/object/index.js#L49-L65 | train | |
beeblebrox3/super-helpers | src/object/index.js | function (obj) {
"use strict";
if (Object.getPrototypeOf(obj) !== Object.prototype) {
throw Error("obj must be an Object");
}
return Object.keys(obj)[0] || null;
} | javascript | function (obj) {
"use strict";
if (Object.getPrototypeOf(obj) !== Object.prototype) {
throw Error("obj must be an Object");
}
return Object.keys(obj)[0] || null;
} | [
"function",
"(",
"obj",
")",
"{",
"\"use strict\"",
";",
"if",
"(",
"Object",
".",
"getPrototypeOf",
"(",
"obj",
")",
"!==",
"Object",
".",
"prototype",
")",
"{",
"throw",
"Error",
"(",
"\"obj must be an Object\"",
")",
";",
"}",
"return",
"Object",
".",
... | Get first key of an object or null if it doesn't have keys
@param {Object} obj
@return {*}
@memberof object | [
"Get",
"first",
"key",
"of",
"an",
"object",
"or",
"null",
"if",
"it",
"doesn",
"t",
"have",
"keys"
] | 15deaf3509bfe47817e6dd3ecd3e6879743b7dd9 | https://github.com/beeblebrox3/super-helpers/blob/15deaf3509bfe47817e6dd3ecd3e6879743b7dd9/src/object/index.js#L106-L114 | train | |
vkiding/jud-vue-render | src/render/vue/modules/dom.js | function (key, styles) {
key = camelToKebab(key)
let stylesText = ''
for (const k in styles) {
if (styles.hasOwnProperty(k)) {
stylesText += camelToKebab(k) + ':' + styles[k] + ';'
}
}
const styleText = `@${key}{${stylesText}}`
appendCss(styleText, 'dom-added-rules')
} | javascript | function (key, styles) {
key = camelToKebab(key)
let stylesText = ''
for (const k in styles) {
if (styles.hasOwnProperty(k)) {
stylesText += camelToKebab(k) + ':' + styles[k] + ';'
}
}
const styleText = `@${key}{${stylesText}}`
appendCss(styleText, 'dom-added-rules')
} | [
"function",
"(",
"key",
",",
"styles",
")",
"{",
"key",
"=",
"camelToKebab",
"(",
"key",
")",
"let",
"stylesText",
"=",
"''",
"for",
"(",
"const",
"k",
"in",
"styles",
")",
"{",
"if",
"(",
"styles",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
... | for adding fontFace
@param {string} key fontFace
@param {object} styles rules | [
"for",
"adding",
"fontFace"
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/vue/modules/dom.js#L139-L149 | train | |
lightningtgc/grunt-at-csstidy | tasks/csstidy.js | preHandleSrc | function preHandleSrc (cssSrc) {
/*
* fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\9;}
* which has two semicolon( : ) will cause parse error.
*/
cssSrc = cssSrc.replac... | javascript | function preHandleSrc (cssSrc) {
/*
* fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\9;}
* which has two semicolon( : ) will cause parse error.
*/
cssSrc = cssSrc.replac... | [
"function",
"preHandleSrc",
"(",
"cssSrc",
")",
"{",
"/* \n * fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\\9;}\n * which has two semicolon( : ) will cause parse error.\n */",
"c... | Handle special case | [
"Handle",
"special",
"case"
] | efdcf07f7e49b910be289e52834c6e2022b7dd97 | https://github.com/lightningtgc/grunt-at-csstidy/blob/efdcf07f7e49b910be289e52834c6e2022b7dd97/tasks/csstidy.js#L25-L88 | train |
huafu/ember-marked | addon/components/code-section.js | function (code, language, bare) {
var result;
if (typeof hljs !== 'undefined') {
if (language) {
try {
result = hljs.highlight(language, code, true);
}
catch (e) {
Ember.warn(
'[marked] Failing to highlight some code with language `' + language +
... | javascript | function (code, language, bare) {
var result;
if (typeof hljs !== 'undefined') {
if (language) {
try {
result = hljs.highlight(language, code, true);
}
catch (e) {
Ember.warn(
'[marked] Failing to highlight some code with language `' + language +
... | [
"function",
"(",
"code",
",",
"language",
",",
"bare",
")",
"{",
"var",
"result",
";",
"if",
"(",
"typeof",
"hljs",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"language",
")",
"{",
"try",
"{",
"result",
"=",
"hljs",
".",
"highlight",
"(",
"language",... | Highlighter function, using highlight.js if available
@method highlight
@param {String} code
@param {String} [language]
@param {Boolean} [bare=false]
@returns {String|{value: String, language: String}} | [
"Highlighter",
"function",
"using",
"highlight",
".",
"js",
"if",
"available"
] | 372f7aad36cfc5fd6fd9faaef8f561d692852d23 | https://github.com/huafu/ember-marked/blob/372f7aad36cfc5fd6fd9faaef8f561d692852d23/addon/components/code-section.js#L88-L123 | train | |
Antyfive/teo-logger | lib/logger.js | _parseErrors | function _parseErrors() {
let errors = [].slice.call(arguments);
let parsed = [];
errors.forEach(err => {
let message = (err instanceof Error) ? err.stack : err.toString();
parsed.push(message);
});
return parsed;
} | javascript | function _parseErrors() {
let errors = [].slice.call(arguments);
let parsed = [];
errors.forEach(err => {
let message = (err instanceof Error) ? err.stack : err.toString();
parsed.push(message);
});
return parsed;
} | [
"function",
"_parseErrors",
"(",
")",
"{",
"let",
"errors",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"let",
"parsed",
"=",
"[",
"]",
";",
"errors",
".",
"forEach",
"(",
"err",
"=>",
"{",
"let",
"message",
"=",
"(",
"e... | Parses errors. Expects Error instance, or string with message
@returns {Array}
@private | [
"Parses",
"errors",
".",
"Expects",
"Error",
"instance",
"or",
"string",
"with",
"message"
] | 5b632e1ddb939dc839181313ab2e23061d6c2db8 | https://github.com/Antyfive/teo-logger/blob/5b632e1ddb939dc839181313ab2e23061d6c2db8/lib/logger.js#L18-L28 | train |
Antyfive/teo-logger | lib/logger.js | _log | function _log(message) {
if (cluster.isMaster) {
// write directly to the log file
console.log(_format(message));
}
else {
// send to master
cluster.worker.process.send({
type: "logging",
data: {
message: message,
worker... | javascript | function _log(message) {
if (cluster.isMaster) {
// write directly to the log file
console.log(_format(message));
}
else {
// send to master
cluster.worker.process.send({
type: "logging",
data: {
message: message,
worker... | [
"function",
"_log",
"(",
"message",
")",
"{",
"if",
"(",
"cluster",
".",
"isMaster",
")",
"{",
"// write directly to the log file",
"console",
".",
"log",
"(",
"_format",
"(",
"message",
")",
")",
";",
"}",
"else",
"{",
"// send to master",
"cluster",
".",
... | Logs message. Forwards message from child process to master
@param {String} message
@private | [
"Logs",
"message",
".",
"Forwards",
"message",
"from",
"child",
"process",
"to",
"master"
] | 5b632e1ddb939dc839181313ab2e23061d6c2db8 | https://github.com/Antyfive/teo-logger/blob/5b632e1ddb939dc839181313ab2e23061d6c2db8/lib/logger.js#L56-L72 | train |
crcn/mojo-views | lib/views/base/index.js | BaseView | function BaseView (properties, application) {
// note that if application is not defined, this.application will
// default to the default, global application.
this.application = application;
this._onParent = _.bind(this._onParent, this);
SubindableObject.call(this, properties);
/**
* The main app... | javascript | function BaseView (properties, application) {
// note that if application is not defined, this.application will
// default to the default, global application.
this.application = application;
this._onParent = _.bind(this._onParent, this);
SubindableObject.call(this, properties);
/**
* The main app... | [
"function",
"BaseView",
"(",
"properties",
",",
"application",
")",
"{",
"// note that if application is not defined, this.application will",
"// default to the default, global application.",
"this",
".",
"application",
"=",
"application",
";",
"this",
".",
"_onParent",
"=",
... | Called when the view is rendered
@event render
Called when the view is remove
@event remove | [
"Called",
"when",
"the",
"view",
"is",
"rendered"
] | 5c4899fb8f117f98ad02a34b714ebb0cc646caba | https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L31-L51 | train |
crcn/mojo-views | lib/views/base/index.js | function (data) {
this.on("change:parent", this._onParent);
// copy the data to this object. Note this shaves a TON
// of time off initializing any view, especially list items if we
// use this method over @setProperties data
if (false) {
for(var key in data) {
this[key] = data[key];
... | javascript | function (data) {
this.on("change:parent", this._onParent);
// copy the data to this object. Note this shaves a TON
// of time off initializing any view, especially list items if we
// use this method over @setProperties data
if (false) {
for(var key in data) {
this[key] = data[key];
... | [
"function",
"(",
"data",
")",
"{",
"this",
".",
"on",
"(",
"\"change:parent\"",
",",
"this",
".",
"_onParent",
")",
";",
"// copy the data to this object. Note this shaves a TON",
"// of time off initializing any view, especially list items if we",
"// use this method over @setPr... | Called when the view is instantiated
@method initialize
@param {Object} options options passed when creating the view | [
"Called",
"when",
"the",
"view",
"is",
"instantiated"
] | 5c4899fb8f117f98ad02a34b714ebb0cc646caba | https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L96-L110 | train | |
crcn/mojo-views | lib/views/base/index.js | function () {
var path = [], cp = this;
while (cp) {
path.unshift(cp.name || cp.constructor.name);
cp = cp.parent;
}
return path.join(".");
} | javascript | function () {
var path = [], cp = this;
while (cp) {
path.unshift(cp.name || cp.constructor.name);
cp = cp.parent;
}
return path.join(".");
} | [
"function",
"(",
")",
"{",
"var",
"path",
"=",
"[",
"]",
",",
"cp",
"=",
"this",
";",
"while",
"(",
"cp",
")",
"{",
"path",
".",
"unshift",
"(",
"cp",
".",
"name",
"||",
"cp",
".",
"constructor",
".",
"name",
")",
";",
"cp",
"=",
"cp",
".",
... | Returns the path to the view
@method path | [
"Returns",
"the",
"path",
"to",
"the",
"view"
] | 5c4899fb8f117f98ad02a34b714ebb0cc646caba | https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L144-L153 | train | |
crcn/mojo-views | lib/views/base/index.js | function () {
// if rendered, then just return the fragment
if (this._rendered) {
return this.section.render();
}
this._rendered = true;
if (this._cleanupJanitor) {
this._cleanupJanitor.dispose();
}
if (!this.section) {
this._createSection();
}
this.willRender(... | javascript | function () {
// if rendered, then just return the fragment
if (this._rendered) {
return this.section.render();
}
this._rendered = true;
if (this._cleanupJanitor) {
this._cleanupJanitor.dispose();
}
if (!this.section) {
this._createSection();
}
this.willRender(... | [
"function",
"(",
")",
"{",
"// if rendered, then just return the fragment",
"if",
"(",
"this",
".",
"_rendered",
")",
"{",
"return",
"this",
".",
"section",
".",
"render",
"(",
")",
";",
"}",
"this",
".",
"_rendered",
"=",
"true",
";",
"if",
"(",
"this",
... | Renders the view
@method render
@return {Object} document fragment | [
"Renders",
"the",
"view"
] | 5c4899fb8f117f98ad02a34b714ebb0cc646caba | https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L161-L187 | train | |
crcn/mojo-views | lib/views/base/index.js | function (search) {
if (!this.section) this.render();
var el = noselector(this.section.getChildNodes());
if (arguments.length) {
return el.find(search).andSelf().filter(search);
}
return el;
} | javascript | function (search) {
if (!this.section) this.render();
var el = noselector(this.section.getChildNodes());
if (arguments.length) {
return el.find(search).andSelf().filter(search);
}
return el;
} | [
"function",
"(",
"search",
")",
"{",
"if",
"(",
"!",
"this",
".",
"section",
")",
"this",
".",
"render",
"(",
")",
";",
"var",
"el",
"=",
"noselector",
"(",
"this",
".",
"section",
".",
"getChildNodes",
"(",
")",
")",
";",
"if",
"(",
"arguments",
... | jquery selector for elements owned by the view
@method $
@param {String} selector | [
"jquery",
"selector",
"for",
"elements",
"owned",
"by",
"the",
"view"
] | 5c4899fb8f117f98ad02a34b714ebb0cc646caba | https://github.com/crcn/mojo-views/blob/5c4899fb8f117f98ad02a34b714ebb0cc646caba/lib/views/base/index.js#L248-L258 | train | |
benderjs/dom-combiner | lib/combiner.js | merge | function merge( elem, callback ) {
var old = find( destChildren, elem.name ),
nl;
// merge with old element
if ( old ) {
if ( typeof callback == 'function' ) {
return callback( old );
}
_.merge( old.attribs, elem.attribs );
if ( elem.children ) {
combine( old, elem );
}
// append n... | javascript | function merge( elem, callback ) {
var old = find( destChildren, elem.name ),
nl;
// merge with old element
if ( old ) {
if ( typeof callback == 'function' ) {
return callback( old );
}
_.merge( old.attribs, elem.attribs );
if ( elem.children ) {
combine( old, elem );
}
// append n... | [
"function",
"merge",
"(",
"elem",
",",
"callback",
")",
"{",
"var",
"old",
"=",
"find",
"(",
"destChildren",
",",
"elem",
".",
"name",
")",
",",
"nl",
";",
"// merge with old element",
"if",
"(",
"old",
")",
"{",
"if",
"(",
"typeof",
"callback",
"==",
... | Merge element with equivalent found in destination
@param {Object} elem Source element
@param {Function} callback Callback called when equivalent found | [
"Merge",
"element",
"with",
"equivalent",
"found",
"in",
"destination"
] | 6971337fff22668664906da757fc29b8a6f4cad1 | https://github.com/benderjs/dom-combiner/blob/6971337fff22668664906da757fc29b8a6f4cad1/lib/combiner.js#L57-L84 | train |
benderjs/dom-combiner | lib/combiner.js | mergeDoctype | function mergeDoctype( elem ) {
merge( elem, function( old ) {
utils.replaceElement( old, elem );
destChildren[ destChildren.indexOf( old ) ] = elem;
} );
} | javascript | function mergeDoctype( elem ) {
merge( elem, function( old ) {
utils.replaceElement( old, elem );
destChildren[ destChildren.indexOf( old ) ] = elem;
} );
} | [
"function",
"mergeDoctype",
"(",
"elem",
")",
"{",
"merge",
"(",
"elem",
",",
"function",
"(",
"old",
")",
"{",
"utils",
".",
"replaceElement",
"(",
"old",
",",
"elem",
")",
";",
"destChildren",
"[",
"destChildren",
".",
"indexOf",
"(",
"old",
")",
"]"... | Merge doctype directives
@param {Object} elem New doctype directive | [
"Merge",
"doctype",
"directives"
] | 6971337fff22668664906da757fc29b8a6f4cad1 | https://github.com/benderjs/dom-combiner/blob/6971337fff22668664906da757fc29b8a6f4cad1/lib/combiner.js#L90-L95 | train |
the-labo/the-resource-user | example/example-usage.js | signup | async function signup (username, password, options = {}) {
let { email = null, profile = {}, roles = [] } = options
let user = await User.create({ username, email })
user.sign = await UserSign.create({ user, password })
user.profile = await UserProfile.create({ user, profile })
user.roles = await Us... | javascript | async function signup (username, password, options = {}) {
let { email = null, profile = {}, roles = [] } = options
let user = await User.create({ username, email })
user.sign = await UserSign.create({ user, password })
user.profile = await UserProfile.create({ user, profile })
user.roles = await Us... | [
"async",
"function",
"signup",
"(",
"username",
",",
"password",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"{",
"email",
"=",
"null",
",",
"profile",
"=",
"{",
"}",
",",
"roles",
"=",
"[",
"]",
"}",
"=",
"options",
"let",
"user",
"=",
"awai... | Signup an user | [
"Signup",
"an",
"user"
] | c11b720e7e29325bef8299729f7b29d638cb4888 | https://github.com/the-labo/the-resource-user/blob/c11b720e7e29325bef8299729f7b29d638cb4888/example/example-usage.js#L29-L37 | train |
the-labo/the-resource-user | example/example-usage.js | signin | async function signin (username, password, options = {}) {
let { agent } = options
let user = await User.only({ username })
let sign = user && await UserSign.only({ user })
let valid = sign && await sign.testPassword(password)
if (!valid) {
throw new Error('Signin failed!')
}
await use... | javascript | async function signin (username, password, options = {}) {
let { agent } = options
let user = await User.only({ username })
let sign = user && await UserSign.only({ user })
let valid = sign && await sign.testPassword(password)
if (!valid) {
throw new Error('Signin failed!')
}
await use... | [
"async",
"function",
"signin",
"(",
"username",
",",
"password",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"{",
"agent",
"}",
"=",
"options",
"let",
"user",
"=",
"await",
"User",
".",
"only",
"(",
"{",
"username",
"}",
")",
"let",
"sign",
"="... | Start user session | [
"Start",
"user",
"session"
] | c11b720e7e29325bef8299729f7b29d638cb4888 | https://github.com/the-labo/the-resource-user/blob/c11b720e7e29325bef8299729f7b29d638cb4888/example/example-usage.js#L40-L51 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/compiler.js | FunctionCompiler | function FunctionCompiler() {
var _this;
_classCallCheck(this, FunctionCompiler);
_this = _possibleConstructorReturn(this, _getPrototypeOf(FunctionCompiler).call(this));
/**
* Compile sequence.
* @type {Array<function>}
*/
_this._sequence = [_this._uncomment, _this._validate, _this... | javascript | function FunctionCompiler() {
var _this;
_classCallCheck(this, FunctionCompiler);
_this = _possibleConstructorReturn(this, _getPrototypeOf(FunctionCompiler).call(this));
/**
* Compile sequence.
* @type {Array<function>}
*/
_this._sequence = [_this._uncomment, _this._validate, _this... | [
"function",
"FunctionCompiler",
"(",
")",
"{",
"var",
"_this",
";",
"_classCallCheck",
"(",
"this",
",",
"FunctionCompiler",
")",
";",
"_this",
"=",
"_possibleConstructorReturn",
"(",
"this",
",",
"_getPrototypeOf",
"(",
"FunctionCompiler",
")",
".",
"call",
"("... | Construction time again. | [
"Construction",
"time",
"again",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L523-L578 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/compiler.js | ScriptCompiler | function ScriptCompiler() {
var _this4;
_classCallCheck(this, ScriptCompiler);
_this4 = _possibleConstructorReturn(this, _getPrototypeOf(ScriptCompiler).call(this));
_this4.inputs = {};
return _this4;
} | javascript | function ScriptCompiler() {
var _this4;
_classCallCheck(this, ScriptCompiler);
_this4 = _possibleConstructorReturn(this, _getPrototypeOf(ScriptCompiler).call(this));
_this4.inputs = {};
return _this4;
} | [
"function",
"ScriptCompiler",
"(",
")",
"{",
"var",
"_this4",
";",
"_classCallCheck",
"(",
"this",
",",
"ScriptCompiler",
")",
";",
"_this4",
"=",
"_possibleConstructorReturn",
"(",
"this",
",",
"_getPrototypeOf",
"(",
"ScriptCompiler",
")",
".",
"call",
"(",
... | Map observed types.
Add custom sequence.
@param {string} key | [
"Map",
"observed",
"types",
".",
"Add",
"custom",
"sequence",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L802-L810 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/compiler.js | strip | function strip(script) {
script = this._stripout(script, '<!--', '-->');
script = this._stripout(script, '/*', '*/');
script = this._stripout(script, '^//', '\n');
return script;
} | javascript | function strip(script) {
script = this._stripout(script, '<!--', '-->');
script = this._stripout(script, '/*', '*/');
script = this._stripout(script, '^//', '\n');
return script;
} | [
"function",
"strip",
"(",
"script",
")",
"{",
"script",
"=",
"this",
".",
"_stripout",
"(",
"script",
",",
"'<!--'",
",",
"'-->'",
")",
";",
"script",
"=",
"this",
".",
"_stripout",
"(",
"script",
",",
"'/*'",
",",
"'*/'",
")",
";",
"script",
"=",
... | Strip HTML and JS comments.
@param {string} script
@returns {string} | [
"Strip",
"HTML",
"and",
"JS",
"comments",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L941-L946 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/compiler.js | Runner | function Runner() {
_classCallCheck(this, Runner);
this.firstline = false;
this.lastline = false;
this.firstchar = false;
this.lastchar = false;
this._line = null;
this._index = -1;
} | javascript | function Runner() {
_classCallCheck(this, Runner);
this.firstline = false;
this.lastline = false;
this.firstchar = false;
this.lastchar = false;
this._line = null;
this._index = -1;
} | [
"function",
"Runner",
"(",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"Runner",
")",
";",
"this",
".",
"firstline",
"=",
"false",
";",
"this",
".",
"lastline",
"=",
"false",
";",
"this",
".",
"firstchar",
"=",
"false",
";",
"this",
".",
"lastchar",... | Let's go. | [
"Let",
"s",
"go",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L1061-L1070 | train |
wunderbyte/grunt-spiritual-edbml | tasks/things/compiler.js | Output | function Output() {
var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
_classCallCheck(this, Output);
this.body = body;
this.temp = null;
} | javascript | function Output() {
var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
_classCallCheck(this, Output);
this.body = body;
this.temp = null;
} | [
"function",
"Output",
"(",
")",
"{",
"var",
"body",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"''",
";",
"_classCallCheck",
"(",
"this",
",",
"Output",
")",
... | Collecting JS code. | [
"Collecting",
"JS",
"code",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/compiler.js#L1722-L1729 | train |
andrewscwei/requiem | src/dom/getState.js | getState | function getState(element) {
assertType(element, Node, false, 'Invalid element specified');
let state = element.state || element.getAttribute(Directive.STATE);
if (!state || state === '')
return null;
else
return state;
} | javascript | function getState(element) {
assertType(element, Node, false, 'Invalid element specified');
let state = element.state || element.getAttribute(Directive.STATE);
if (!state || state === '')
return null;
else
return state;
} | [
"function",
"getState",
"(",
"element",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"let",
"state",
"=",
"element",
".",
"state",
"||",
"element",
".",
"getAttribute",
"(",
"Directive",
"."... | Gets the current state of a DOM element as defined by Directive.STATE.
@param {Node} element - Target element.
@return {string} State of the target element.
@alias module:requiem~dom.getState | [
"Gets",
"the",
"current",
"state",
"of",
"a",
"DOM",
"element",
"as",
"defined",
"by",
"Directive",
".",
"STATE",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getState.js#L17-L26 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.