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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
var name = this.getName();
for ( var i = 0 ; i < arguments.length ; i++ )
{
if ( arguments[ i ] == name )
return true;
}
return false;
} | javascript | function()
{
var name = this.getName();
for ( var i = 0 ; i < arguments.length ; i++ )
{
if ( arguments[ i ] == name )
return true;
}
return false;
} | [
"function",
"(",
")",
"{",
"var",
"name",
"=",
"this",
".",
"getName",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"arguments",
"[",
"i",
"]",
"==",
"name",
... | Checks if the element name matches one or more names.
@param {String} name[,name[,...]] One or more names to be checked.
@returns {Boolean} true if the element name matches any of the names.
@example
var element = new CKEDITOR.element( 'span' );
alert( <b>element.is( 'span' )</b> ); "true"
alert( <b>element.is( 'p', '... | [
"Checks",
"if",
"the",
"element",
"name",
"matches",
"one",
"or",
"more",
"names",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L711-L720 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden',
elementWindow,
elementWindowFrame;
// Webkit and Opera report non-zero offsetHeight despite that
// element is inside an invisible iframe. (#4542)
if ( isVisibl... | javascript | function()
{
var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden',
elementWindow,
elementWindowFrame;
// Webkit and Opera report non-zero offsetHeight despite that
// element is inside an invisible iframe. (#4542)
if ( isVisibl... | [
"function",
"(",
")",
"{",
"var",
"isVisible",
"=",
"(",
"this",
".",
"$",
".",
"offsetHeight",
"||",
"this",
".",
"$",
".",
"offsetWidth",
")",
"&&",
"this",
".",
"getComputedStyle",
"(",
"'visibility'",
")",
"!=",
"'hidden'",
",",
"elementWindow",
",",... | Checks if this element is visible. May not work if the element is
child of an element with visibility set to "hidden", but works well
on the great majority of cases.
@return {Boolean} True if the element is visible. | [
"Checks",
"if",
"this",
"element",
"is",
"visible",
".",
"May",
"not",
"work",
"if",
"the",
"element",
"is",
"child",
"of",
"an",
"element",
"with",
"visibility",
"set",
"to",
"hidden",
"but",
"works",
"well",
"on",
"the",
"great",
"majority",
"of",
"cas... | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L793-L813 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
if ( !CKEDITOR.dtd.$removeEmpty[ this.getName() ] )
return false;
var children = this.getChildren();
for ( var i = 0, count = children.count(); i < count; i++ )
{
var child = children.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && child.data( 'cke-bookmark' ... | javascript | function()
{
if ( !CKEDITOR.dtd.$removeEmpty[ this.getName() ] )
return false;
var children = this.getChildren();
for ( var i = 0, count = children.count(); i < count; i++ )
{
var child = children.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && child.data( 'cke-bookmark' ... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"CKEDITOR",
".",
"dtd",
".",
"$removeEmpty",
"[",
"this",
".",
"getName",
"(",
")",
"]",
")",
"return",
"false",
";",
"var",
"children",
"=",
"this",
".",
"getChildren",
"(",
")",
";",
"for",
"(",
"var",
... | Whether it's an empty inline elements which has no visual impact when removed. | [
"Whether",
"it",
"s",
"an",
"empty",
"inline",
"elements",
"which",
"has",
"no",
"visual",
"impact",
"when",
"removed",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L818-L838 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( opacity )
{
if ( CKEDITOR.env.ie )
{
opacity = Math.round( opacity * 100 );
this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' );
}
else
this.setStyle( 'opacity', opacity );
} | javascript | function( opacity )
{
if ( CKEDITOR.env.ie )
{
opacity = Math.round( opacity * 100 );
this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' );
}
else
this.setStyle( 'opacity', opacity );
} | [
"function",
"(",
"opacity",
")",
"{",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
")",
"{",
"opacity",
"=",
"Math",
".",
"round",
"(",
"opacity",
"*",
"100",
")",
";",
"this",
".",
"setStyle",
"(",
"'filter'",
",",
"opacity",
">=",
"100",
"?",
... | Sets the opacity of an element.
@param {Number} opacity A number within the range [0.0, 1.0].
@example
var element = CKEDITOR.dom.element.getById( 'myElement' );
<b>element.setOpacity( 0.75 )</b>; | [
"Sets",
"the",
"opacity",
"of",
"an",
"element",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1227-L1236 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
var $ = this.$;
try
{
// In IE, with custom document.domain, it may happen that
// the iframe is not yet available, resulting in "Access
// Denied" for the following property access.
$.contentWindow.document;
}
catch ( e )
{
// Trick to solve this issue... | javascript | function()
{
var $ = this.$;
try
{
// In IE, with custom document.domain, it may happen that
// the iframe is not yet available, resulting in "Access
// Denied" for the following property access.
$.contentWindow.document;
}
catch ( e )
{
// Trick to solve this issue... | [
"function",
"(",
")",
"{",
"var",
"$",
"=",
"this",
".",
"$",
";",
"try",
"{",
"// In IE, with custom document.domain, it may happen that\r",
"// the iframe is not yet available, resulting in \"Access\r",
"// Denied\" for the following property access.\r",
"$",
".",
"contentWindo... | Returns the inner document of this IFRAME element.
@returns {CKEDITOR.dom.document} The inner document. | [
"Returns",
"the",
"inner",
"document",
"of",
"this",
"IFRAME",
"element",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1461-L1493 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( dest, skipAttributes )
{
var attributes = this.$.attributes;
skipAttributes = skipAttributes || {};
for ( var n = 0 ; n < attributes.length ; n++ )
{
var attribute = attributes[n];
// Lowercase attribute name hard rule is broken for
// some attribute on IE, e.g. CHECKED.
... | javascript | function( dest, skipAttributes )
{
var attributes = this.$.attributes;
skipAttributes = skipAttributes || {};
for ( var n = 0 ; n < attributes.length ; n++ )
{
var attribute = attributes[n];
// Lowercase attribute name hard rule is broken for
// some attribute on IE, e.g. CHECKED.
... | [
"function",
"(",
"dest",
",",
"skipAttributes",
")",
"{",
"var",
"attributes",
"=",
"this",
".",
"$",
".",
"attributes",
";",
"skipAttributes",
"=",
"skipAttributes",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"attributes",
... | Copy all the attributes from one node to the other, kinda like a clone
skipAttributes is an object with the attributes that must NOT be copied.
@param {CKEDITOR.dom.element} dest The destination element.
@param {Object} skipAttributes A dictionary of attributes to skip.
@example | [
"Copy",
"all",
"the",
"attributes",
"from",
"one",
"node",
"to",
"the",
"other",
"kinda",
"like",
"a",
"clone",
"skipAttributes",
"is",
"an",
"object",
"with",
"the",
"attributes",
"that",
"must",
"NOT",
"be",
"copied",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1502-L1537 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( newTag )
{
// If it's already correct exit here.
if ( this.getName() == newTag )
return;
var doc = this.getDocument();
// Create the new node.
var newNode = new CKEDITOR.dom.element( newTag, doc );
// Copy all attributes.
this.copyAttributes( newNode );
// Move ... | javascript | function( newTag )
{
// If it's already correct exit here.
if ( this.getName() == newTag )
return;
var doc = this.getDocument();
// Create the new node.
var newNode = new CKEDITOR.dom.element( newTag, doc );
// Copy all attributes.
this.copyAttributes( newNode );
// Move ... | [
"function",
"(",
"newTag",
")",
"{",
"// If it's already correct exit here.\r",
"if",
"(",
"this",
".",
"getName",
"(",
")",
"==",
"newTag",
")",
"return",
";",
"var",
"doc",
"=",
"this",
".",
"getDocument",
"(",
")",
";",
"// Create the new node.\r",
"var",
... | Changes the tag name of the current element.
@param {String} newTag The new tag for the element. | [
"Changes",
"the",
"tag",
"name",
"of",
"the",
"current",
"element",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1543-L1564 | train | |
fvsch/gulp-task-maker | example/tasks/minjs/index.js | minjs | function minjs(config, tools) {
return tools.simpleStream(config, [
config.concat && concat(config.concat),
config.minify && uglify(config.uglifyjs)
])
} | javascript | function minjs(config, tools) {
return tools.simpleStream(config, [
config.concat && concat(config.concat),
config.minify && uglify(config.uglifyjs)
])
} | [
"function",
"minjs",
"(",
"config",
",",
"tools",
")",
"{",
"return",
"tools",
".",
"simpleStream",
"(",
"config",
",",
"[",
"config",
".",
"concat",
"&&",
"concat",
"(",
"config",
".",
"concat",
")",
",",
"config",
".",
"minify",
"&&",
"uglify",
"(",
... | Make a simple JS build, optionally concatenated and minified
@param {object} config - task configuration
@param {object} tools - gtm utility functions
@return {object} | [
"Make",
"a",
"simple",
"JS",
"build",
"optionally",
"concatenated",
"and",
"minified"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/example/tasks/minjs/index.js#L10-L15 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/docprops/dialogs/docprops.js | resetStyle | function resetStyle( element, prop, resetVal )
{
element.removeStyle( prop );
if ( element.getComputedStyle( prop ) != resetVal )
element.setStyle( prop, resetVal );
} | javascript | function resetStyle( element, prop, resetVal )
{
element.removeStyle( prop );
if ( element.getComputedStyle( prop ) != resetVal )
element.setStyle( prop, resetVal );
} | [
"function",
"resetStyle",
"(",
"element",
",",
"prop",
",",
"resetVal",
")",
"{",
"element",
".",
"removeStyle",
"(",
"prop",
")",
";",
"if",
"(",
"element",
".",
"getComputedStyle",
"(",
"prop",
")",
"!=",
"resetVal",
")",
"element",
".",
"setStyle",
"(... | We cannot just remove the style from the element, as it might be affected from non-inline stylesheets. To get the proper result, we should manually set the inline style to its default value. | [
"We",
"cannot",
"just",
"remove",
"the",
"style",
"from",
"the",
"element",
"as",
"it",
"might",
"be",
"affected",
"from",
"non",
"-",
"inline",
"stylesheets",
".",
"To",
"get",
"the",
"proper",
"result",
"we",
"should",
"manually",
"set",
"the",
"inline",... | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/docprops/dialogs/docprops.js#L132-L137 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/docprops/dialogs/docprops.js | function( id, label, fieldProps )
{
return {
type : 'hbox',
padding : 0,
widths : [ '60%', '40%' ],
children : [
CKEDITOR.tools.extend( {
type : 'text',
id : id,
label : lang[ label ]
}, fieldProps || {}, 1 ),
{
type : 'button',
id : id + 'Choose',
... | javascript | function( id, label, fieldProps )
{
return {
type : 'hbox',
padding : 0,
widths : [ '60%', '40%' ],
children : [
CKEDITOR.tools.extend( {
type : 'text',
id : id,
label : lang[ label ]
}, fieldProps || {}, 1 ),
{
type : 'button',
id : id + 'Choose',
... | [
"function",
"(",
"id",
",",
"label",
",",
"fieldProps",
")",
"{",
"return",
"{",
"type",
":",
"'hbox'",
",",
"padding",
":",
"0",
",",
"widths",
":",
"[",
"'60%'",
",",
"'40%'",
"]",
",",
"children",
":",
"[",
"CKEDITOR",
".",
"tools",
".",
"extend... | Utilty to shorten the creation of color fields in the dialog. | [
"Utilty",
"to",
"shorten",
"the",
"creation",
"of",
"color",
"fields",
"in",
"the",
"dialog",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/docprops/dialogs/docprops.js#L140-L169 | train | |
cblanquera/acquire | acquire.js | function(paths, callback, results, cached) {
results = results || [];
if(!paths.length) {
callback.apply(null, results);
return results;
}
var path = paths.shift();
//what do we do if it's not a string ?
if(typeof path !== 'string') {
... | javascript | function(paths, callback, results, cached) {
results = results || [];
if(!paths.length) {
callback.apply(null, results);
return results;
}
var path = paths.shift();
//what do we do if it's not a string ?
if(typeof path !== 'string') {
... | [
"function",
"(",
"paths",
",",
"callback",
",",
"results",
",",
"cached",
")",
"{",
"results",
"=",
"results",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"paths",
".",
"length",
")",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"results",
")",
";",
... | Loads files by the list
@param array
@param function
@param array current results
@param bool whether to use cache
@return void | [
"Loads",
"files",
"by",
"the",
"list"
] | 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L377-L399 | train | |
cblanquera/acquire | acquire.js | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just add it
return queue[source].push(callback);
}
//otherwise there is not a queue
//so let's create one
queue[source]... | javascript | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just add it
return queue[source].push(callback);
}
//otherwise there is not a queue
//so let's create one
queue[source]... | [
"function",
"(",
"source",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"noop",
";",
"//if there's a queue",
"if",
"(",
"queue",
"[",
"source",
"]",
"instanceof",
"Array",
")",
"{",
"//just add it",
"return",
"queue",
"[",
"source",
"]",
"... | Gets a script remotely, runs it
and caches it.
@param string
@param function
@return void | [
"Gets",
"a",
"script",
"remotely",
"runs",
"it",
"and",
"caches",
"it",
"."
] | 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L409-L445 | train | |
cblanquera/acquire | acquire.js | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just call the callback
return callback();
}
//otherwise there is not a queue
//so let's create one
queue[source] = [];
... | javascript | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just call the callback
return callback();
}
//otherwise there is not a queue
//so let's create one
queue[source] = [];
... | [
"function",
"(",
"source",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"noop",
";",
"//if there's a queue",
"if",
"(",
"queue",
"[",
"source",
"]",
"instanceof",
"Array",
")",
"{",
"//just call the callback",
"return",
"callback",
"(",
")",
... | Gets a style remotely
and caches it.
@param string
@param function
@return void | [
"Gets",
"a",
"style",
"remotely",
"and",
"caches",
"it",
"."
] | 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L455-L477 | train | |
cblanquera/acquire | acquire.js | function(url, success, fail) {
success = success || noop;
fail = fail || noop;
//if there's a queue
if (queue[url] instanceof Array) {
//just add it
return queue[url].push({
success: success,
fail: fail
});
}
... | javascript | function(url, success, fail) {
success = success || noop;
fail = fail || noop;
//if there's a queue
if (queue[url] instanceof Array) {
//just add it
return queue[url].push({
success: success,
fail: fail
});
}
... | [
"function",
"(",
"url",
",",
"success",
",",
"fail",
")",
"{",
"success",
"=",
"success",
"||",
"noop",
";",
"fail",
"=",
"fail",
"||",
"noop",
";",
"//if there's a queue",
"if",
"(",
"queue",
"[",
"url",
"]",
"instanceof",
"Array",
")",
"{",
"//just a... | Gets a file remotely
and caches it.
@param string
@param function success callback
@param function fail callback
@return void | [
"Gets",
"a",
"file",
"remotely",
"and",
"caches",
"it",
"."
] | 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L488-L578 | train | |
esha/Eventi | dist/eventi.js | function(type, event, handler) {
_.parsers.forEach(function(parser) {
type = type.replace(parser[0], function() {
var args = _.slice(arguments, 1);
args.unshift(event, handler);
return parser[1].apply(event, args) || '';
});
});
... | javascript | function(type, event, handler) {
_.parsers.forEach(function(parser) {
type = type.replace(parser[0], function() {
var args = _.slice(arguments, 1);
args.unshift(event, handler);
return parser[1].apply(event, args) || '';
});
});
... | [
"function",
"(",
"type",
",",
"event",
",",
"handler",
")",
"{",
"_",
".",
"parsers",
".",
"forEach",
"(",
"function",
"(",
"parser",
")",
"{",
"type",
"=",
"type",
".",
"replace",
"(",
"parser",
"[",
"0",
"]",
",",
"function",
"(",
")",
"{",
"va... | only an extension hook | [
"only",
"an",
"extension",
"hook"
] | 2a5cf530ee7f69c6a53426d38b129b6d0e2c45dd | https://github.com/esha/Eventi/blob/2a5cf530ee7f69c6a53426d38b129b6d0e2c45dd/dist/eventi.js#L74-L83 | train | |
Testlio/lambda-foundation | lib/error/index.js | report | function report(error, additionalTags, extra) {
let sentTags = tags ? [].concat(tags) : [];
if (additionalTags) {
sentTags = sentTags.concat(additionalTags);
}
return Promise.resolve(sentTags).then(function(t) {
// Need this wrapping so that our internal implementation can safely throw... | javascript | function report(error, additionalTags, extra) {
let sentTags = tags ? [].concat(tags) : [];
if (additionalTags) {
sentTags = sentTags.concat(additionalTags);
}
return Promise.resolve(sentTags).then(function(t) {
// Need this wrapping so that our internal implementation can safely throw... | [
"function",
"report",
"(",
"error",
",",
"additionalTags",
",",
"extra",
")",
"{",
"let",
"sentTags",
"=",
"tags",
"?",
"[",
"]",
".",
"concat",
"(",
"tags",
")",
":",
"[",
"]",
";",
"if",
"(",
"additionalTags",
")",
"{",
"sentTags",
"=",
"sentTags",... | Report an error, with optional additional tags
@param error - error to report
@param additionalTags - optional additional tags to report, along with the
default set of tags set on the module
@param extra - optional extra metadata to include in the error report
@returns promise which resolves into the passed in error | [
"Report",
"an",
"error",
"with",
"optional",
"additional",
"tags"
] | d6db22ab7974b9279f17466f36f77af4d53fde01 | https://github.com/Testlio/lambda-foundation/blob/d6db22ab7974b9279f17466f36f77af4d53fde01/lib/error/index.js#L25-L58 | train |
Testlio/lambda-foundation | lib/error/index.js | LambdaError | function LambdaError(code, message, extra, request) {
Error.captureStackTrace(this, this.constructor);
this.name = 'LambdaError';
this.message = `${code}: ${message}`;
this.code = code;
this.extra = extra;
this.request = request;
// Also capture a native error internally, which
// we ca... | javascript | function LambdaError(code, message, extra, request) {
Error.captureStackTrace(this, this.constructor);
this.name = 'LambdaError';
this.message = `${code}: ${message}`;
this.code = code;
this.extra = extra;
this.request = request;
// Also capture a native error internally, which
// we ca... | [
"function",
"LambdaError",
"(",
"code",
",",
"message",
",",
"extra",
",",
"request",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
".",
"constructor",
")",
";",
"this",
".",
"name",
"=",
"'LambdaError'",
";",
"this",
".",
"messa... | Create a new error object
@param code - code for the error (for example HTTP response code)
@param message - error message
@param extra - additional metadata sent when reporting the error
@param request - optional request information sent when reporting
@returns error object | [
"Create",
"a",
"new",
"error",
"object"
] | d6db22ab7974b9279f17466f36f77af4d53fde01 | https://github.com/Testlio/lambda-foundation/blob/d6db22ab7974b9279f17466f36f77af4d53fde01/lib/error/index.js#L81-L93 | train |
rhythmagency/rhythm.framework | lib/jquery/jquery.dataAttributeFramework.js | function ($element, event, fn) {
var handler = {
$element: $element,
event: event,
fn: fn
};
existingHandlers.push(handler);
return $element.on(event, fn);
} | javascript | function ($element, event, fn) {
var handler = {
$element: $element,
event: event,
fn: fn
};
existingHandlers.push(handler);
return $element.on(event, fn);
} | [
"function",
"(",
"$element",
",",
"event",
",",
"fn",
")",
"{",
"var",
"handler",
"=",
"{",
"$element",
":",
"$element",
",",
"event",
":",
"event",
",",
"fn",
":",
"fn",
"}",
";",
"existingHandlers",
".",
"push",
"(",
"handler",
")",
";",
"return",
... | Attaches events, keeping track of handlers. | [
"Attaches",
"events",
"keeping",
"track",
"of",
"handlers",
"."
] | 056671a8596f1d9c23f8cbe780659af0abc8041f | https://github.com/rhythmagency/rhythm.framework/blob/056671a8596f1d9c23f8cbe780659af0abc8041f/lib/jquery/jquery.dataAttributeFramework.js#L19-L27 | train | |
jchook/virtual-dom-handlebars | lib/VNode.js | VNode | function VNode(tagName, attributes, children) {
this.simple = true;
this.tagName = tagName; // non-virtual VText
this.attributes = attributes; // javascript
this.children = new VTree(children);
} | javascript | function VNode(tagName, attributes, children) {
this.simple = true;
this.tagName = tagName; // non-virtual VText
this.attributes = attributes; // javascript
this.children = new VTree(children);
} | [
"function",
"VNode",
"(",
"tagName",
",",
"attributes",
",",
"children",
")",
"{",
"this",
".",
"simple",
"=",
"true",
";",
"this",
".",
"tagName",
"=",
"tagName",
";",
"// non-virtual VText",
"this",
".",
"attributes",
"=",
"attributes",
";",
"// javascript... | Node that can have children | [
"Node",
"that",
"can",
"have",
"children"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/VNode.js#L8-L13 | train |
shlomiassaf/resty-stone | lib/RestListMetadata.js | groupFieldsByType | function groupFieldsByType(list){
var fields = {};
_.each(list.fields, function(v,k) {
if (! fields.hasOwnProperty(v.type)) fields[v.type] = [];
fields[v.type].push(v);
});
return fields;
} | javascript | function groupFieldsByType(list){
var fields = {};
_.each(list.fields, function(v,k) {
if (! fields.hasOwnProperty(v.type)) fields[v.type] = [];
fields[v.type].push(v);
});
return fields;
} | [
"function",
"groupFieldsByType",
"(",
"list",
")",
"{",
"var",
"fields",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"list",
".",
"fields",
",",
"function",
"(",
"v",
",",
"k",
")",
"{",
"if",
"(",
"!",
"fields",
".",
"hasOwnProperty",
"(",
"v",
"... | Groups all fields in a list by type.
@param list
@returns {{}} An object map of type/fields. | [
"Groups",
"all",
"fields",
"in",
"a",
"list",
"by",
"type",
"."
] | 9ab093272ea7b68c6fe0aba45384206571896295 | https://github.com/shlomiassaf/resty-stone/blob/9ab093272ea7b68c6fe0aba45384206571896295/lib/RestListMetadata.js#L76-L83 | train |
saggiyogesh/nodeportal | plugins/manageResource/client/js/manageResource.js | getBytesWithUnit | function getBytesWithUnit(bytes) {
if (isNaN(bytes)) {
return;
}
var units = [ ' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
var amountOf2s = Math.floor(Math.log(+bytes) / Math.log(2));
if (amountOf2s < 1) {
amountOf2s = 0;
}
... | javascript | function getBytesWithUnit(bytes) {
if (isNaN(bytes)) {
return;
}
var units = [ ' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
var amountOf2s = Math.floor(Math.log(+bytes) / Math.log(2));
if (amountOf2s < 1) {
amountOf2s = 0;
}
... | [
"function",
"getBytesWithUnit",
"(",
"bytes",
")",
"{",
"if",
"(",
"isNaN",
"(",
"bytes",
")",
")",
"{",
"return",
";",
"}",
"var",
"units",
"=",
"[",
"' bytes'",
",",
"' KB'",
",",
"' MB'",
",",
"' GB'",
",",
"' TB'",
",",
"' PB'",
",",
"' EB'",
"... | code with the help of google | [
"code",
"with",
"the",
"help",
"of",
"google"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/manageResource/client/js/manageResource.js#L32-L49 | train |
saggiyogesh/nodeportal | plugins/manageResource/client/js/manageResource.js | renderActionButtons | function renderActionButtons() {
$('.manage-resource-container .action-button').each(function (i, action) {
action = $(action);
var type = action.parent().hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "";
var id = action.attr("id"),
dataId = action.parent('.resource-i... | javascript | function renderActionButtons() {
$('.manage-resource-container .action-button').each(function (i, action) {
action = $(action);
var type = action.parent().hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "";
var id = action.attr("id"),
dataId = action.parent('.resource-i... | [
"function",
"renderActionButtons",
"(",
")",
"{",
"$",
"(",
"'.manage-resource-container .action-button'",
")",
".",
"each",
"(",
"function",
"(",
"i",
",",
"action",
")",
"{",
"action",
"=",
"$",
"(",
"action",
")",
";",
"var",
"type",
"=",
"action",
".",... | render action button | [
"render",
"action",
"button"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/manageResource/client/js/manageResource.js#L263-L319 | train |
mdreizin/webpack-config-stream | lib/ignoreStream.js | ignoreStream | function ignoreStream(strategy) {
if (!(strategy instanceof IgnoreStrategy)) {
strategy = DefaultIgnoreStrategy.INSTANCE;
}
return through.obj(function(chunk, enc, cb) {
strategy.execute(this, chunk).then(function(isIgnored) {
if (!isIgnored) {
cb(null, chunk);
... | javascript | function ignoreStream(strategy) {
if (!(strategy instanceof IgnoreStrategy)) {
strategy = DefaultIgnoreStrategy.INSTANCE;
}
return through.obj(function(chunk, enc, cb) {
strategy.execute(this, chunk).then(function(isIgnored) {
if (!isIgnored) {
cb(null, chunk);
... | [
"function",
"ignoreStream",
"(",
"strategy",
")",
"{",
"if",
"(",
"!",
"(",
"strategy",
"instanceof",
"IgnoreStrategy",
")",
")",
"{",
"strategy",
"=",
"DefaultIgnoreStrategy",
".",
"INSTANCE",
";",
"}",
"return",
"through",
".",
"obj",
"(",
"function",
"(",... | Prevents writing of `webpack.config.js`. Can be piped.
@function
@alias ignoreStream
@param {IgnoreStrategy=} strategy
@returns {Stream} | [
"Prevents",
"writing",
"of",
"webpack",
".",
"config",
".",
"js",
".",
"Can",
"be",
"piped",
"."
] | f8424f97837a224bc07cc18a03ecf649d708e924 | https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/ignoreStream.js#L14-L28 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/core/tools.js | function( text )
{
var standard = function( text )
{
var span = new CKEDITOR.dom.element( 'span' );
span.setText( text );
return span.getHtml();
};
var fix1 = ( standard( '\n' ).toLowerCase() == '<br>' ) ?
function( text )
{
// #3874 IE and Safari encode line-break in... | javascript | function( text )
{
var standard = function( text )
{
var span = new CKEDITOR.dom.element( 'span' );
span.setText( text );
return span.getHtml();
};
var fix1 = ( standard( '\n' ).toLowerCase() == '<br>' ) ?
function( text )
{
// #3874 IE and Safari encode line-break in... | [
"function",
"(",
"text",
")",
"{",
"var",
"standard",
"=",
"function",
"(",
"text",
")",
"{",
"var",
"span",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"'span'",
")",
";",
"span",
".",
"setText",
"(",
"text",
")",
";",
"return",
"span... | Replace special HTML characters in a string with their relative HTML
entity values.
@param {String} text The string to be encoded.
@returns {String} The encode string.
@example
alert( CKEDITOR.tools.htmlEncode( 'A > B & C < D' ) ); // "A &gt; B &amp; C &lt; D" | [
"Replace",
"special",
"HTML",
"characters",
"in",
"a",
"string",
"with",
"their",
"relative",
"HTML",
"entity",
"values",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/tools.js#L296-L333 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/tools.js | function( func, milliseconds, scope, args, ownerWindow )
{
if ( !ownerWindow )
ownerWindow = window;
if ( !scope )
scope = ownerWindow;
return ownerWindow.setTimeout(
function()
{
if ( args )
func.apply( scope, [].concat( args ) ) ;
else
func.apply( scope... | javascript | function( func, milliseconds, scope, args, ownerWindow )
{
if ( !ownerWindow )
ownerWindow = window;
if ( !scope )
scope = ownerWindow;
return ownerWindow.setTimeout(
function()
{
if ( args )
func.apply( scope, [].concat( args ) ) ;
else
func.apply( scope... | [
"function",
"(",
"func",
",",
"milliseconds",
",",
"scope",
",",
"args",
",",
"ownerWindow",
")",
"{",
"if",
"(",
"!",
"ownerWindow",
")",
"ownerWindow",
"=",
"window",
";",
"if",
"(",
"!",
"scope",
")",
"scope",
"=",
"ownerWindow",
";",
"return",
"own... | Executes a function after specified delay.
@param {Function} func The function to be executed.
@param {Number} [milliseconds] The amount of time (millisecods) to wait
to fire the function execution. Defaults to zero.
@param {Object} [scope] The object to hold the function execution scope
(the "this" object). By default... | [
"Executes",
"a",
"function",
"after",
"specified",
"delay",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/tools.js#L430-L447 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/core/tools.js | function( ref )
{
var fn = functions[ ref ];
return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
} | javascript | function( ref )
{
var fn = functions[ ref ];
return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
} | [
"function",
"(",
"ref",
")",
"{",
"var",
"fn",
"=",
"functions",
"[",
"ref",
"]",
";",
"return",
"fn",
"&&",
"fn",
".",
"apply",
"(",
"window",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
... | Executes a function based on the reference created with
CKEDITOR.tools.addFunction.
@param {Number} ref The function reference created with
CKEDITOR.tools.addFunction.
@param {[Any,[Any,...]} params Any number of parameters to be passed
to the executed function.
@returns {Any} The return value of the function.
@example... | [
"Executes",
"a",
"function",
"based",
"on",
"the",
"reference",
"created",
"with",
"CKEDITOR",
".",
"tools",
".",
"addFunction",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/tools.js#L671-L675 | train | |
dailymotion/react-collider | lib/server.js | returnResponse | function returnResponse(res, Handler, data, perfInstance) {
var content = React.renderToString(React.createElement(Handler, { data: data })),
html = '<!DOCTYPE html>' + content;
options.log && log(options.log, 'perf', perfInstance());
res.end(html);
} | javascript | function returnResponse(res, Handler, data, perfInstance) {
var content = React.renderToString(React.createElement(Handler, { data: data })),
html = '<!DOCTYPE html>' + content;
options.log && log(options.log, 'perf', perfInstance());
res.end(html);
} | [
"function",
"returnResponse",
"(",
"res",
",",
"Handler",
",",
"data",
",",
"perfInstance",
")",
"{",
"var",
"content",
"=",
"React",
".",
"renderToString",
"(",
"React",
".",
"createElement",
"(",
"Handler",
",",
"{",
"data",
":",
"data",
"}",
")",
")",... | Server side rendering | [
"Server",
"side",
"rendering"
] | 00cea5d25928d4a3ff0c68b6535edbc231d2b0a1 | https://github.com/dailymotion/react-collider/blob/00cea5d25928d4a3ff0c68b6535edbc231d2b0a1/lib/server.js#L40-L45 | train |
francois2metz/node-spore | lib/client.js | function(url, callback) {
var parsedUrl = urlparse(url, true);
var method = this._normalizeSpecMethod(this.spec, {
base_url: parsedUrl.protocol +'//' + parsedUrl.hostname,
headers: {},
method: 'GET',
path: parsedUrl.pathname + parsedUrl.search
});
... | javascript | function(url, callback) {
var parsedUrl = urlparse(url, true);
var method = this._normalizeSpecMethod(this.spec, {
base_url: parsedUrl.protocol +'//' + parsedUrl.hostname,
headers: {},
method: 'GET',
path: parsedUrl.pathname + parsedUrl.search
});
... | [
"function",
"(",
"url",
",",
"callback",
")",
"{",
"var",
"parsedUrl",
"=",
"urlparse",
"(",
"url",
",",
"true",
")",
";",
"var",
"method",
"=",
"this",
".",
"_normalizeSpecMethod",
"(",
"this",
".",
"spec",
",",
"{",
"base_url",
":",
"parsedUrl",
".",... | Direct get request | [
"Direct",
"get",
"request"
] | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L38-L48 | train | |
francois2metz/node-spore | lib/client.js | function(middleware) {
this.middlewares = this.middlewares.filter(function(element) {
if (element.fun === middleware)
return false;
return true;
});
} | javascript | function(middleware) {
this.middlewares = this.middlewares.filter(function(element) {
if (element.fun === middleware)
return false;
return true;
});
} | [
"function",
"(",
"middleware",
")",
"{",
"this",
".",
"middlewares",
"=",
"this",
".",
"middlewares",
".",
"filter",
"(",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"fun",
"===",
"middleware",
")",
"return",
"false",
";",
"return",
... | Disable middleware at runtime | [
"Disable",
"middleware",
"at",
"runtime"
] | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L64-L70 | train | |
francois2metz/node-spore | lib/client.js | function(methodName, args) {
var method = this.spec.methods[methodName];
if (method.deprecated === true)
console.warn('Method '+ methodName + ' is deprecated.')
var callback = args.pop(); // callback is always at the end
var middleware = args[0];
var params = null... | javascript | function(methodName, args) {
var method = this.spec.methods[methodName];
if (method.deprecated === true)
console.warn('Method '+ methodName + ' is deprecated.')
var callback = args.pop(); // callback is always at the end
var middleware = args[0];
var params = null... | [
"function",
"(",
"methodName",
",",
"args",
")",
"{",
"var",
"method",
"=",
"this",
".",
"spec",
".",
"methods",
"[",
"methodName",
"]",
";",
"if",
"(",
"method",
".",
"deprecated",
"===",
"true",
")",
"console",
".",
"warn",
"(",
"'Method '",
"+",
"... | args is an array with some possibilities
middleware, params, payload, callback
middleware, payload, callback
middleware, params, callback
middleware, callback
params, payload, callback
payload, callback
params, callback
callback | [
"args",
"is",
"an",
"array",
"with",
"some",
"possibilities",
"middleware",
"params",
"payload",
"callback",
"middleware",
"payload",
"callback",
"middleware",
"params",
"callback",
"middleware",
"callback",
"params",
"payload",
"callback",
"payload",
"callback",
"par... | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L96-L127 | train | |
francois2metz/node-spore | lib/client.js | function(request, callback, response_middlewares) {
var that = this;
request.finalize(function(err, res) {
if (err) callback(err, null);
else that._callResponseMiddlewares(response_middlewares, res, callback);
});
} | javascript | function(request, callback, response_middlewares) {
var that = this;
request.finalize(function(err, res) {
if (err) callback(err, null);
else that._callResponseMiddlewares(response_middlewares, res, callback);
});
} | [
"function",
"(",
"request",
",",
"callback",
",",
"response_middlewares",
")",
"{",
"var",
"that",
"=",
"this",
";",
"request",
".",
"finalize",
"(",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"callback",
"(",
"err",
",",
"n... | Make http request | [
"Make",
"http",
"request"
] | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L192-L198 | train | |
francois2metz/node-spore | lib/client.js | function(methodDef, callback, params, payload) {
// check required params
for (var index in methodDef.required_params) {
var requiredParamName = methodDef.required_params[index];
if (!params.hasOwnProperty(requiredParamName)) {
callback(requiredParamName +' param ... | javascript | function(methodDef, callback, params, payload) {
// check required params
for (var index in methodDef.required_params) {
var requiredParamName = methodDef.required_params[index];
if (!params.hasOwnProperty(requiredParamName)) {
callback(requiredParamName +' param ... | [
"function",
"(",
"methodDef",
",",
"callback",
",",
"params",
",",
"payload",
")",
"{",
"// check required params",
"for",
"(",
"var",
"index",
"in",
"methodDef",
".",
"required_params",
")",
"{",
"var",
"requiredParamName",
"=",
"methodDef",
".",
"required_para... | Check params and payload | [
"Check",
"params",
"and",
"payload"
] | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L235-L260 | train | |
nijikokun/http-responses | index.js | GenericRestError | function GenericRestError (type, status) {
return function Handler (code, message, header) {
return new RestError(type, status, code, message, header)
}
} | javascript | function GenericRestError (type, status) {
return function Handler (code, message, header) {
return new RestError(type, status, code, message, header)
}
} | [
"function",
"GenericRestError",
"(",
"type",
",",
"status",
")",
"{",
"return",
"function",
"Handler",
"(",
"code",
",",
"message",
",",
"header",
")",
"{",
"return",
"new",
"RestError",
"(",
"type",
",",
"status",
",",
"code",
",",
"message",
",",
"head... | Setup pre-defined status code for RestError method
@param {Number} status HTTP Status Code
@private | [
"Setup",
"pre",
"-",
"defined",
"status",
"code",
"for",
"RestError",
"method"
] | f33f01c69ba720773adaba6d1b596f2b973f5189 | https://github.com/nijikokun/http-responses/blob/f33f01c69ba720773adaba6d1b596f2b973f5189/index.js#L174-L178 | train |
jeffsu/js2 | src/core/js2-lexer.js | function(stuff) {
var len = this.str.length;
if (typeof stuff == 'number') {
this.str = this.str.substr(stuff);
} else if (typeof stuff == 'string') {
this.str = this.str.substr(stuff.length);
} else if (stuff instanceof RegExp) {
var m = this.str.match(stuff);
if... | javascript | function(stuff) {
var len = this.str.length;
if (typeof stuff == 'number') {
this.str = this.str.substr(stuff);
} else if (typeof stuff == 'string') {
this.str = this.str.substr(stuff.length);
} else if (stuff instanceof RegExp) {
var m = this.str.match(stuff);
if... | [
"function",
"(",
"stuff",
")",
"{",
"var",
"len",
"=",
"this",
".",
"str",
".",
"length",
";",
"if",
"(",
"typeof",
"stuff",
"==",
"'number'",
")",
"{",
"this",
".",
"str",
"=",
"this",
".",
"str",
".",
"substr",
"(",
"stuff",
")",
";",
"}",
"e... | stuff can be string, integer, or regex will return true if it actually made the string smaller | [
"stuff",
"can",
"be",
"string",
"integer",
"or",
"regex",
"will",
"return",
"true",
"if",
"it",
"actually",
"made",
"the",
"string",
"smaller"
] | 5651e6d8ceaea1239aa162462ab9eab80c640707 | https://github.com/jeffsu/js2/blob/5651e6d8ceaea1239aa162462ab9eab80c640707/src/core/js2-lexer.js#L350-L363 | train | |
wombleton/angular-gettext-extract-loader | index.js | mergeReferences | function mergeReferences (oldRefs, newRefs) {
const _newRefs = _(newRefs);
return _(oldRefs)
.reject(function (oldRef) {
return _newRefs.any(function (newRef) {
return matches(oldRef, newRef);
});
})
.concat(newRefs)
.uniq()
.sort(... | javascript | function mergeReferences (oldRefs, newRefs) {
const _newRefs = _(newRefs);
return _(oldRefs)
.reject(function (oldRef) {
return _newRefs.any(function (newRef) {
return matches(oldRef, newRef);
});
})
.concat(newRefs)
.uniq()
.sort(... | [
"function",
"mergeReferences",
"(",
"oldRefs",
",",
"newRefs",
")",
"{",
"const",
"_newRefs",
"=",
"_",
"(",
"newRefs",
")",
";",
"return",
"_",
"(",
"oldRefs",
")",
".",
"reject",
"(",
"function",
"(",
"oldRef",
")",
"{",
"return",
"_newRefs",
".",
"a... | Merge new references with old references; ignore old references from the same file. | [
"Merge",
"new",
"references",
"with",
"old",
"references",
";",
"ignore",
"old",
"references",
"from",
"the",
"same",
"file",
"."
] | 8b977383b4f34a74e967d99267b70c83aa53cffd | https://github.com/wombleton/angular-gettext-extract-loader/blob/8b977383b4f34a74e967d99267b70c83aa53cffd/index.js#L15-L28 | train |
bevacqua/measly | sample/sample.js | preventAll | function preventAll () {
function shield (req) {
req.prevent();
}
measly.on('create', shield);
text(preventButton, 'Shield On..');
preventButton.classList.add('cm-prevent-on');
setTimeout(function () {
measly.off('create', shield);
text(preventButton, 'Prevent for 5s');
... | javascript | function preventAll () {
function shield (req) {
req.prevent();
}
measly.on('create', shield);
text(preventButton, 'Shield On..');
preventButton.classList.add('cm-prevent-on');
setTimeout(function () {
measly.off('create', shield);
text(preventButton, 'Prevent for 5s');
... | [
"function",
"preventAll",
"(",
")",
"{",
"function",
"shield",
"(",
"req",
")",
"{",
"req",
".",
"prevent",
"(",
")",
";",
"}",
"measly",
".",
"on",
"(",
"'create'",
",",
"shield",
")",
";",
"text",
"(",
"preventButton",
",",
"'Shield On..'",
")",
";... | prevents all requests fired by measly for 5 seconds. | [
"prevents",
"all",
"requests",
"fired",
"by",
"measly",
"for",
"5",
"seconds",
"."
] | bc94d8207c61f7140da8a2a4879e3ca15e1a4b38 | https://github.com/bevacqua/measly/blob/bc94d8207c61f7140da8a2a4879e3ca15e1a4b38/sample/sample.js#L117-L130 | train |
jeffsu/js2 | flavors/ringo-full.js | mainFunction | function mainFunction (arg) {
if (typeof arg == 'string') {
return JS2.Parser.parse(arg).toString();
} else if (arg instanceof Array) {
return new JS2.Array(arg);
} else {
return new JS2.Array();
}
} | javascript | function mainFunction (arg) {
if (typeof arg == 'string') {
return JS2.Parser.parse(arg).toString();
} else if (arg instanceof Array) {
return new JS2.Array(arg);
} else {
return new JS2.Array();
}
} | [
"function",
"mainFunction",
"(",
"arg",
")",
"{",
"if",
"(",
"typeof",
"arg",
"==",
"'string'",
")",
"{",
"return",
"JS2",
".",
"Parser",
".",
"parse",
"(",
"arg",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"arg",
"instanceof",
"A... | temporarily set root to JS2 global var for this scope | [
"temporarily",
"set",
"root",
"to",
"JS2",
"global",
"var",
"for",
"this",
"scope"
] | 5651e6d8ceaea1239aa162462ab9eab80c640707 | https://github.com/jeffsu/js2/blob/5651e6d8ceaea1239aa162462ab9eab80c640707/flavors/ringo-full.js#L4-L12 | train |
UsabilityDynamics/node-wordpress-client | examples/get-single.js | havePosts | function havePosts( error, post ) {
this.debug( 'haveSingle' );
console.log( require( 'util' ).inspect( post, { showHidden: false, colors: true, depth: 4 } ) );
} | javascript | function havePosts( error, post ) {
this.debug( 'haveSingle' );
console.log( require( 'util' ).inspect( post, { showHidden: false, colors: true, depth: 4 } ) );
} | [
"function",
"havePosts",
"(",
"error",
",",
"post",
")",
"{",
"this",
".",
"debug",
"(",
"'haveSingle'",
")",
";",
"console",
".",
"log",
"(",
"require",
"(",
"'util'",
")",
".",
"inspect",
"(",
"post",
",",
"{",
"showHidden",
":",
"false",
",",
"col... | Post Query Callback
@param error
@param post | [
"Post",
"Query",
"Callback"
] | 2b47a7c5cadd3d8f2cfd255f997f36af14a5d843 | https://github.com/UsabilityDynamics/node-wordpress-client/blob/2b47a7c5cadd3d8f2cfd255f997f36af14a5d843/examples/get-single.js#L14-L17 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/wysiwygarea/plugin.js | function( data )
{
if ( iframe )
iframe.remove();
var src =
'document.open();' +
// The document domain must be set any time we
// call document.open().
( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
'document.close(... | javascript | function( data )
{
if ( iframe )
iframe.remove();
var src =
'document.open();' +
// The document domain must be set any time we
// call document.open().
( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
'document.close(... | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"iframe",
")",
"iframe",
".",
"remove",
"(",
")",
";",
"var",
"src",
"=",
"'document.open();'",
"+",
"// The document domain must be set any time we\r",
"// call document.open().\r",
"(",
"isCustomDomain",
"?",
"(",
"'... | Creates the iframe that holds the editable document. | [
"Creates",
"the",
"iframe",
"that",
"holds",
"the",
"editable",
"document",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/wysiwygarea/plugin.js#L494-L549 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/wysiwygarea/plugin.js | blinkCursor | function blinkCursor( retry )
{
if ( editor.readOnly )
return;
CKEDITOR.tools.tryThese(
function()
{
editor.document.$.designMode = 'on';
setTimeout( function()
{
editor.document.$.designMode = 'off';
if ( CKEDITOR.currentInstance == editor )
... | javascript | function blinkCursor( retry )
{
if ( editor.readOnly )
return;
CKEDITOR.tools.tryThese(
function()
{
editor.document.$.designMode = 'on';
setTimeout( function()
{
editor.document.$.designMode = 'off';
if ( CKEDITOR.currentInstance == editor )
... | [
"function",
"blinkCursor",
"(",
"retry",
")",
"{",
"if",
"(",
"editor",
".",
"readOnly",
")",
"return",
";",
"CKEDITOR",
".",
"tools",
".",
"tryThese",
"(",
"function",
"(",
")",
"{",
"editor",
".",
"document",
".",
"$",
".",
"designMode",
"=",
"'on'",... | Switch on design mode for a short while and close it after then. | [
"Switch",
"on",
"design",
"mode",
"for",
"a",
"short",
"while",
"and",
"close",
"it",
"after",
"then",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/wysiwygarea/plugin.js#L1171-L1199 | train |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/xml/plugin.js | function( xpath, contextNode )
{
var baseXml = this.baseXml;
if ( contextNode || ( contextNode = baseXml ) )
{
if ( CKEDITOR.env.ie || contextNode.selectSingleNode ) // IE
return contextNode.selectSingleNode( xpath );
else if ( baseXml.evaluate ) // Others
{
var result ... | javascript | function( xpath, contextNode )
{
var baseXml = this.baseXml;
if ( contextNode || ( contextNode = baseXml ) )
{
if ( CKEDITOR.env.ie || contextNode.selectSingleNode ) // IE
return contextNode.selectSingleNode( xpath );
else if ( baseXml.evaluate ) // Others
{
var result ... | [
"function",
"(",
"xpath",
",",
"contextNode",
")",
"{",
"var",
"baseXml",
"=",
"this",
".",
"baseXml",
";",
"if",
"(",
"contextNode",
"||",
"(",
"contextNode",
"=",
"baseXml",
")",
")",
"{",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
"||",
"contex... | Get a single node from the XML document, based on a XPath query.
@param {String} xpath The XPath query to execute.
@param {Object} [contextNode] The XML DOM node to be used as the context
for the XPath query. The document root is used by default.
@returns {Object} A XML node element or null if the query has no results.... | [
"Get",
"a",
"single",
"node",
"from",
"the",
"XML",
"document",
"based",
"on",
"a",
"XPath",
"query",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/xml/plugin.js#L76-L92 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/xml/plugin.js | function( xpath, contextNode )
{
var baseXml = this.baseXml,
nodes = [];
if ( contextNode || ( contextNode = baseXml ) )
{
if ( CKEDITOR.env.ie || contextNode.selectNodes ) // IE
return contextNode.selectNodes( xpath );
else if ( baseXml.evaluate ) // Others
{
var... | javascript | function( xpath, contextNode )
{
var baseXml = this.baseXml,
nodes = [];
if ( contextNode || ( contextNode = baseXml ) )
{
if ( CKEDITOR.env.ie || contextNode.selectNodes ) // IE
return contextNode.selectNodes( xpath );
else if ( baseXml.evaluate ) // Others
{
var... | [
"function",
"(",
"xpath",
",",
"contextNode",
")",
"{",
"var",
"baseXml",
"=",
"this",
".",
"baseXml",
",",
"nodes",
"=",
"[",
"]",
";",
"if",
"(",
"contextNode",
"||",
"(",
"contextNode",
"=",
"baseXml",
")",
")",
"{",
"if",
"(",
"CKEDITOR",
".",
... | Gets a list node from the XML document, based on a XPath query.
@param {String} xpath The XPath query to execute.
@param {Object} [contextNode] The XML DOM node to be used as the context
for the XPath query. The document root is used by default.
@returns {ArrayLike} An array containing all matched nodes. The array will... | [
"Gets",
"a",
"list",
"node",
"from",
"the",
"XML",
"document",
"based",
"on",
"a",
"XPath",
"query",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/xml/plugin.js#L110-L133 | train | |
saggiyogesh/nodeportal | public/ckeditor/_source/plugins/xml/plugin.js | function( xpath, contextNode )
{
var node = this.selectSingleNode( xpath, contextNode ),
xml = [];
if ( node )
{
node = node.firstChild;
while ( node )
{
if ( node.xml ) // IE
xml.push( node.xml );
else if ( window.XMLSerializer ) // Others
xml.push( ( new... | javascript | function( xpath, contextNode )
{
var node = this.selectSingleNode( xpath, contextNode ),
xml = [];
if ( node )
{
node = node.firstChild;
while ( node )
{
if ( node.xml ) // IE
xml.push( node.xml );
else if ( window.XMLSerializer ) // Others
xml.push( ( new... | [
"function",
"(",
"xpath",
",",
"contextNode",
")",
"{",
"var",
"node",
"=",
"this",
".",
"selectSingleNode",
"(",
"xpath",
",",
"contextNode",
")",
",",
"xml",
"=",
"[",
"]",
";",
"if",
"(",
"node",
")",
"{",
"node",
"=",
"node",
".",
"firstChild",
... | Gets the string representation of hte inner contents of a XML node,
based on a XPath query.
@param {String} xpath The XPath query to execute.
@param {Object} [contextNode] The XML DOM node to be used as the context
for the XPath query. The document root is used by default.
@returns {String} The textual representation o... | [
"Gets",
"the",
"string",
"representation",
"of",
"hte",
"inner",
"contents",
"of",
"a",
"XML",
"node",
"based",
"on",
"a",
"XPath",
"query",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/xml/plugin.js#L149-L168 | train | |
nodejitsu/npm-search-pagelet | httpsgc.js | request | function request(url, using, fn, disk) {
if ('function' === typeof using) {
disk = fn;
fn = using;
using = null;
}
if (!using) {
if (curl) using = 'curl';
else if (wget) using = 'wget';
else using = 'node';
}
debug('requesting '+ url +' using '+ using);
request[using + ( disk ? 'd'... | javascript | function request(url, using, fn, disk) {
if ('function' === typeof using) {
disk = fn;
fn = using;
using = null;
}
if (!using) {
if (curl) using = 'curl';
else if (wget) using = 'wget';
else using = 'node';
}
debug('requesting '+ url +' using '+ using);
request[using + ( disk ? 'd'... | [
"function",
"request",
"(",
"url",
",",
"using",
",",
"fn",
",",
"disk",
")",
"{",
"if",
"(",
"'function'",
"===",
"typeof",
"using",
")",
"{",
"disk",
"=",
"fn",
";",
"fn",
"=",
"using",
";",
"using",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"us... | Request a HTTP resource and return it's contents.
@param {String} url The HTTPS URL that we need to fetch.
@param {String} using Optionally force which fetch engine we should use.
@param {Function} fn Completion callback.
@param {Boolean} disk Store file to disk instead of streaming spawns.
@api private | [
"Request",
"a",
"HTTP",
"resource",
"and",
"return",
"it",
"s",
"contents",
"."
] | a6086c627b69c36c0cf638dc994c25f3d9d5df72 | https://github.com/nodejitsu/npm-search-pagelet/blob/a6086c627b69c36c0cf638dc994c25f3d9d5df72/httpsgc.js#L40-L55 | train |
lazd/PseudoClass | source/Class.js | extendThis | function extendThis() {
var i, ni, objects, object, prop;
objects = arguments;
for (i = 0, ni = objects.length; i < ni; i++) {
object = objects[i];
for (prop in object) {
this[prop] = object[prop];
}
}
return this;
} | javascript | function extendThis() {
var i, ni, objects, object, prop;
objects = arguments;
for (i = 0, ni = objects.length; i < ni; i++) {
object = objects[i];
for (prop in object) {
this[prop] = object[prop];
}
}
return this;
} | [
"function",
"extendThis",
"(",
")",
"{",
"var",
"i",
",",
"ni",
",",
"objects",
",",
"object",
",",
"prop",
";",
"objects",
"=",
"arguments",
";",
"for",
"(",
"i",
"=",
"0",
",",
"ni",
"=",
"objects",
".",
"length",
";",
"i",
"<",
"ni",
";",
"i... | Extend the current context by the passed objects | [
"Extend",
"the",
"current",
"context",
"by",
"the",
"passed",
"objects"
] | 6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08 | https://github.com/lazd/PseudoClass/blob/6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08/source/Class.js#L40-L51 | train |
lazd/PseudoClass | source/Class.js | defineAndInheritProperties | function defineAndInheritProperties(Component, properties) {
var constructor,
descriptor,
property,
propertyDescriptors,
propertyDescriptorHash,
propertyDescriptorQueue;
// Set properties
Component.properties = properties;
// Traverse the chain of constructors and gather all property descriptor... | javascript | function defineAndInheritProperties(Component, properties) {
var constructor,
descriptor,
property,
propertyDescriptors,
propertyDescriptorHash,
propertyDescriptorQueue;
// Set properties
Component.properties = properties;
// Traverse the chain of constructors and gather all property descriptor... | [
"function",
"defineAndInheritProperties",
"(",
"Component",
",",
"properties",
")",
"{",
"var",
"constructor",
",",
"descriptor",
",",
"property",
",",
"propertyDescriptors",
",",
"propertyDescriptorHash",
",",
"propertyDescriptorQueue",
";",
"// Set properties",
"Compone... | Merge and define properties | [
"Merge",
"and",
"define",
"properties"
] | 6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08 | https://github.com/lazd/PseudoClass/blob/6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08/source/Class.js#L61-L105 | train |
lazd/PseudoClass | source/Class.js | function(name, func, superPrototype) {
return function PseudoClass_setStaticSuper() {
// Store the old super
var previousSuper = this._super;
// Use the method from the superclass' prototype
// This strategy allows monkey patching (modification of superclass prototypes)
this._super = superPrototype[na... | javascript | function(name, func, superPrototype) {
return function PseudoClass_setStaticSuper() {
// Store the old super
var previousSuper = this._super;
// Use the method from the superclass' prototype
// This strategy allows monkey patching (modification of superclass prototypes)
this._super = superPrototype[na... | [
"function",
"(",
"name",
",",
"func",
",",
"superPrototype",
")",
"{",
"return",
"function",
"PseudoClass_setStaticSuper",
"(",
")",
"{",
"// Store the old super",
"var",
"previousSuper",
"=",
"this",
".",
"_super",
";",
"// Use the method from the superclass' prototype... | Bind an overriding method such that it gets the overridden method as its first argument | [
"Bind",
"an",
"overriding",
"method",
"such",
"that",
"it",
"gets",
"the",
"overridden",
"method",
"as",
"its",
"first",
"argument"
] | 6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08 | https://github.com/lazd/PseudoClass/blob/6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08/source/Class.js#L116-L134 | train | |
lazd/PseudoClass | source/Class.js | function(properties) {
// If a class-like object is passed as properties.extend, just call extend on it
if (properties && properties.extend)
return properties.extend.extend(properties);
// Otherwise, just create a new class with the passed properties
return PseudoClass.extend(properties);
} | javascript | function(properties) {
// If a class-like object is passed as properties.extend, just call extend on it
if (properties && properties.extend)
return properties.extend.extend(properties);
// Otherwise, just create a new class with the passed properties
return PseudoClass.extend(properties);
} | [
"function",
"(",
"properties",
")",
"{",
"// If a class-like object is passed as properties.extend, just call extend on it",
"if",
"(",
"properties",
"&&",
"properties",
".",
"extend",
")",
"return",
"properties",
".",
"extend",
".",
"extend",
"(",
"properties",
")",
";... | The base Class implementation acts as extend alias, with the exception that it can take properties.extend as the Class to extend | [
"The",
"base",
"Class",
"implementation",
"acts",
"as",
"extend",
"alias",
"with",
"the",
"exception",
"that",
"it",
"can",
"take",
"properties",
".",
"extend",
"as",
"the",
"Class",
"to",
"extend"
] | 6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08 | https://github.com/lazd/PseudoClass/blob/6cb3ac83d18b8782d3943b7461cc4ee0d8f6ce08/source/Class.js#L187-L194 | train | |
EightMedia/discodip | lib/render.js | render | function render(q) {
if (!q.length) {
complete();
return;
}
const item = q.shift();
// render HTML file
fs.writeFile(`${item.file}.html`, item.html, err => {
if (err) throw err;
// if prerendering is enabled
if (typeof options.prerender === "object" && options.prerender !== null) {
... | javascript | function render(q) {
if (!q.length) {
complete();
return;
}
const item = q.shift();
// render HTML file
fs.writeFile(`${item.file}.html`, item.html, err => {
if (err) throw err;
// if prerendering is enabled
if (typeof options.prerender === "object" && options.prerender !== null) {
... | [
"function",
"render",
"(",
"q",
")",
"{",
"if",
"(",
"!",
"q",
".",
"length",
")",
"{",
"complete",
"(",
")",
";",
"return",
";",
"}",
"const",
"item",
"=",
"q",
".",
"shift",
"(",
")",
";",
"// render HTML file",
"fs",
".",
"writeFile",
"(",
"`"... | Recursive render
generates component html file
and json file after that | [
"Recursive",
"render",
"generates",
"component",
"html",
"file",
"and",
"json",
"file",
"after",
"that"
] | 9311bf6c7cb774c8663e40fed1c158dffe2690cb | https://github.com/EightMedia/discodip/blob/9311bf6c7cb774c8663e40fed1c158dffe2690cb/lib/render.js#L174-L222 | train |
EightMedia/discodip | lib/render.js | complete | function complete() {
quit();
const deleteQueue = [];
fs.readdir(paths.output, (err, files) => {
if (files) {
// lookup array for quick search inside existing component names
const componentsLookup = components.map(item => {
return slugify(item.meta.name);
});
// loop over fi... | javascript | function complete() {
quit();
const deleteQueue = [];
fs.readdir(paths.output, (err, files) => {
if (files) {
// lookup array for quick search inside existing component names
const componentsLookup = components.map(item => {
return slugify(item.meta.name);
});
// loop over fi... | [
"function",
"complete",
"(",
")",
"{",
"quit",
"(",
")",
";",
"const",
"deleteQueue",
"=",
"[",
"]",
";",
"fs",
".",
"readdir",
"(",
"paths",
".",
"output",
",",
"(",
"err",
",",
"files",
")",
"=>",
"{",
"if",
"(",
"files",
")",
"{",
"// lookup a... | Clean up unused files and shut down | [
"Clean",
"up",
"unused",
"files",
"and",
"shut",
"down"
] | 9311bf6c7cb774c8663e40fed1c158dffe2690cb | https://github.com/EightMedia/discodip/blob/9311bf6c7cb774c8663e40fed1c158dffe2690cb/lib/render.js#L228-L271 | train |
EightMedia/discodip | lib/render.js | removeFile | function removeFile(q) {
if (!q.length) {
process.send(true);
return;
}
const file = q.shift();
rimraf(path.resolve(paths.output, file), { read: false }, () => {
removeFile(q);
});
} | javascript | function removeFile(q) {
if (!q.length) {
process.send(true);
return;
}
const file = q.shift();
rimraf(path.resolve(paths.output, file), { read: false }, () => {
removeFile(q);
});
} | [
"function",
"removeFile",
"(",
"q",
")",
"{",
"if",
"(",
"!",
"q",
".",
"length",
")",
"{",
"process",
".",
"send",
"(",
"true",
")",
";",
"return",
";",
"}",
"const",
"file",
"=",
"q",
".",
"shift",
"(",
")",
";",
"rimraf",
"(",
"path",
".",
... | remove file by passing shorter queue | [
"remove",
"file",
"by",
"passing",
"shorter",
"queue"
] | 9311bf6c7cb774c8663e40fed1c158dffe2690cb | https://github.com/EightMedia/discodip/blob/9311bf6c7cb774c8663e40fed1c158dffe2690cb/lib/render.js#L257-L267 | train |
EightMedia/discodip | lib/render.js | slugify | function slugify(str) {
return str
.toString()
.toLowerCase()
.replace(/\s+/g, "-") // Replace spaces with -
.replace(/[^\w-]+/g, "") // Remove all non-word chars
.replace(/--+/g, "-") // Replace multiple - with single -
.replace(/^-+/, "") // Trim - from start of text
.replace(/-+$/, "");... | javascript | function slugify(str) {
return str
.toString()
.toLowerCase()
.replace(/\s+/g, "-") // Replace spaces with -
.replace(/[^\w-]+/g, "") // Remove all non-word chars
.replace(/--+/g, "-") // Replace multiple - with single -
.replace(/^-+/, "") // Trim - from start of text
.replace(/-+$/, "");... | [
"function",
"slugify",
"(",
"str",
")",
"{",
"return",
"str",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"/",
"\\s+",
"/",
"g",
",",
"\"-\"",
")",
"// Replace spaces with -",
".",
"replace",
"(",
"/",
"[^\\w-]+",
"/",... | Basic slugify function
Used to build the output filenames | [
"Basic",
"slugify",
"function",
"Used",
"to",
"build",
"the",
"output",
"filenames"
] | 9311bf6c7cb774c8663e40fed1c158dffe2690cb | https://github.com/EightMedia/discodip/blob/9311bf6c7cb774c8663e40fed1c158dffe2690cb/lib/render.js#L278-L287 | train |
saggiyogesh/nodeportal | lib/PageScript/index.js | PageScript | function PageScript(req) {
var codeList = [], bottomScriptList = [], cacheKey;
/**
* Add plugin load code. Called for each configured plugin on page.
* @param pluginOptions {Object} Plugin options object described in plugin properties
*/
this.addPluginLoad = function (pluginOptions) {
... | javascript | function PageScript(req) {
var codeList = [], bottomScriptList = [], cacheKey;
/**
* Add plugin load code. Called for each configured plugin on page.
* @param pluginOptions {Object} Plugin options object described in plugin properties
*/
this.addPluginLoad = function (pluginOptions) {
... | [
"function",
"PageScript",
"(",
"req",
")",
"{",
"var",
"codeList",
"=",
"[",
"]",
",",
"bottomScriptList",
"=",
"[",
"]",
",",
"cacheKey",
";",
"/**\n * Add plugin load code. Called for each configured plugin on page.\n * @param pluginOptions {Object} Plugin options obj... | Constructor to create a PageScript object for each request.
Client js code added will be rendered at last in the html.
@param req {Object} Request object
@constructor | [
"Constructor",
"to",
"create",
"a",
"PageScript",
"object",
"for",
"each",
"request",
".",
"Client",
"js",
"code",
"added",
"will",
"be",
"rendered",
"at",
"last",
"in",
"the",
"html",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/PageScript/index.js#L25-L104 | train |
saggiyogesh/nodeportal | lib/PageScript/index.js | renderHTML | function renderHTML(callback) {
async.map(codeList, function (locals, n) {
locals.req = req;
ViewHelper.render({
cache: true,
path: SCRIPT_JADE
}, locals, n)
}, function (err, buf) {
if (!err)... | javascript | function renderHTML(callback) {
async.map(codeList, function (locals, n) {
locals.req = req;
ViewHelper.render({
cache: true,
path: SCRIPT_JADE
}, locals, n)
}, function (err, buf) {
if (!err)... | [
"function",
"renderHTML",
"(",
"callback",
")",
"{",
"async",
".",
"map",
"(",
"codeList",
",",
"function",
"(",
"locals",
",",
"n",
")",
"{",
"locals",
".",
"req",
"=",
"req",
";",
"ViewHelper",
".",
"render",
"(",
"{",
"cache",
":",
"true",
",",
... | Function renders html.
@param callback {Function} callback function - arguments - err, html | [
"Function",
"renders",
"html",
"."
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/PageScript/index.js#L76-L92 | train |
boneskull/angular-autoselect | demo/demo.js | run | function run($templateCache) {
angular.forEach(examples, function (example) {
$templateCache.put(example.id + '-template', example.html);
$templateCache.put(example.id + '-description', example.description);
});
} | javascript | function run($templateCache) {
angular.forEach(examples, function (example) {
$templateCache.put(example.id + '-template', example.html);
$templateCache.put(example.id + '-description', example.description);
});
} | [
"function",
"run",
"(",
"$templateCache",
")",
"{",
"angular",
".",
"forEach",
"(",
"examples",
",",
"function",
"(",
"example",
")",
"{",
"$templateCache",
".",
"put",
"(",
"example",
".",
"id",
"+",
"'-template'",
",",
"example",
".",
"html",
")",
";",... | Puts the templates into the template cache | [
"Puts",
"the",
"templates",
"into",
"the",
"template",
"cache"
] | ebd8682012ae7d056470410ebecd3269babddd3a | https://github.com/boneskull/angular-autoselect/blob/ebd8682012ae7d056470410ebecd3269babddd3a/demo/demo.js#L44-L49 | train |
boneskull/angular-autoselect | demo/demo.js | ExampleCtrl | function ExampleCtrl($scope, $timeout) {
var pomo_nonsense = 'The fallacy of disciplinary boundaries thematizes the figuralization of civil society.',
regex = /(of\s.+\sboundaries|eht)/;
$scope.reset = function reset() {
delete $scope.data.pomo_nonsense;
$timeout(function () {
$scope.... | javascript | function ExampleCtrl($scope, $timeout) {
var pomo_nonsense = 'The fallacy of disciplinary boundaries thematizes the figuralization of civil society.',
regex = /(of\s.+\sboundaries|eht)/;
$scope.reset = function reset() {
delete $scope.data.pomo_nonsense;
$timeout(function () {
$scope.... | [
"function",
"ExampleCtrl",
"(",
"$scope",
",",
"$timeout",
")",
"{",
"var",
"pomo_nonsense",
"=",
"'The fallacy of disciplinary boundaries thematizes the figuralization of civil society.'",
",",
"regex",
"=",
"/",
"(of\\s.+\\sboundaries|eht)",
"/",
";",
"$scope",
".",
"rese... | Controls a singular example | [
"Controls",
"a",
"singular",
"example"
] | ebd8682012ae7d056470410ebecd3269babddd3a | https://github.com/boneskull/angular-autoselect/blob/ebd8682012ae7d056470410ebecd3269babddd3a/demo/demo.js#L55-L76 | train |
boneskull/angular-autoselect | demo/demo.js | MainCtrl | function MainCtrl($scope, $location) {
$scope.select = function select(id) {
$scope.selected = $scope.selected === id ? null : id;
$location.path('/' + id);
};
$scope.examples = examples;
$scope.select($location.path().substring(1) || examples[0].id);
} | javascript | function MainCtrl($scope, $location) {
$scope.select = function select(id) {
$scope.selected = $scope.selected === id ? null : id;
$location.path('/' + id);
};
$scope.examples = examples;
$scope.select($location.path().substring(1) || examples[0].id);
} | [
"function",
"MainCtrl",
"(",
"$scope",
",",
"$location",
")",
"{",
"$scope",
".",
"select",
"=",
"function",
"select",
"(",
"id",
")",
"{",
"$scope",
".",
"selected",
"=",
"$scope",
".",
"selected",
"===",
"id",
"?",
"null",
":",
"id",
";",
"$location"... | Controls the example navigation | [
"Controls",
"the",
"example",
"navigation"
] | ebd8682012ae7d056470410ebecd3269babddd3a | https://github.com/boneskull/angular-autoselect/blob/ebd8682012ae7d056470410ebecd3269babddd3a/demo/demo.js#L81-L91 | train |
boneskull/angular-autoselect | demo/demo.js | code | function code($window) {
return {
restrict: 'E',
require: '?ngModel',
/**
*
* @param {$rootScope.Scope} scope Element Scope
* @param {angular.element} element AngularJS element
* @param {$compile.directive.Attributes} attrs AngularJS Attributes object
* @param {N... | javascript | function code($window) {
return {
restrict: 'E',
require: '?ngModel',
/**
*
* @param {$rootScope.Scope} scope Element Scope
* @param {angular.element} element AngularJS element
* @param {$compile.directive.Attributes} attrs AngularJS Attributes object
* @param {N... | [
"function",
"code",
"(",
"$window",
")",
"{",
"return",
"{",
"restrict",
":",
"'E'",
",",
"require",
":",
"'?ngModel'",
",",
"/**\n *\n * @param {$rootScope.Scope} scope Element Scope\n * @param {angular.element} element AngularJS element\n * @param {$compile.... | Renders source code with highlight.js
@example
$scope.foo = "var bar = 'baz';";
// <source ng-model="foo" lang="js"></source> | [
"Renders",
"source",
"code",
"with",
"highlight",
".",
"js"
] | ebd8682012ae7d056470410ebecd3269babddd3a | https://github.com/boneskull/angular-autoselect/blob/ebd8682012ae7d056470410ebecd3269babddd3a/demo/demo.js#L100-L127 | train |
levilindsey/physx | src/collisions/src/collision-utils.js | detectIntersection | function detectIntersection(a, b) {
if (a instanceof Sphere) {
if (b instanceof Sphere) {
return sphereCollisionDetection.sphereVsSphere(a, b);
} else if (b instanceof Aabb) {
return sphereCollisionDetection.sphereVsAabb(a, b);
} else if (b instanceof Capsule) {
return sphereCollisionDet... | javascript | function detectIntersection(a, b) {
if (a instanceof Sphere) {
if (b instanceof Sphere) {
return sphereCollisionDetection.sphereVsSphere(a, b);
} else if (b instanceof Aabb) {
return sphereCollisionDetection.sphereVsAabb(a, b);
} else if (b instanceof Capsule) {
return sphereCollisionDet... | [
"function",
"detectIntersection",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"a",
"instanceof",
"Sphere",
")",
"{",
"if",
"(",
"b",
"instanceof",
"Sphere",
")",
"{",
"return",
"sphereCollisionDetection",
".",
"sphereVsSphere",
"(",
"a",
",",
"b",
")",
";",... | This module defines a collection of static utility functions for detecting and responding to
collisions.
@param {Collidable} a
@param {Collidable} b
@returns {boolean} | [
"This",
"module",
"defines",
"a",
"collection",
"of",
"static",
"utility",
"functions",
"for",
"detecting",
"and",
"responding",
"to",
"collisions",
"."
] | 62df9f6968082ed34aa784a23f3db6c8feca6f3a | https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/src/collision-utils.js#L32-L94 | train |
psastras/swagger2aglio | index.js | convert | function convert(program, callback) {
// define no-op callback
if (!callback) {
callback = function (err, blueprint) { }
}
// Read in the file
refparser.parse(program.input, function (err, schema) {
if (err) isMain ? halt(err) : callback(err);
// Read in aglio options
var options = {
t... | javascript | function convert(program, callback) {
// define no-op callback
if (!callback) {
callback = function (err, blueprint) { }
}
// Read in the file
refparser.parse(program.input, function (err, schema) {
if (err) isMain ? halt(err) : callback(err);
// Read in aglio options
var options = {
t... | [
"function",
"convert",
"(",
"program",
",",
"callback",
")",
"{",
"// define no-op callback",
"if",
"(",
"!",
"callback",
")",
"{",
"callback",
"=",
"function",
"(",
"err",
",",
"blueprint",
")",
"{",
"}",
"}",
"// Read in the file",
"refparser",
".",
"parse... | End program
Helper functions | [
"End",
"program",
"Helper",
"functions"
] | 42869876ecd28526a68814c07a93ccf188127f06 | https://github.com/psastras/swagger2aglio/blob/42869876ecd28526a68814c07a93ccf188127f06/index.js#L44-L117 | train |
psastras/swagger2aglio | index.js | check_input | function check_input(input, message) {
if (!input) {
error('\n Error: ' + message);
program.outputHelp(colors.red);
process.exit(1);
}
} | javascript | function check_input(input, message) {
if (!input) {
error('\n Error: ' + message);
program.outputHelp(colors.red);
process.exit(1);
}
} | [
"function",
"check_input",
"(",
"input",
",",
"message",
")",
"{",
"if",
"(",
"!",
"input",
")",
"{",
"error",
"(",
"'\\n Error: '",
"+",
"message",
")",
";",
"program",
".",
"outputHelp",
"(",
"colors",
".",
"red",
")",
";",
"process",
".",
"exit",
... | Checks that the given input is defined. If it is defined, this is a no-op. Else
this prints the error message and halts the program with exit code 1.
@param {input} input - The input to check
@param {message} txt - The text to display if the check fails | [
"Checks",
"that",
"the",
"given",
"input",
"is",
"defined",
".",
"If",
"it",
"is",
"defined",
"this",
"is",
"a",
"no",
"-",
"op",
".",
"Else",
"this",
"prints",
"the",
"error",
"message",
"and",
"halts",
"the",
"program",
"with",
"exit",
"code",
"1",
... | 42869876ecd28526a68814c07a93ccf188127f06 | https://github.com/psastras/swagger2aglio/blob/42869876ecd28526a68814c07a93ccf188127f06/index.js#L125-L131 | train |
slideme/rorschach | lib/builders/create.js | adjustPath | function adjustPath(builder, path) {
if (builder.protection) {
var pathAndNode = utils.pathAndNode(path);
var nodeName = getProtectedPrefix(builder.protectedId) + pathAndNode.node;
path = utils.join(pathAndNode.path, nodeName);
}
return path;
} | javascript | function adjustPath(builder, path) {
if (builder.protection) {
var pathAndNode = utils.pathAndNode(path);
var nodeName = getProtectedPrefix(builder.protectedId) + pathAndNode.node;
path = utils.join(pathAndNode.path, nodeName);
}
return path;
} | [
"function",
"adjustPath",
"(",
"builder",
",",
"path",
")",
"{",
"if",
"(",
"builder",
".",
"protection",
")",
"{",
"var",
"pathAndNode",
"=",
"utils",
".",
"pathAndNode",
"(",
"path",
")",
";",
"var",
"nodeName",
"=",
"getProtectedPrefix",
"(",
"builder",... | Get final path
@param {CreateBuilder} builder
@param {String} path | [
"Get",
"final",
"path"
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/builders/create.js#L98-L105 | train |
slideme/rorschach | lib/builders/create.js | findNode | function findNode(children, path, protectedId) {
var prefix = getProtectedPrefix(protectedId);
var i = 0;
var node;
while ((node = children[i++])) {
if (node.indexOf(prefix) === 0) {
return utils.join(path, node);
}
}
return null;
} | javascript | function findNode(children, path, protectedId) {
var prefix = getProtectedPrefix(protectedId);
var i = 0;
var node;
while ((node = children[i++])) {
if (node.indexOf(prefix) === 0) {
return utils.join(path, node);
}
}
return null;
} | [
"function",
"findNode",
"(",
"children",
",",
"path",
",",
"protectedId",
")",
"{",
"var",
"prefix",
"=",
"getProtectedPrefix",
"(",
"protectedId",
")",
";",
"var",
"i",
"=",
"0",
";",
"var",
"node",
";",
"while",
"(",
"(",
"node",
"=",
"children",
"["... | Find znode among children list with given prefix.
@param {Array.<String>} children
@param {String} path
@param {String} protectedId
@returns {String|null} | [
"Find",
"znode",
"among",
"children",
"list",
"with",
"given",
"prefix",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/builders/create.js#L173-L183 | train |
slideme/rorschach | lib/builders/create.js | findProtectedNode | function findProtectedNode(builder, path, callback) {
var zk = builder.client.zk;
var pathAndNode = utils.pathAndNode(path);
zk.getChildren(pathAndNode.path, afterCheck);
function afterCheck(err, children) {
if (err && err.getCode() === Exception.NO_NODE) {
callback();
}
else if (err) {
... | javascript | function findProtectedNode(builder, path, callback) {
var zk = builder.client.zk;
var pathAndNode = utils.pathAndNode(path);
zk.getChildren(pathAndNode.path, afterCheck);
function afterCheck(err, children) {
if (err && err.getCode() === Exception.NO_NODE) {
callback();
}
else if (err) {
... | [
"function",
"findProtectedNode",
"(",
"builder",
",",
"path",
",",
"callback",
")",
"{",
"var",
"zk",
"=",
"builder",
".",
"client",
".",
"zk",
";",
"var",
"pathAndNode",
"=",
"utils",
".",
"pathAndNode",
"(",
"path",
")",
";",
"zk",
".",
"getChildren",
... | Try to find protected node with same `protectedId`.
@param {CreateBuilder} builder Builder instance
@param {String} path Desired path
@param {Function} callback Callback function: <code>(err, nodePath)</code> | [
"Try",
"to",
"find",
"protected",
"node",
"with",
"same",
"protectedId",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/builders/create.js#L195-L215 | train |
slideme/rorschach | lib/builders/create.js | performCreate | function performCreate(builder, path, data, callback) {
var client = builder.client;
var zk = client.zk;
var firstTime = true;
client.retryLoop(exec, callback);
function exec(cb) {
if (firstTime && builder.protection) {
findProtectedNode(builder, path, createIfNotExist);
}
else {
cre... | javascript | function performCreate(builder, path, data, callback) {
var client = builder.client;
var zk = client.zk;
var firstTime = true;
client.retryLoop(exec, callback);
function exec(cb) {
if (firstTime && builder.protection) {
findProtectedNode(builder, path, createIfNotExist);
}
else {
cre... | [
"function",
"performCreate",
"(",
"builder",
",",
"path",
",",
"data",
",",
"callback",
")",
"{",
"var",
"client",
"=",
"builder",
".",
"client",
";",
"var",
"zk",
"=",
"client",
".",
"zk",
";",
"var",
"firstTime",
"=",
"true",
";",
"client",
".",
"r... | Create node and it's parents if needed.
@param {CreateBuilder} builder
@param {String} path Node path
@param {Buffer} data Node data
@param {Function} callback Callback function: <code>(err)</code> | [
"Create",
"node",
"and",
"it",
"s",
"parents",
"if",
"needed",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/builders/create.js#L290-L332 | train |
fvsch/gulp-task-maker | example/tasks/mincss/index.js | mincss | function mincss(config, tools) {
return tools.simpleStream(config, [
config.autoprefixer && autoprefixer(config.autoprefixer),
config.concat && concat(config.concat),
config.minify && csso(config.csso)
])
} | javascript | function mincss(config, tools) {
return tools.simpleStream(config, [
config.autoprefixer && autoprefixer(config.autoprefixer),
config.concat && concat(config.concat),
config.minify && csso(config.csso)
])
} | [
"function",
"mincss",
"(",
"config",
",",
"tools",
")",
"{",
"return",
"tools",
".",
"simpleStream",
"(",
"config",
",",
"[",
"config",
".",
"autoprefixer",
"&&",
"autoprefixer",
"(",
"config",
".",
"autoprefixer",
")",
",",
"config",
".",
"concat",
"&&",
... | Make a CSS build, optionally concatenated and minified
@param {object} config - task configuration
@param {object} tools - gtm utility functions
@return {object} | [
"Make",
"a",
"CSS",
"build",
"optionally",
"concatenated",
"and",
"minified"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/example/tasks/mincss/index.js#L11-L17 | train |
saggiyogesh/nodeportal | lib/Renderer/PageRenderer.js | PageRenderer | function PageRenderer(req, res) {
var page = req.attrs.page;
Object.defineProperties(this, {
req: {
value: req
},
res: {
value: res
},
page: {
value: _.clone(page)
},
themeDBAction: {
value: DBActions.getInst... | javascript | function PageRenderer(req, res) {
var page = req.attrs.page;
Object.defineProperties(this, {
req: {
value: req
},
res: {
value: res
},
page: {
value: _.clone(page)
},
themeDBAction: {
value: DBActions.getInst... | [
"function",
"PageRenderer",
"(",
"req",
",",
"res",
")",
"{",
"var",
"page",
"=",
"req",
".",
"attrs",
".",
"page",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"req",
":",
"{",
"value",
":",
"req",
"}",
",",
"res",
":",
"{",
"v... | Constructor to create PageRenderer to render page for current request
@param req
@param res
@constructor | [
"Constructor",
"to",
"create",
"PageRenderer",
"to",
"render",
"page",
"for",
"current",
"request"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Renderer/PageRenderer.js#L35-L69 | train |
Ajedi32/metalsmith-matters | lib/index.js | extractFrontmatter | function extractFrontmatter(file, filePath, options, grayMatterOptions){
if (utf8(file.contents)) {
var parsed;
try {
parsed = matter(file.contents.toString(), grayMatterOptions);
} catch (e) {
var errMsg = 'Invalid frontmatter in file';
if (filePath !== undefined) errMsg += ": " + file... | javascript | function extractFrontmatter(file, filePath, options, grayMatterOptions){
if (utf8(file.contents)) {
var parsed;
try {
parsed = matter(file.contents.toString(), grayMatterOptions);
} catch (e) {
var errMsg = 'Invalid frontmatter in file';
if (filePath !== undefined) errMsg += ": " + file... | [
"function",
"extractFrontmatter",
"(",
"file",
",",
"filePath",
",",
"options",
",",
"grayMatterOptions",
")",
"{",
"if",
"(",
"utf8",
"(",
"file",
".",
"contents",
")",
")",
"{",
"var",
"parsed",
";",
"try",
"{",
"parsed",
"=",
"matter",
"(",
"file",
... | Assign metadata in `file` based on the YAML frontmatter in `file.contents`.
@param {Object} file The Metalsmith file object to extract frontmatter from
@param {string} filePath The path to the file represented by `file`
@param {Object} options Options for the extraction routine
@param {Object} grayMatterOptions Option... | [
"Assign",
"metadata",
"in",
"file",
"based",
"on",
"the",
"YAML",
"frontmatter",
"in",
"file",
".",
"contents",
"."
] | 42393d7c0ebf7df35c4eccef40018075c160b31c | https://github.com/Ajedi32/metalsmith-matters/blob/42393d7c0ebf7df35c4eccef40018075c160b31c/lib/index.js#L19-L42 | train |
Ajedi32/metalsmith-matters | lib/index.js | frontmatter | function frontmatter(opts){
var options = {}, grayMatterOptions = {};
Object.keys(opts || {}).forEach(function(key){
if (key === 'namespace'){
options[key] = opts[key];
} else {
grayMatterOptions[key] = opts[key];
}
});
return each(function(file, filePath){
extractFrontmatter(file, ... | javascript | function frontmatter(opts){
var options = {}, grayMatterOptions = {};
Object.keys(opts || {}).forEach(function(key){
if (key === 'namespace'){
options[key] = opts[key];
} else {
grayMatterOptions[key] = opts[key];
}
});
return each(function(file, filePath){
extractFrontmatter(file, ... | [
"function",
"frontmatter",
"(",
"opts",
")",
"{",
"var",
"options",
"=",
"{",
"}",
",",
"grayMatterOptions",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"opts",
"||",
"{",
"}",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
... | Metalsmith plugin to extract metadata from frontmatter in file contents.
@param {Object} options - `Namespace` is used, the rest is passed on to `gray-matter`
@return {Function} | [
"Metalsmith",
"plugin",
"to",
"extract",
"metadata",
"from",
"frontmatter",
"in",
"file",
"contents",
"."
] | 42393d7c0ebf7df35c4eccef40018075c160b31c | https://github.com/Ajedi32/metalsmith-matters/blob/42393d7c0ebf7df35c4eccef40018075c160b31c/lib/index.js#L50-L63 | train |
saggiyogesh/nodeportal | lib/plugins.js | loadPlugin | function loadPlugin(id) {
var plugin = PLUGINS[id];
plugin.exec.load(plugin.id, {
id: plugin.id
});
} | javascript | function loadPlugin(id) {
var plugin = PLUGINS[id];
plugin.exec.load(plugin.id, {
id: plugin.id
});
} | [
"function",
"loadPlugin",
"(",
"id",
")",
"{",
"var",
"plugin",
"=",
"PLUGINS",
"[",
"id",
"]",
";",
"plugin",
".",
"exec",
".",
"load",
"(",
"plugin",
".",
"id",
",",
"{",
"id",
":",
"plugin",
".",
"id",
"}",
")",
";",
"}"
] | After adding a plugin, it also should be loaded, otherwise it'll raise an err for listenload event | [
"After",
"adding",
"a",
"plugin",
"it",
"also",
"should",
"be",
"loaded",
"otherwise",
"it",
"ll",
"raise",
"an",
"err",
"for",
"listenload",
"event"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/plugins.js#L45-L50 | train |
yuanqing/modal | modal.js | bindToClick | function bindToClick(selector, handler) {
var elems = document.querySelectorAll(selector);
var i = -1;
var len = elems.length;
while (++i < len) {
elems[i].addEventListener('click', handler);
}
} | javascript | function bindToClick(selector, handler) {
var elems = document.querySelectorAll(selector);
var i = -1;
var len = elems.length;
while (++i < len) {
elems[i].addEventListener('click', handler);
}
} | [
"function",
"bindToClick",
"(",
"selector",
",",
"handler",
")",
"{",
"var",
"elems",
"=",
"document",
".",
"querySelectorAll",
"(",
"selector",
")",
";",
"var",
"i",
"=",
"-",
"1",
";",
"var",
"len",
"=",
"elems",
".",
"length",
";",
"while",
"(",
"... | Binds the given `handler` to all elements that match the `selector`. | [
"Binds",
"the",
"given",
"handler",
"to",
"all",
"elements",
"that",
"match",
"the",
"selector",
"."
] | f9a4913a427e022d649956d11c160ceed33213d3 | https://github.com/yuanqing/modal/blob/f9a4913a427e022d649956d11c160ceed33213d3/modal.js#L26-L33 | train |
shlomiassaf/resty-stone | lib/decoration/sessionDecorator.js | sessionDecorator | function sessionDecorator() {
// save token header to be used in cookieParserDecorator middleware.
tokenHeaderName = rs.keystone.get('resty token header');
rs.keystone.session = RestySession.factory(rs.keystone);
rs.keystone.set('session', rs.keystone.session.persist);
} | javascript | function sessionDecorator() {
// save token header to be used in cookieParserDecorator middleware.
tokenHeaderName = rs.keystone.get('resty token header');
rs.keystone.session = RestySession.factory(rs.keystone);
rs.keystone.set('session', rs.keystone.session.persist);
} | [
"function",
"sessionDecorator",
"(",
")",
"{",
"// save token header to be used in cookieParserDecorator middleware.",
"tokenHeaderName",
"=",
"rs",
".",
"keystone",
".",
"get",
"(",
"'resty token header'",
")",
";",
"rs",
".",
"keystone",
".",
"session",
"=",
"RestySes... | Replaces keystone session API with a proxy to handle authentication different the cookie auth.
@param keystone | [
"Replaces",
"keystone",
"session",
"API",
"with",
"a",
"proxy",
"to",
"handle",
"authentication",
"different",
"the",
"cookie",
"auth",
"."
] | 9ab093272ea7b68c6fe0aba45384206571896295 | https://github.com/shlomiassaf/resty-stone/blob/9ab093272ea7b68c6fe0aba45384206571896295/lib/decoration/sessionDecorator.js#L14-L20 | train |
shlomiassaf/resty-stone | lib/decoration/sessionDecorator.js | cookieParserDecorator | function cookieParserDecorator(req, res, next) {
// run express.cookieParser() only when were not visiting the api.
if (req.isResty) {
// get token from headers.
var token = req.headers[tokenHeaderName] || undefined;
if (token) {
try {
// decode token, it hol... | javascript | function cookieParserDecorator(req, res, next) {
// run express.cookieParser() only when were not visiting the api.
if (req.isResty) {
// get token from headers.
var token = req.headers[tokenHeaderName] || undefined;
if (token) {
try {
// decode token, it hol... | [
"function",
"cookieParserDecorator",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// run express.cookieParser() only when were not visiting the api.",
"if",
"(",
"req",
".",
"isResty",
")",
"{",
"// get token from headers.",
"var",
"token",
"=",
"req",
".",
"header... | Replace the default cookie parser with a proxy cookie parser middleware.
The proxy is then used to decide what parser is right for the task.
If we are not in the api realm, use the default cookie parser.
In any other case, use the appropriate one.
This approach is used to create fake "cookie" data.
By faking cookie da... | [
"Replace",
"the",
"default",
"cookie",
"parser",
"with",
"a",
"proxy",
"cookie",
"parser",
"middleware",
".",
"The",
"proxy",
"is",
"then",
"used",
"to",
"decide",
"what",
"parser",
"is",
"right",
"for",
"the",
"task",
".",
"If",
"we",
"are",
"not",
"in"... | 9ab093272ea7b68c6fe0aba45384206571896295 | https://github.com/shlomiassaf/resty-stone/blob/9ab093272ea7b68c6fe0aba45384206571896295/lib/decoration/sessionDecorator.js#L34-L71 | train |
ForbesLindesay/stop | lib/status-codes.js | statusCodes | function statusCodes(allowed, ignored, options) {
var stream = new Transform({objectMode: true});
var errored = false;
stream._transform = function (page, _, callback) {
if (errored) return callback(null);
if (ignored && ignored.indexOf(page.statusCode) !== -1) return callback(null);
if (!allowed || ... | javascript | function statusCodes(allowed, ignored, options) {
var stream = new Transform({objectMode: true});
var errored = false;
stream._transform = function (page, _, callback) {
if (errored) return callback(null);
if (ignored && ignored.indexOf(page.statusCode) !== -1) return callback(null);
if (!allowed || ... | [
"function",
"statusCodes",
"(",
"allowed",
",",
"ignored",
",",
"options",
")",
"{",
"var",
"stream",
"=",
"new",
"Transform",
"(",
"{",
"objectMode",
":",
"true",
"}",
")",
";",
"var",
"errored",
"=",
"false",
";",
"stream",
".",
"_transform",
"=",
"f... | Limit status codes to a list of allowed status codes
@param {Array.<Number>} allowed
@param {Array.<Number>} ignored
@returns {TransformStream} | [
"Limit",
"status",
"codes",
"to",
"a",
"list",
"of",
"allowed",
"status",
"codes"
] | 61db8899bdde604dc45cfc8f11fffa1beaa27abb | https://github.com/ForbesLindesay/stop/blob/61db8899bdde604dc45cfc8f11fffa1beaa27abb/lib/status-codes.js#L14-L31 | train |
slideme/rorschach | lib/ReadWriteLock.js | ReadWriteLock | function ReadWriteLock(client, basePath) {
var readLockDriver = new ReadLockDriver(this);
var writeLockDriver = new SortingLockDriver();
/**
* Read mutex.
*
* @type {Lock}
*/
this.readMutex = new Lock(client, basePath, READ_LOCK_NAME, readLockDriver);
this.readMutex.setMaxLeases(Infinity);
/... | javascript | function ReadWriteLock(client, basePath) {
var readLockDriver = new ReadLockDriver(this);
var writeLockDriver = new SortingLockDriver();
/**
* Read mutex.
*
* @type {Lock}
*/
this.readMutex = new Lock(client, basePath, READ_LOCK_NAME, readLockDriver);
this.readMutex.setMaxLeases(Infinity);
/... | [
"function",
"ReadWriteLock",
"(",
"client",
",",
"basePath",
")",
"{",
"var",
"readLockDriver",
"=",
"new",
"ReadLockDriver",
"(",
"this",
")",
";",
"var",
"writeLockDriver",
"=",
"new",
"SortingLockDriver",
"(",
")",
";",
"/**\n * Read mutex.\n *\n * @type {L... | Implementation of re-entrant readers-writer mutex.
@constructor
@param {Rorschach} client Rorschach instance
@param {String} basePath Base lock path | [
"Implementation",
"of",
"re",
"-",
"entrant",
"readers",
"-",
"writer",
"mutex",
"."
] | 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/ReadWriteLock.js#L42-L63 | train |
shinout/LineStream | LineStream.js | emit | function emit() {
if (arguments.length) this.emitted.push(arguments);
while (!this.paused && this.emitted.length && this.readable) {
var emitArgs = this.emitted.shift();
this.emit.apply(this, emitArgs);
if (emitArgs[0] == 'end') {
this.readable = false;
}
}
} | javascript | function emit() {
if (arguments.length) this.emitted.push(arguments);
while (!this.paused && this.emitted.length && this.readable) {
var emitArgs = this.emitted.shift();
this.emit.apply(this, emitArgs);
if (emitArgs[0] == 'end') {
this.readable = false;
}
}
} | [
"function",
"emit",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
")",
"this",
".",
"emitted",
".",
"push",
"(",
"arguments",
")",
";",
"while",
"(",
"!",
"this",
".",
"paused",
"&&",
"this",
".",
"emitted",
".",
"length",
"&&",
"this",
"."... | add emit events to the event queue.
(private method) | [
"add",
"emit",
"events",
"to",
"the",
"event",
"queue",
"."
] | 7df667d67521b9c2145901117ea61a35b2d4b55c | https://github.com/shinout/LineStream/blob/7df667d67521b9c2145901117ea61a35b2d4b55c/LineStream.js#L220-L229 | train |
shinout/LineStream | LineStream.js | emitLine | function emitLine(line, isEnd) {
if (this.filters.every(function(fn) { return fn(line) }))
emit.call(this, 'data', line, !!isEnd);
} | javascript | function emitLine(line, isEnd) {
if (this.filters.every(function(fn) { return fn(line) }))
emit.call(this, 'data', line, !!isEnd);
} | [
"function",
"emitLine",
"(",
"line",
",",
"isEnd",
")",
"{",
"if",
"(",
"this",
".",
"filters",
".",
"every",
"(",
"function",
"(",
"fn",
")",
"{",
"return",
"fn",
"(",
"line",
")",
"}",
")",
")",
"emit",
".",
"call",
"(",
"this",
",",
"'data'",
... | emit data event if the given line is valid.
(private method) | [
"emit",
"data",
"event",
"if",
"the",
"given",
"line",
"is",
"valid",
"."
] | 7df667d67521b9c2145901117ea61a35b2d4b55c | https://github.com/shinout/LineStream/blob/7df667d67521b9c2145901117ea61a35b2d4b55c/LineStream.js#L237-L240 | train |
Raynos/contract | src/contract.js | _create | function _create(f) {
var c = Object.create(Contract);
c._wrapped = f;
return c;
} | javascript | function _create(f) {
var c = Object.create(Contract);
c._wrapped = f;
return c;
} | [
"function",
"_create",
"(",
"f",
")",
"{",
"var",
"c",
"=",
"Object",
".",
"create",
"(",
"Contract",
")",
";",
"c",
".",
"_wrapped",
"=",
"f",
";",
"return",
"c",
";",
"}"
] | ContractFactory generates a new Contract based on the passed function `f` | [
"ContractFactory",
"generates",
"a",
"new",
"Contract",
"based",
"on",
"the",
"passed",
"function",
"f"
] | 4e41fffe494e2844fd6df7924ef43cfa1d6936b9 | https://github.com/Raynos/contract/blob/4e41fffe494e2844fd6df7924ef43cfa1d6936b9/src/contract.js#L77-L81 | train |
Raynos/contract | src/contract.js | defineProperties | function defineProperties(obj) {
Object.defineProperties(obj, {
"pre": {
value: Contract.pre,
configurable: true
},
"post": {
value: Contract.post,
configurable: true
},
"invariant": {
value: Contract.invariant,
... | javascript | function defineProperties(obj) {
Object.defineProperties(obj, {
"pre": {
value: Contract.pre,
configurable: true
},
"post": {
value: Contract.post,
configurable: true
},
"invariant": {
value: Contract.invariant,
... | [
"function",
"defineProperties",
"(",
"obj",
")",
"{",
"Object",
".",
"defineProperties",
"(",
"obj",
",",
"{",
"\"pre\"",
":",
"{",
"value",
":",
"Contract",
".",
"pre",
",",
"configurable",
":",
"true",
"}",
",",
"\"post\"",
":",
"{",
"value",
":",
"C... | Define the pre, post & invariant objects onto an object. | [
"Define",
"the",
"pre",
"post",
"&",
"invariant",
"objects",
"onto",
"an",
"object",
"."
] | 4e41fffe494e2844fd6df7924ef43cfa1d6936b9 | https://github.com/Raynos/contract/blob/4e41fffe494e2844fd6df7924ef43cfa1d6936b9/src/contract.js#L104-L119 | train |
EightMedia/discodip | lib/puppeteer.js | getHeight | async function getHeight(url) {
await page.goto(url);
const height = await page.evaluate(() => {
return document.body.getBoundingClientRect().height;
});
return height;
} | javascript | async function getHeight(url) {
await page.goto(url);
const height = await page.evaluate(() => {
return document.body.getBoundingClientRect().height;
});
return height;
} | [
"async",
"function",
"getHeight",
"(",
"url",
")",
"{",
"await",
"page",
".",
"goto",
"(",
"url",
")",
";",
"const",
"height",
"=",
"await",
"page",
".",
"evaluate",
"(",
"(",
")",
"=>",
"{",
"return",
"document",
".",
"body",
".",
"getBoundingClientRe... | Get page height | [
"Get",
"page",
"height"
] | 9311bf6c7cb774c8663e40fed1c158dffe2690cb | https://github.com/EightMedia/discodip/blob/9311bf6c7cb774c8663e40fed1c158dffe2690cb/lib/puppeteer.js#L26-L34 | train |
fvsch/gulp-task-maker | add.js | defineTasksForConfig | function defineTasksForConfig(taskData) {
// Define gulp tasks (build and optionally watch)
// For the task name:
// - single config, no 'name' key: <callback>
// - single config, 'name' key: <callback>_<name>
// - multiple configs, no 'name' key: <callback>_<index>
const { callback, name, normalizedConfigs... | javascript | function defineTasksForConfig(taskData) {
// Define gulp tasks (build and optionally watch)
// For the task name:
// - single config, no 'name' key: <callback>
// - single config, 'name' key: <callback>_<name>
// - multiple configs, no 'name' key: <callback>_<index>
const { callback, name, normalizedConfigs... | [
"function",
"defineTasksForConfig",
"(",
"taskData",
")",
"{",
"// Define gulp tasks (build and optionally watch)",
"// For the task name:",
"// - single config, no 'name' key: <callback>",
"// - single config, 'name' key: <callback>_<name>",
"// - multiple configs, no 'name' key: <callback>_<in... | Register matching 'build' and 'watch' gulp tasks
@param {object} taskData | [
"Register",
"matching",
"build",
"and",
"watch",
"gulp",
"tasks"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/add.js#L107-L142 | train |
fvsch/gulp-task-maker | add.js | getTaskCallback | function getTaskCallback(callback) {
let result = null
// Get the callback function; throw errors, because we can't log them
// later until we have identified a task name
if (typeof callback === 'function') {
result = callback
} else if (typeof callback === 'string') {
let id = callback.trim()
// ... | javascript | function getTaskCallback(callback) {
let result = null
// Get the callback function; throw errors, because we can't log them
// later until we have identified a task name
if (typeof callback === 'function') {
result = callback
} else if (typeof callback === 'string') {
let id = callback.trim()
// ... | [
"function",
"getTaskCallback",
"(",
"callback",
")",
"{",
"let",
"result",
"=",
"null",
"// Get the callback function; throw errors, because we can't log them",
"// later until we have identified a task name",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"r... | Check that a declared task uses a valid callback function
@param {string|Function} callback
@return {Function}
@throws {Error} | [
"Check",
"that",
"a",
"declared",
"task",
"uses",
"a",
"valid",
"callback",
"function"
] | 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/add.js#L150-L191 | train |
jlewczyk/git-hooks-js-win | lib/git-hooks.js | function (workingDirectory) {
var gitPath = getClosestGitPath(workingDirectory);
if (!gitPath) {
throw new Error('git-hooks must be run inside a git repository');
}
var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
var hooksOldPath = path.resolve(gitPath, HOOKS_... | javascript | function (workingDirectory) {
var gitPath = getClosestGitPath(workingDirectory);
if (!gitPath) {
throw new Error('git-hooks must be run inside a git repository');
}
var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
var hooksOldPath = path.resolve(gitPath, HOOKS_... | [
"function",
"(",
"workingDirectory",
")",
"{",
"var",
"gitPath",
"=",
"getClosestGitPath",
"(",
"workingDirectory",
")",
";",
"if",
"(",
"!",
"gitPath",
")",
"{",
"throw",
"new",
"Error",
"(",
"'git-hooks must be run inside a git repository'",
")",
";",
"}",
"va... | Uninstalls git hooks.
@param {String} [workingDirectory]
@throws {Error} | [
"Uninstalls",
"git",
"hooks",
"."
] | e156f88ad7aec76c9180c70656c5568ad89f9de7 | https://github.com/jlewczyk/git-hooks-js-win/blob/e156f88ad7aec76c9180c70656c5568ad89f9de7/lib/git-hooks.js#L96-L115 | train | |
jlewczyk/git-hooks-js-win | lib/git-hooks.js | spawnHook | function spawnHook(hookName, args) {
var stats = fs.statSync(hookName);
var command = hookName;
var opts = args;
var hook;
if (isWin32) {
hook = fs.readFileSync(hookName).toString();
if (!require('shebang-regex').test(hook)) {
throw new Error('Cannot find shebang in hook... | javascript | function spawnHook(hookName, args) {
var stats = fs.statSync(hookName);
var command = hookName;
var opts = args;
var hook;
if (isWin32) {
hook = fs.readFileSync(hookName).toString();
if (!require('shebang-regex').test(hook)) {
throw new Error('Cannot find shebang in hook... | [
"function",
"spawnHook",
"(",
"hookName",
",",
"args",
")",
"{",
"var",
"stats",
"=",
"fs",
".",
"statSync",
"(",
"hookName",
")",
";",
"var",
"command",
"=",
"hookName",
";",
"var",
"opts",
"=",
"args",
";",
"var",
"hook",
";",
"if",
"(",
"isWin32",... | Spawns hook as a separate process.
@param {String} hookName
@param {String[]} args
@returns {ChildProcess} | [
"Spawns",
"hook",
"as",
"a",
"separate",
"process",
"."
] | e156f88ad7aec76c9180c70656c5568ad89f9de7 | https://github.com/jlewczyk/git-hooks-js-win/blob/e156f88ad7aec76c9180c70656c5568ad89f9de7/lib/git-hooks.js#L185-L205 | train |
jlewczyk/git-hooks-js-win | lib/git-hooks.js | getClosestGitPath | function getClosestGitPath(currentPath) {
currentPath = currentPath || process.cwd();
var dirnamePath = path.join(currentPath, '.git');
if (fsHelpers.exists(dirnamePath)) {
return dirnamePath;
}
var nextPath = path.resolve(currentPath, '..');
if (nextPath === currentPath) {
r... | javascript | function getClosestGitPath(currentPath) {
currentPath = currentPath || process.cwd();
var dirnamePath = path.join(currentPath, '.git');
if (fsHelpers.exists(dirnamePath)) {
return dirnamePath;
}
var nextPath = path.resolve(currentPath, '..');
if (nextPath === currentPath) {
r... | [
"function",
"getClosestGitPath",
"(",
"currentPath",
")",
"{",
"currentPath",
"=",
"currentPath",
"||",
"process",
".",
"cwd",
"(",
")",
";",
"var",
"dirnamePath",
"=",
"path",
".",
"join",
"(",
"currentPath",
",",
"'.git'",
")",
";",
"if",
"(",
"fsHelpers... | Returns the closest git directory.
It starts looking from the current directory and does it up to the fs root.
It returns undefined in case where the specified directory isn't found.
@param {String} [currentPath] Current started path to search.
@returns {String|undefined} | [
"Returns",
"the",
"closest",
"git",
"directory",
".",
"It",
"starts",
"looking",
"from",
"the",
"current",
"directory",
"and",
"does",
"it",
"up",
"to",
"the",
"fs",
"root",
".",
"It",
"returns",
"undefined",
"in",
"case",
"where",
"the",
"specified",
"dir... | e156f88ad7aec76c9180c70656c5568ad89f9de7 | https://github.com/jlewczyk/git-hooks-js-win/blob/e156f88ad7aec76c9180c70656c5568ad89f9de7/lib/git-hooks.js#L215-L231 | train |
saggiyogesh/nodeportal | public/js/fileuploader.js | function(parent, type){
var element = qq.getByClass(parent, this._options.classes[type])[0];
if (!element){
throw new Error('element not found ' + type);
}
return element;
} | javascript | function(parent, type){
var element = qq.getByClass(parent, this._options.classes[type])[0];
if (!element){
throw new Error('element not found ' + type);
}
return element;
} | [
"function",
"(",
"parent",
",",
"type",
")",
"{",
"var",
"element",
"=",
"qq",
".",
"getByClass",
"(",
"parent",
",",
"this",
".",
"_options",
".",
"classes",
"[",
"type",
"]",
")",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"element",
")",
"{",
"throw"... | Gets one of the elements listed in this._options.classes | [
"Gets",
"one",
"of",
"the",
"elements",
"listed",
"in",
"this",
".",
"_options",
".",
"classes"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/fileuploader.js#L542-L549 | train | |
saggiyogesh/nodeportal | public/js/fileuploader.js | function(){
var self = this,
list = this._listElement;
qq.attach(list, 'click', function(e){
e = e || window.event;
var target = e.target || e.srcElement;
if (qq.hasClass(target, self._classes.cancel)){ ... | javascript | function(){
var self = this,
list = this._listElement;
qq.attach(list, 'click', function(e){
e = e || window.event;
var target = e.target || e.srcElement;
if (qq.hasClass(target, self._classes.cancel)){ ... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"list",
"=",
"this",
".",
"_listElement",
";",
"qq",
".",
"attach",
"(",
"list",
",",
"'click'",
",",
"function",
"(",
"e",
")",
"{",
"e",
"=",
"e",
"||",
"window",
".",
"event",
";",
... | delegate click event for cancel link | [
"delegate",
"click",
"event",
"for",
"cancel",
"link"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/fileuploader.js#L647-L663 | train | |
saggiyogesh/nodeportal | public/js/fileuploader.js | function(id){
// We can't use following code as the name attribute
// won't be properly registered in IE6, and new window
// on form submit will open
// var iframe = document.createElement('iframe');
// iframe.setAttribute('name', id);
var iframe = qq.toElement('<iframe ... | javascript | function(id){
// We can't use following code as the name attribute
// won't be properly registered in IE6, and new window
// on form submit will open
// var iframe = document.createElement('iframe');
// iframe.setAttribute('name', id);
var iframe = qq.toElement('<iframe ... | [
"function",
"(",
"id",
")",
"{",
"// We can't use following code as the name attribute",
"// won't be properly registered in IE6, and new window",
"// on form submit will open",
"// var iframe = document.createElement('iframe');",
"// iframe.setAttribute('name', id);",
"var",
"iframe",
"=",
... | Creates iframe with unique name | [
"Creates",
"iframe",
"with",
"unique",
"name"
] | cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/js/fileuploader.js#L1074-L1090 | train | |
slawrence/grunt-properties-reader | tasks/properties_reader.js | _convertStringIfTrue | function _convertStringIfTrue(original) {
var str;
if (original && typeof original === "string") {
str = original.toLowerCase().trim();
return (str === "true" || str === "false") ? (str === "true") : original;
}
return original;
} | javascript | function _convertStringIfTrue(original) {
var str;
if (original && typeof original === "string") {
str = original.toLowerCase().trim();
return (str === "true" || str === "false") ? (str === "true") : original;
}
return original;
} | [
"function",
"_convertStringIfTrue",
"(",
"original",
")",
"{",
"var",
"str",
";",
"if",
"(",
"original",
"&&",
"typeof",
"original",
"===",
"\"string\"",
")",
"{",
"str",
"=",
"original",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
";",
"return"... | If a string is "true" "TRUE", or " TrUE" convert to boolean type else
leave as is | [
"If",
"a",
"string",
"is",
"true",
"TRUE",
"or",
"TrUE",
"convert",
"to",
"boolean",
"type",
"else",
"leave",
"as",
"is"
] | e8da99c688e2609838d76ea3b1c69a3e6027692e | https://github.com/slawrence/grunt-properties-reader/blob/e8da99c688e2609838d76ea3b1c69a3e6027692e/tasks/properties_reader.js#L15-L22 | train |
slawrence/grunt-properties-reader | tasks/properties_reader.js | convertPropsToJson | function convertPropsToJson(text) {
var configObject = {};
if (text && text.length) {
// handle multi-line values terminated with a backslash
text = text.replace(/\\\r?\n\s*/g, '');
text.split(/\r?\n/g).forEach(function (line) {
var props,
name,
... | javascript | function convertPropsToJson(text) {
var configObject = {};
if (text && text.length) {
// handle multi-line values terminated with a backslash
text = text.replace(/\\\r?\n\s*/g, '');
text.split(/\r?\n/g).forEach(function (line) {
var props,
name,
... | [
"function",
"convertPropsToJson",
"(",
"text",
")",
"{",
"var",
"configObject",
"=",
"{",
"}",
";",
"if",
"(",
"text",
"&&",
"text",
".",
"length",
")",
"{",
"// handle multi-line values terminated with a backslash",
"text",
"=",
"text",
".",
"replace",
"(",
"... | Convert properties string into a json object
Only supports boolean and string types | [
"Convert",
"properties",
"string",
"into",
"a",
"json",
"object",
"Only",
"supports",
"boolean",
"and",
"string",
"types"
] | e8da99c688e2609838d76ea3b1c69a3e6027692e | https://github.com/slawrence/grunt-properties-reader/blob/e8da99c688e2609838d76ea3b1c69a3e6027692e/tasks/properties_reader.js#L28-L47 | train |
jchook/virtual-dom-handlebars | lib/VTree.js | VTree | function VTree(body, config) {
var i;
config = extend({ allowJSON: false }, config);
Object.defineProperty(this, 'config', { enumerable: false, value: config });
if (body && body.length) {
for (i=0; i<body.length; i++) {
this.push(body[i]);
}
}
} | javascript | function VTree(body, config) {
var i;
config = extend({ allowJSON: false }, config);
Object.defineProperty(this, 'config', { enumerable: false, value: config });
if (body && body.length) {
for (i=0; i<body.length; i++) {
this.push(body[i]);
}
}
} | [
"function",
"VTree",
"(",
"body",
",",
"config",
")",
"{",
"var",
"i",
";",
"config",
"=",
"extend",
"(",
"{",
"allowJSON",
":",
"false",
"}",
",",
"config",
")",
";",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'config'",
",",
"{",
"enumerab... | Array of VText, VNode, and Block Expressions | [
"Array",
"of",
"VText",
"VNode",
"and",
"Block",
"Expressions"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/VTree.js#L6-L15 | train |
jchook/virtual-dom-handlebars | lib/Runtime.js | function(object, options) {
var i, r = [];
for (i in object) {
if (object.hasOwnProperty(i)) {
r = r.concat(options.fn(object[i]));
}
}
return r;
} | javascript | function(object, options) {
var i, r = [];
for (i in object) {
if (object.hasOwnProperty(i)) {
r = r.concat(options.fn(object[i]));
}
}
return r;
} | [
"function",
"(",
"object",
",",
"options",
")",
"{",
"var",
"i",
",",
"r",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"in",
"object",
")",
"{",
"if",
"(",
"object",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"r",
"=",
"r",
".",
"concat",
"(",
... | Block helpers always return an array of VNodes | [
"Block",
"helpers",
"always",
"return",
"an",
"array",
"of",
"VNodes"
] | d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Runtime.js#L85-L93 | train | |
wilmoore/dotsplit.js | index.js | dotsplit | function dotsplit (string) {
var idx = -1
var str = compact(normalize(string).split('.'))
var end = str.length
var out = []
while (++idx < end) {
out.push(todots(str[idx]))
}
return out
} | javascript | function dotsplit (string) {
var idx = -1
var str = compact(normalize(string).split('.'))
var end = str.length
var out = []
while (++idx < end) {
out.push(todots(str[idx]))
}
return out
} | [
"function",
"dotsplit",
"(",
"string",
")",
"{",
"var",
"idx",
"=",
"-",
"1",
"var",
"str",
"=",
"compact",
"(",
"normalize",
"(",
"string",
")",
".",
"split",
"(",
"'.'",
")",
")",
"var",
"end",
"=",
"str",
".",
"length",
"var",
"out",
"=",
"[",... | Transform dot-delimited strings to array of strings.
@param {String} string
Dot-delimited string.
@return {Array}
Array of strings. | [
"Transform",
"dot",
"-",
"delimited",
"strings",
"to",
"array",
"of",
"strings",
"."
] | 5334735bd130dbb9089bdf2ccdc73723f1a49419 | https://github.com/wilmoore/dotsplit.js/blob/5334735bd130dbb9089bdf2ccdc73723f1a49419/index.js#L15-L26 | train |
wilmoore/dotsplit.js | index.js | compact | function compact (arr) {
var idx = -1
var end = arr.length
var out = []
while (++idx < end) {
if (arr[idx]) out.push(arr[idx])
}
return out
} | javascript | function compact (arr) {
var idx = -1
var end = arr.length
var out = []
while (++idx < end) {
if (arr[idx]) out.push(arr[idx])
}
return out
} | [
"function",
"compact",
"(",
"arr",
")",
"{",
"var",
"idx",
"=",
"-",
"1",
"var",
"end",
"=",
"arr",
".",
"length",
"var",
"out",
"=",
"[",
"]",
"while",
"(",
"++",
"idx",
"<",
"end",
")",
"{",
"if",
"(",
"arr",
"[",
"idx",
"]",
")",
"out",
... | Drop empty values from array.
@param {Array} array
Array of strings.
@return {Array}
Array of strings (empty values dropped). | [
"Drop",
"empty",
"values",
"from",
"array",
"."
] | 5334735bd130dbb9089bdf2ccdc73723f1a49419 | https://github.com/wilmoore/dotsplit.js/blob/5334735bd130dbb9089bdf2ccdc73723f1a49419/index.js#L52-L62 | train |
IonicaBizau/read-file-cache | lib/index.js | readFileCache | function readFileCache (path, noCache, cb) {
path = abs(path);
if (typeof noCache === "function") {
cb = noCache;
noCache = false;
}
// TODO: Callback buffering
if (_cache[path] && noCache !== true) {
return cb(null, _cache[path]);
}
read(path, (err, data) => {
... | javascript | function readFileCache (path, noCache, cb) {
path = abs(path);
if (typeof noCache === "function") {
cb = noCache;
noCache = false;
}
// TODO: Callback buffering
if (_cache[path] && noCache !== true) {
return cb(null, _cache[path]);
}
read(path, (err, data) => {
... | [
"function",
"readFileCache",
"(",
"path",
",",
"noCache",
",",
"cb",
")",
"{",
"path",
"=",
"abs",
"(",
"path",
")",
";",
"if",
"(",
"typeof",
"noCache",
"===",
"\"function\"",
")",
"{",
"cb",
"=",
"noCache",
";",
"noCache",
"=",
"false",
";",
"}",
... | readFileCache
Reads the file asyncronously.
@name readFileCache
@function
@param {String} path The file path.
@param {Boolean} noCache If `true`, the file will be read from the disk.
@param {Function} cb The callback function. | [
"readFileCache",
"Reads",
"the",
"file",
"asyncronously",
"."
] | 3bc33aa244169bdf6a48dad96b6a94dcf91d8d59 | https://github.com/IonicaBizau/read-file-cache/blob/3bc33aa244169bdf6a48dad96b6a94dcf91d8d59/lib/index.js#L19-L36 | train |
ryanseys/node-jawbone-up | index.js | function(options, callback) {
request({
method: 'post',
url: options.url,
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/x-www-form-urlencoded'
},
form: options.data
},
function(error, response, body) {
callback(error, b... | javascript | function(options, callback) {
request({
method: 'post',
url: options.url,
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/x-www-form-urlencoded'
},
form: options.data
},
function(error, response, body) {
callback(error, b... | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"request",
"(",
"{",
"method",
":",
"'post'",
",",
"url",
":",
"options",
".",
"url",
",",
"headers",
":",
"{",
"'Authorization'",
":",
"'Bearer '",
"+",
"access_token",
",",
"'Content-Type'",
":",
"... | Makes a POST request to the API with options.
@private
@param {Object} options Options that includes the `url` to POST and
`data` object to include in POST request.
@param {Function} callback Function to callback with response. | [
"Makes",
"a",
"POST",
"request",
"to",
"the",
"API",
"with",
"options",
"."
] | 6856b7960530e43682e7dd9bf8d4f97e852637cf | https://github.com/ryanseys/node-jawbone-up/blob/6856b7960530e43682e7dd9bf8d4f97e852637cf/index.js#L102-L115 | train | |
dailymotion/react-collider | lib/client.js | reanderPage | function reanderPage(Handler, data) {
React.render(React.createElement(Handler, { data: data }), document);
} | javascript | function reanderPage(Handler, data) {
React.render(React.createElement(Handler, { data: data }), document);
} | [
"function",
"reanderPage",
"(",
"Handler",
",",
"data",
")",
"{",
"React",
".",
"render",
"(",
"React",
".",
"createElement",
"(",
"Handler",
",",
"{",
"data",
":",
"data",
"}",
")",
",",
"document",
")",
";",
"}"
] | Client side rendering | [
"Client",
"side",
"rendering"
] | 00cea5d25928d4a3ff0c68b6535edbc231d2b0a1 | https://github.com/dailymotion/react-collider/blob/00cea5d25928d4a3ff0c68b6535edbc231d2b0a1/lib/client.js#L26-L28 | train |
francois2metz/node-spore | lib/httpclient.js | function(path, params) {
var queryString = this.query_string;
for (var param in params) {
var re = new RegExp(":"+ param)
var found = false;
if (path.search(re) != -1) {
path = path.replace(re, params[param]);
found = true;
... | javascript | function(path, params) {
var queryString = this.query_string;
for (var param in params) {
var re = new RegExp(":"+ param)
var found = false;
if (path.search(re) != -1) {
path = path.replace(re, params[param]);
found = true;
... | [
"function",
"(",
"path",
",",
"params",
")",
"{",
"var",
"queryString",
"=",
"this",
".",
"query_string",
";",
"for",
"(",
"var",
"param",
"in",
"params",
")",
"{",
"var",
"re",
"=",
"new",
"RegExp",
"(",
"\":\"",
"+",
"param",
")",
"var",
"found",
... | Format uri with params
add orphelin params in query string | [
"Format",
"uri",
"with",
"params",
"add",
"orphelin",
"params",
"in",
"query",
"string"
] | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/httpclient.js#L41-L68 | train | |
francois2metz/node-spore | lib/httpclient.js | function(headers, params) {
var newHeaders = {};
for (var header in headers)
newHeaders[header] = headers[header];
for (var param in params) {
var re = new RegExp(":"+ param);
for (var header in newHeaders) {
if (newHeaders[header].search(re) !... | javascript | function(headers, params) {
var newHeaders = {};
for (var header in headers)
newHeaders[header] = headers[header];
for (var param in params) {
var re = new RegExp(":"+ param);
for (var header in newHeaders) {
if (newHeaders[header].search(re) !... | [
"function",
"(",
"headers",
",",
"params",
")",
"{",
"var",
"newHeaders",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"header",
"in",
"headers",
")",
"newHeaders",
"[",
"header",
"]",
"=",
"headers",
"[",
"header",
"]",
";",
"for",
"(",
"var",
"param",
... | format final headers | [
"format",
"final",
"headers"
] | a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/httpclient.js#L72-L85 | train | |
tradle/zlorp | lib/peer.js | Peer | function Peer (options) {
EventEmitter.call(this)
bindFns(this)
extend(this, options)
var addr = this.address
var hp = addr.split(':')
this.host = hp[0]
this.port = Number(hp[1])
this._deliveryTrackers = []
this.setMaxListeners(0)
this._debug('new peer')
} | javascript | function Peer (options) {
EventEmitter.call(this)
bindFns(this)
extend(this, options)
var addr = this.address
var hp = addr.split(':')
this.host = hp[0]
this.port = Number(hp[1])
this._deliveryTrackers = []
this.setMaxListeners(0)
this._debug('new peer')
} | [
"function",
"Peer",
"(",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
"bindFns",
"(",
"this",
")",
"extend",
"(",
"this",
",",
"options",
")",
"var",
"addr",
"=",
"this",
".",
"address",
"var",
"hp",
"=",
"addr",
".",
"split",
... | A connection with whoever can prove ownership of a pubKey
@param {[type]} options [description] | [
"A",
"connection",
"with",
"whoever",
"can",
"prove",
"ownership",
"of",
"a",
"pubKey"
] | 6d23d855fdafed49cb6d77a0e1930f6465f11d6e | https://github.com/tradle/zlorp/blob/6d23d855fdafed49cb6d77a0e1930f6465f11d6e/lib/peer.js#L29-L41 | 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.