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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
enbock/corejs-w3c | src/core.js | use | function use(fullQualifiedClassName) {
var container = use.getContainer(fullQualifiedClassName)
;
if (container._loader === null) {
use.loadCount++;
container._loader = Ajax.factory(
"get", container._path + use.fileExtension
);
container._loader.addEventListener(Ajax.Event.LOAD, function(event... | javascript | function use(fullQualifiedClassName) {
var container = use.getContainer(fullQualifiedClassName)
;
if (container._loader === null) {
use.loadCount++;
container._loader = Ajax.factory(
"get", container._path + use.fileExtension
);
container._loader.addEventListener(Ajax.Event.LOAD, function(event... | [
"function",
"use",
"(",
"fullQualifiedClassName",
")",
"{",
"var",
"container",
"=",
"use",
".",
"getContainer",
"(",
"fullQualifiedClassName",
")",
";",
"if",
"(",
"container",
".",
"_loader",
"===",
"null",
")",
"{",
"use",
".",
"loadCount",
"++",
";",
"... | Auto load system.
@signleton | [
"Auto",
"load",
"system",
"."
] | ae6b78f17152b1e8ddf1c0031b4f54cb0e419d04 | https://github.com/enbock/corejs-w3c/blob/ae6b78f17152b1e8ddf1c0031b4f54cb0e419d04/src/core.js#L399-L455 | train |
SoftEng-HEIGVD/iflux-node-client | lib/client.js | Client | function Client(endpointUrl, sourceId) {
this.restClient = new restClient.Client();
this.endpointUrl = endpointUrl;
if (this.endpointUrl) {
// Remove the trailing slash if necessary
if (this.endpointUrl.indexOf('/', this.endpointUrl.length - 1) !== -1) {
this.endpointUrl = this.endpointUrl.substr(0, t... | javascript | function Client(endpointUrl, sourceId) {
this.restClient = new restClient.Client();
this.endpointUrl = endpointUrl;
if (this.endpointUrl) {
// Remove the trailing slash if necessary
if (this.endpointUrl.indexOf('/', this.endpointUrl.length - 1) !== -1) {
this.endpointUrl = this.endpointUrl.substr(0, t... | [
"function",
"Client",
"(",
"endpointUrl",
",",
"sourceId",
")",
"{",
"this",
".",
"restClient",
"=",
"new",
"restClient",
".",
"Client",
"(",
")",
";",
"this",
".",
"endpointUrl",
"=",
"endpointUrl",
";",
"if",
"(",
"this",
".",
"endpointUrl",
")",
"{",
... | Constructor for the iFLUX Client.
@param {string} endpointUrl The URL prefix for the API (e.g. http://api.iflux.io/api)
@param {string} sourceId The event source id
@constructor | [
"Constructor",
"for",
"the",
"iFLUX",
"Client",
"."
] | 5cb9fb4c0ca34ce120a876f6a64577fa97e3aac5 | https://github.com/SoftEng-HEIGVD/iflux-node-client/blob/5cb9fb4c0ca34ce120a876f6a64577fa97e3aac5/lib/client.js#L11-L32 | train |
fieosa/webcomponent-mdl | src/utils/jsxdom.js | processChildren | function processChildren(ele, children) {
if (children && children.constructor === Array) {
for(var i = 0; i < children.length; i++) {
processChildren(ele, children[i]);
}
} else if (children instanceof Node) {
ele.appendChild(children);
} else if (children) {
ele.appendChild(document.create... | javascript | function processChildren(ele, children) {
if (children && children.constructor === Array) {
for(var i = 0; i < children.length; i++) {
processChildren(ele, children[i]);
}
} else if (children instanceof Node) {
ele.appendChild(children);
} else if (children) {
ele.appendChild(document.create... | [
"function",
"processChildren",
"(",
"ele",
",",
"children",
")",
"{",
"if",
"(",
"children",
"&&",
"children",
".",
"constructor",
"===",
"Array",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
... | Implementation of templating syntax for jsx.
To support tag nesting syntax:
examples:
<p>
<div></div>
<span><span/>
</p>
1. Recursively call processChildren which the 'children' parameter is an instance of n-dimensional array.
The above example is an array of [[div], [span]] as the children of <p> tag.
To support {t... | [
"Implementation",
"of",
"templating",
"syntax",
"for",
"jsx",
"."
] | 5aec1bfd5110addcbeedd01ba07b8a01c836c511 | https://github.com/fieosa/webcomponent-mdl/blob/5aec1bfd5110addcbeedd01ba07b8a01c836c511/src/utils/jsxdom.js#L33-L43 | train |
overlookmotel/drive-watch | lib/index.js | getDrives | function getDrives() {
return getDrivesNow().then(function(drives) {
// if new drive events during scan, redo scan
if (newEvents) return getDrives();
recordDrives(drives);
if (self.options.scanInterval) self.scanTimer = setTimeout(updateDrives, self.options.scanI... | javascript | function getDrives() {
return getDrivesNow().then(function(drives) {
// if new drive events during scan, redo scan
if (newEvents) return getDrives();
recordDrives(drives);
if (self.options.scanInterval) self.scanTimer = setTimeout(updateDrives, self.options.scanI... | [
"function",
"getDrives",
"(",
")",
"{",
"return",
"getDrivesNow",
"(",
")",
".",
"then",
"(",
"function",
"(",
"drives",
")",
"{",
"// if new drive events during scan, redo scan",
"if",
"(",
"newEvents",
")",
"return",
"getDrives",
"(",
")",
";",
"recordDrives",... | get drives initially connected | [
"get",
"drives",
"initially",
"connected"
] | 61ca4c8c82aba06f0c3af3ca17cc4fd15fb78ed4 | https://github.com/overlookmotel/drive-watch/blob/61ca4c8c82aba06f0c3af3ca17cc4fd15fb78ed4/lib/index.js#L65-L76 | train |
overlookmotel/drive-watch | lib/index.js | getDrivesNow | function getDrivesNow() {
reading = true;
newEvents = false;
return fs.readdirAsync(drivesPath)
.then(function(files) {
var drives = files.filter(function(name) {
return name != '.DS_Store';
});
return drives;
});
} | javascript | function getDrivesNow() {
reading = true;
newEvents = false;
return fs.readdirAsync(drivesPath)
.then(function(files) {
var drives = files.filter(function(name) {
return name != '.DS_Store';
});
return drives;
});
} | [
"function",
"getDrivesNow",
"(",
")",
"{",
"reading",
"=",
"true",
";",
"newEvents",
"=",
"false",
";",
"return",
"fs",
".",
"readdirAsync",
"(",
"drivesPath",
")",
".",
"then",
"(",
"function",
"(",
"files",
")",
"{",
"var",
"drives",
"=",
"files",
".... | scan for connected drives | [
"scan",
"for",
"connected",
"drives"
] | 61ca4c8c82aba06f0c3af3ca17cc4fd15fb78ed4 | https://github.com/overlookmotel/drive-watch/blob/61ca4c8c82aba06f0c3af3ca17cc4fd15fb78ed4/lib/index.js#L107-L119 | train |
fazo96/LC2.js | cli.js | onRead | function onRead (key) {
if (key !== null) {
if (cli.debug) console.log('Key:', key)
// Exits on CTRL-C
if (key === '\u0003') process.exit()
// If enter is pressed and the program is waiting for the user to press enter
// so that the emulator can step forward, then call the appropriate callback
... | javascript | function onRead (key) {
if (key !== null) {
if (cli.debug) console.log('Key:', key)
// Exits on CTRL-C
if (key === '\u0003') process.exit()
// If enter is pressed and the program is waiting for the user to press enter
// so that the emulator can step forward, then call the appropriate callback
... | [
"function",
"onRead",
"(",
"key",
")",
"{",
"if",
"(",
"key",
"!==",
"null",
")",
"{",
"if",
"(",
"cli",
".",
"debug",
")",
"console",
".",
"log",
"(",
"'Key:'",
",",
"key",
")",
"// Exits on CTRL-C",
"if",
"(",
"key",
"===",
"'\\u0003'",
")",
"pro... | This function processes an input key from STDIN. | [
"This",
"function",
"processes",
"an",
"input",
"key",
"from",
"STDIN",
"."
] | 33b1d1e84d5da7c0df16290fc1289628ba65b430 | https://github.com/fazo96/LC2.js/blob/33b1d1e84d5da7c0df16290fc1289628ba65b430/cli.js#L48-L63 | train |
fazo96/LC2.js | cli.js | end | function end () {
console.log('\n=== REG DUMP ===\n' + cpu.regdump().join('\n'))
if (options.memDump) console.log('\n\n=== MEM DUMP ===\n' + cpu.memdump(0, 65535).join('\n'))
process.exit() // workaround for stdin event listener hanging
} | javascript | function end () {
console.log('\n=== REG DUMP ===\n' + cpu.regdump().join('\n'))
if (options.memDump) console.log('\n\n=== MEM DUMP ===\n' + cpu.memdump(0, 65535).join('\n'))
process.exit() // workaround for stdin event listener hanging
} | [
"function",
"end",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'\\n=== REG DUMP ===\\n'",
"+",
"cpu",
".",
"regdump",
"(",
")",
".",
"join",
"(",
"'\\n'",
")",
")",
"if",
"(",
"options",
".",
"memDump",
")",
"console",
".",
"log",
"(",
"'\\n\\n=== MEM ... | Called when the LC-2 program has finished running | [
"Called",
"when",
"the",
"LC",
"-",
"2",
"program",
"has",
"finished",
"running"
] | 33b1d1e84d5da7c0df16290fc1289628ba65b430 | https://github.com/fazo96/LC2.js/blob/33b1d1e84d5da7c0df16290fc1289628ba65b430/cli.js#L138-L142 | train |
hitchyjs/server-dev-tools | bin/hitchy-pm.js | processSimple | function processSimple( names, current, stopAt, collector, done ) {
const name = names[current];
File.stat( Path.join( "node_modules", name, "hitchy.json" ), ( error, stat ) => {
if ( error ) {
if ( error.code === "ENOENT" ) {
collector.push( name );
} else {
done( error );
return;
}
} else ... | javascript | function processSimple( names, current, stopAt, collector, done ) {
const name = names[current];
File.stat( Path.join( "node_modules", name, "hitchy.json" ), ( error, stat ) => {
if ( error ) {
if ( error.code === "ENOENT" ) {
collector.push( name );
} else {
done( error );
return;
}
} else ... | [
"function",
"processSimple",
"(",
"names",
",",
"current",
",",
"stopAt",
",",
"collector",
",",
"done",
")",
"{",
"const",
"name",
"=",
"names",
"[",
"current",
"]",
";",
"File",
".",
"stat",
"(",
"Path",
".",
"join",
"(",
"\"node_modules\"",
",",
"na... | Successively tests provided names of dependencies for matching existing
folder in local sub-folder `node_modules` each containing file hitchy.json.
@param {string[]} names list of dependency names to be tested
@param {int} current index of next item in provided list to be processed
@param {int} stopAt index to stop at... | [
"Successively",
"tests",
"provided",
"names",
"of",
"dependencies",
"for",
"matching",
"existing",
"folder",
"in",
"local",
"sub",
"-",
"folder",
"node_modules",
"each",
"containing",
"file",
"hitchy",
".",
"json",
"."
] | 352c0de74b532b474a71816fdc63d2218c126536 | https://github.com/hitchyjs/server-dev-tools/blob/352c0de74b532b474a71816fdc63d2218c126536/bin/hitchy-pm.js#L125-L151 | train |
hitchyjs/server-dev-tools | bin/hitchy-pm.js | installMissing | function installMissing( error, collected ) {
if ( error ) {
console.error( `checking dependencies failed: ${error.message}` );
process.exit( 1 );
return;
}
if ( collected.length < 1 ) {
postProcess( 0 );
} else {
if ( !quiet ) {
console.error( `installing missing dependencies:\n${collected.map( d =>... | javascript | function installMissing( error, collected ) {
if ( error ) {
console.error( `checking dependencies failed: ${error.message}` );
process.exit( 1 );
return;
}
if ( collected.length < 1 ) {
postProcess( 0 );
} else {
if ( !quiet ) {
console.error( `installing missing dependencies:\n${collected.map( d =>... | [
"function",
"installMissing",
"(",
"error",
",",
"collected",
")",
"{",
"if",
"(",
"error",
")",
"{",
"console",
".",
"error",
"(",
"`",
"${",
"error",
".",
"message",
"}",
"`",
")",
";",
"process",
".",
"exit",
"(",
"1",
")",
";",
"return",
";",
... | Installs collected dependencies considered missing or handles provided error.
@param {Error} error encountered error
@param {string[]} collected list of dependencies considered missing | [
"Installs",
"collected",
"dependencies",
"considered",
"missing",
"or",
"handles",
"provided",
"error",
"."
] | 352c0de74b532b474a71816fdc63d2218c126536 | https://github.com/hitchyjs/server-dev-tools/blob/352c0de74b532b474a71816fdc63d2218c126536/bin/hitchy-pm.js#L159-L183 | train |
hitchyjs/server-dev-tools | bin/hitchy-pm.js | postProcess | function postProcess( errorCode ) {
if ( errorCode ) {
console.error( `running npm for installing missing dependencies ${collected.join( ", " )} exited on error (${errorCode})` );
} else if ( exec ) {
const cmd = exec.join( " " );
if ( !quiet ) {
console.error( `invoking follow-up command: ${cmd}` );
}
... | javascript | function postProcess( errorCode ) {
if ( errorCode ) {
console.error( `running npm for installing missing dependencies ${collected.join( ", " )} exited on error (${errorCode})` );
} else if ( exec ) {
const cmd = exec.join( " " );
if ( !quiet ) {
console.error( `invoking follow-up command: ${cmd}` );
}
... | [
"function",
"postProcess",
"(",
"errorCode",
")",
"{",
"if",
"(",
"errorCode",
")",
"{",
"console",
".",
"error",
"(",
"`",
"${",
"collected",
".",
"join",
"(",
"\", \"",
")",
"}",
"${",
"errorCode",
"}",
"`",
")",
";",
"}",
"else",
"if",
"(",
"exe... | Handles event of having passed installation of missing dependencies.
@param {int} errorCode status code on exit of npm installing missing dependencies | [
"Handles",
"event",
"of",
"having",
"passed",
"installation",
"of",
"missing",
"dependencies",
"."
] | 352c0de74b532b474a71816fdc63d2218c126536 | https://github.com/hitchyjs/server-dev-tools/blob/352c0de74b532b474a71816fdc63d2218c126536/bin/hitchy-pm.js#L190-L213 | train |
shinuza/captain-admin | public/js/lib/alertify.js | function (fn) {
var hasOK = (typeof btnOK !== "undefined"),
hasCancel = (typeof btnCancel !== "undefined"),
hasInput = (typeof input !== "undefined"),
val = "",
self = this,
ok, cancel, common, key, reset;
// ok event handler
ok = function (event) {
... | javascript | function (fn) {
var hasOK = (typeof btnOK !== "undefined"),
hasCancel = (typeof btnCancel !== "undefined"),
hasInput = (typeof input !== "undefined"),
val = "",
self = this,
ok, cancel, common, key, reset;
// ok event handler
ok = function (event) {
... | [
"function",
"(",
"fn",
")",
"{",
"var",
"hasOK",
"=",
"(",
"typeof",
"btnOK",
"!==",
"\"undefined\"",
")",
",",
"hasCancel",
"=",
"(",
"typeof",
"btnCancel",
"!==",
"\"undefined\"",
")",
",",
"hasInput",
"=",
"(",
"typeof",
"input",
"!==",
"\"undefined\"",... | Set the proper button click events
@param {Function} fn [Optional] Callback function
@return {undefined} | [
"Set",
"the",
"proper",
"button",
"click",
"events"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L119-L189 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function (item) {
var html = "",
type = item.type,
message = item.message,
css = item.cssClass || "";
html += "<div class=\"alertify-dialog\">";
if (_alertify.buttonFocus === "none") html += "<a href=\"#\" id=\"alertify-noneFocus\" class=\"alertify-hidden\"></a>";
if... | javascript | function (item) {
var html = "",
type = item.type,
message = item.message,
css = item.cssClass || "";
html += "<div class=\"alertify-dialog\">";
if (_alertify.buttonFocus === "none") html += "<a href=\"#\" id=\"alertify-noneFocus\" class=\"alertify-hidden\"></a>";
if... | [
"function",
"(",
"item",
")",
"{",
"var",
"html",
"=",
"\"\"",
",",
"type",
"=",
"item",
".",
"type",
",",
"message",
"=",
"item",
".",
"message",
",",
"css",
"=",
"item",
".",
"cssClass",
"||",
"\"\"",
";",
"html",
"+=",
"\"<div class=\\\"alertify-dia... | Build the proper message box
@param {Object} item Current object in the queue
@return {String} An HTML string of the message box | [
"Build",
"the",
"proper",
"message",
"box"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L244-L289 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function (elem, wait) {
// Unary Plus: +"2" === 2
var timer = (wait && !isNaN(wait)) ? +wait : this.delay,
self = this,
hideElement, transitionDone;
// set click event on log messages
this.bind(elem, "click", function () {
hideElement(elem);
});
// Hide the dialog box afte... | javascript | function (elem, wait) {
// Unary Plus: +"2" === 2
var timer = (wait && !isNaN(wait)) ? +wait : this.delay,
self = this,
hideElement, transitionDone;
// set click event on log messages
this.bind(elem, "click", function () {
hideElement(elem);
});
// Hide the dialog box afte... | [
"function",
"(",
"elem",
",",
"wait",
")",
"{",
"// Unary Plus: +\"2\" === 2",
"var",
"timer",
"=",
"(",
"wait",
"&&",
"!",
"isNaN",
"(",
"wait",
")",
")",
"?",
"+",
"wait",
":",
"this",
".",
"delay",
",",
"self",
"=",
"this",
",",
"hideElement",
","... | Close the log messages
@param {Object} elem HTML Element of log message to close
@param {Number} wait [optional] Time (in ms) to wait before automatically hiding the message, if 0 never hide
@return {undefined} | [
"Close",
"the",
"log",
"messages"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L299-L338 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function (message, type, fn, placeholder, cssClass) {
// set the current active element
// this allows the keyboard focus to be resetted
// after the dialog box is closed
elCallee = document.activeElement;
// check to ensure the alertify dialog element
// has been successfully created
var ch... | javascript | function (message, type, fn, placeholder, cssClass) {
// set the current active element
// this allows the keyboard focus to be resetted
// after the dialog box is closed
elCallee = document.activeElement;
// check to ensure the alertify dialog element
// has been successfully created
var ch... | [
"function",
"(",
"message",
",",
"type",
",",
"fn",
",",
"placeholder",
",",
"cssClass",
")",
"{",
"// set the current active element",
"// this allows the keyboard focus to be resetted",
"// after the dialog box is closed",
"elCallee",
"=",
"document",
".",
"activeElement",
... | Create a dialog box
@param {String} message The message passed from the callee
@param {String} type Type of dialog to create
@param {Function} fn [Optional] Callback function
@param {String} placeholder [Optional] Default value for prompt input field
@param {String} cssClas... | [
"Create",
"a",
"dialog",
"box"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L351-L376 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function () {
var transitionDone,
self = this;
// remove reference from queue
queue.splice(0,1);
// if items remaining in the queue
if (queue.length > 0) this.setup(true);
else {
isopen = false;
// Hide the dialog box after transition
// This ensure it doens't block any el... | javascript | function () {
var transitionDone,
self = this;
// remove reference from queue
queue.splice(0,1);
// if items remaining in the queue
if (queue.length > 0) this.setup(true);
else {
isopen = false;
// Hide the dialog box after transition
// This ensure it doens't block any el... | [
"function",
"(",
")",
"{",
"var",
"transitionDone",
",",
"self",
"=",
"this",
";",
"// remove reference from queue",
"queue",
".",
"splice",
"(",
"0",
",",
"1",
")",
";",
"// if items remaining in the queue",
"if",
"(",
"queue",
".",
"length",
">",
"0",
")",... | Hide the dialog and rest to defaults
@return {undefined} | [
"Hide",
"the",
"dialog",
"and",
"rest",
"to",
"defaults"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L398-L427 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function () {
// ensure legacy browsers support html5 tags
document.createElement("nav");
document.createElement("article");
document.createElement("section");
// cover
elCover = document.createElement("div");
elCover.setAttribute("id", "alertify-cover");
elCover.className = "alertify-co... | javascript | function () {
// ensure legacy browsers support html5 tags
document.createElement("nav");
document.createElement("article");
document.createElement("section");
// cover
elCover = document.createElement("div");
elCover.setAttribute("id", "alertify-cover");
elCover.className = "alertify-co... | [
"function",
"(",
")",
"{",
"// ensure legacy browsers support html5 tags",
"document",
".",
"createElement",
"(",
"\"nav\"",
")",
";",
"document",
".",
"createElement",
"(",
"\"article\"",
")",
";",
"document",
".",
"createElement",
"(",
"\"section\"",
")",
";",
"... | Initialize Alertify
Create the 2 main elements
@return {undefined} | [
"Initialize",
"Alertify",
"Create",
"the",
"2",
"main",
"elements"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L435-L463 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function (message, type, wait) {
// check to ensure the alertify dialog element
// has been successfully created
var check = function () {
if (elLog && elLog.scrollTop !== null) return;
else check();
};
// initialize alertify if it hasn't already been done
if (typeof this.init === "fun... | javascript | function (message, type, wait) {
// check to ensure the alertify dialog element
// has been successfully created
var check = function () {
if (elLog && elLog.scrollTop !== null) return;
else check();
};
// initialize alertify if it hasn't already been done
if (typeof this.init === "fun... | [
"function",
"(",
"message",
",",
"type",
",",
"wait",
")",
"{",
"// check to ensure the alertify dialog element",
"// has been successfully created",
"var",
"check",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"elLog",
"&&",
"elLog",
".",
"scrollTop",
"!==",
"null"... | Show a new log message box
@param {String} message The message passed from the callee
@param {String} type [Optional] Optional type of log message
@param {Number} wait [Optional] Time (in ms) to wait before auto-hiding the log
@return {Object} | [
"Show",
"a",
"new",
"log",
"message",
"box"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L474-L489 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function (fromQueue) {
var item = queue[0],
self = this,
transitionDone;
// dialog is open
isopen = true;
// Set button focus after transition
transitionDone = function (event) {
event.stopPropagation();
self.setFocus();
// unbind event so function only gets called on... | javascript | function (fromQueue) {
var item = queue[0],
self = this,
transitionDone;
// dialog is open
isopen = true;
// Set button focus after transition
transitionDone = function (event) {
event.stopPropagation();
self.setFocus();
// unbind event so function only gets called on... | [
"function",
"(",
"fromQueue",
")",
"{",
"var",
"item",
"=",
"queue",
"[",
"0",
"]",
",",
"self",
"=",
"this",
",",
"transitionDone",
";",
"// dialog is open",
"isopen",
"=",
"true",
";",
"// Set button focus after transition",
"transitionDone",
"=",
"function",
... | Initiate all the required pieces for the dialog box
@return {undefined} | [
"Initiate",
"all",
"the",
"required",
"pieces",
"for",
"the",
"dialog",
"box"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L550-L581 | train | |
shinuza/captain-admin | public/js/lib/alertify.js | function (el, event, fn) {
if (typeof el.removeEventListener === "function") {
el.removeEventListener(event, fn, false);
} else if (el.detachEvent) {
el.detachEvent("on" + event, fn);
}
} | javascript | function (el, event, fn) {
if (typeof el.removeEventListener === "function") {
el.removeEventListener(event, fn, false);
} else if (el.detachEvent) {
el.detachEvent("on" + event, fn);
}
} | [
"function",
"(",
"el",
",",
"event",
",",
"fn",
")",
"{",
"if",
"(",
"typeof",
"el",
".",
"removeEventListener",
"===",
"\"function\"",
")",
"{",
"el",
".",
"removeEventListener",
"(",
"event",
",",
"fn",
",",
"false",
")",
";",
"}",
"else",
"if",
"(... | Unbind events to elements
@param {Object} el HTML Object
@param {Event} event Event to detach to element
@param {Function} fn Callback function
@return {undefined} | [
"Unbind",
"events",
"to",
"elements"
] | e63408c5206d22b348580a5e1345f5da1cd1d99f | https://github.com/shinuza/captain-admin/blob/e63408c5206d22b348580a5e1345f5da1cd1d99f/public/js/lib/alertify.js#L592-L598 | train | |
YusukeHirao/sceg | lib/fn/output.js | output | function output(sourceCode, filePath) {
return new Promise(function (resolve, reject) {
mkdirp(path.dirname(filePath), function (ioErr) {
if (ioErr) {
reject(ioErr);
throw ioErr;
}
fs.writeFile(filePath, sourceCode, function (writeErr) {
... | javascript | function output(sourceCode, filePath) {
return new Promise(function (resolve, reject) {
mkdirp(path.dirname(filePath), function (ioErr) {
if (ioErr) {
reject(ioErr);
throw ioErr;
}
fs.writeFile(filePath, sourceCode, function (writeErr) {
... | [
"function",
"output",
"(",
"sourceCode",
",",
"filePath",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"mkdirp",
"(",
"path",
".",
"dirname",
"(",
"filePath",
")",
",",
"function",
"(",
"ioErr",
")",
"... | Output file by source code string
@param sourceCode Source code string
@param filePath Destination path and file name | [
"Output",
"file",
"by",
"source",
"code",
"string"
] | 4cde1e56d48dd3b604cc2ddff36b2e9de3348771 | https://github.com/YusukeHirao/sceg/blob/4cde1e56d48dd3b604cc2ddff36b2e9de3348771/lib/fn/output.js#L13-L29 | train |
amooj/node-xcheck | lib/templates.js | ValueTemplate | function ValueTemplate(type, defaultValue, validator){
this.type = type;
this.defaultValue = defaultValue;
this.validator = validator;
} | javascript | function ValueTemplate(type, defaultValue, validator){
this.type = type;
this.defaultValue = defaultValue;
this.validator = validator;
} | [
"function",
"ValueTemplate",
"(",
"type",
",",
"defaultValue",
",",
"validator",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"defaultValue",
"=",
"defaultValue",
";",
"this",
".",
"validator",
"=",
"validator",
";",
"}"
] | Creates a ValueTemplate.
@param {string} type - type of the value.
@param {Object|undefined} defaultValue - default value.
@param {Object} [validator] - value validator(reserved, not used yet).
@constructor | [
"Creates",
"a",
"ValueTemplate",
"."
] | 33b2b59f7d81a8e0421a468a405f15a19126bedf | https://github.com/amooj/node-xcheck/blob/33b2b59f7d81a8e0421a468a405f15a19126bedf/lib/templates.js#L15-L19 | train |
amooj/node-xcheck | lib/templates.js | PropertyTemplate | function PropertyTemplate(name, required, nullable, template){
this.name = name;
this.required = required;
this.nullable = nullable;
this.template = template;
} | javascript | function PropertyTemplate(name, required, nullable, template){
this.name = name;
this.required = required;
this.nullable = nullable;
this.template = template;
} | [
"function",
"PropertyTemplate",
"(",
"name",
",",
"required",
",",
"nullable",
",",
"template",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"required",
"=",
"required",
";",
"this",
".",
"nullable",
"=",
"nullable",
";",
"this",
".",
... | Creates a PropertyTemplate.
@param {object} name - property name.
@param {boolean} required - whether this property is required.
@param {boolean} nullable - whether this property value can be null.
@param {object} template - property value template.
@constructor | [
"Creates",
"a",
"PropertyTemplate",
"."
] | 33b2b59f7d81a8e0421a468a405f15a19126bedf | https://github.com/amooj/node-xcheck/blob/33b2b59f7d81a8e0421a468a405f15a19126bedf/lib/templates.js#L276-L281 | train |
frnd/metalsmith-imagecover | lib/index.js | getByFirstImage | function getByFirstImage(file, attributes) {
var $ = cheerio.load(file.contents.toString()),
img = $('img').first(),
obj = {};
if (img.length) {
_.forEach(attributes, function(attribute) {
obj[attribute] = img.attr(attribute);
});
return obj;
} else {
return undefined;
}
} | javascript | function getByFirstImage(file, attributes) {
var $ = cheerio.load(file.contents.toString()),
img = $('img').first(),
obj = {};
if (img.length) {
_.forEach(attributes, function(attribute) {
obj[attribute] = img.attr(attribute);
});
return obj;
} else {
return undefined;
}
} | [
"function",
"getByFirstImage",
"(",
"file",
",",
"attributes",
")",
"{",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"file",
".",
"contents",
".",
"toString",
"(",
")",
")",
",",
"img",
"=",
"$",
"(",
"'img'",
")",
".",
"first",
"(",
")",
",",
... | retrieve cover from file object by extracting the first image
@param {Object} file file object
@return {Object} cover | [
"retrieve",
"cover",
"from",
"file",
"object",
"by",
"extracting",
"the",
"first",
"image"
] | 7d864004027b01cab2a162bfdc523d9b148c015d | https://github.com/frnd/metalsmith-imagecover/blob/7d864004027b01cab2a162bfdc523d9b148c015d/lib/index.js#L44-L56 | train |
DarkPark/code-proxy | server/wspool.js | function ( name, socket ) {
var self = this;
// check input
if ( name && socket ) {
log('ws', 'init', name, 'connection');
// main data structure
pool[name] = {
socket: socket,
time: +new Date(),
count: 0,
active: true
};
// disable link on close
pool[name].socket.on('close', ... | javascript | function ( name, socket ) {
var self = this;
// check input
if ( name && socket ) {
log('ws', 'init', name, 'connection');
// main data structure
pool[name] = {
socket: socket,
time: +new Date(),
count: 0,
active: true
};
// disable link on close
pool[name].socket.on('close', ... | [
"function",
"(",
"name",
",",
"socket",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// check input",
"if",
"(",
"name",
"&&",
"socket",
")",
"{",
"log",
"(",
"'ws'",
",",
"'init'",
",",
"name",
",",
"'connection'",
")",
";",
"// main data structure",
"... | New WebSocket creation.
@param {String} name unique identifier for session
@param {Object} socket websocket resource
@return {Boolean} true if was deleted successfully | [
"New",
"WebSocket",
"creation",
"."
] | d281c796706e26269bac99c92d5aca7884e68e19 | https://github.com/DarkPark/code-proxy/blob/d281c796706e26269bac99c92d5aca7884e68e19/server/wspool.js#L25-L59 | train | |
DarkPark/code-proxy | server/wspool.js | function ( name ) {
// valid connection
if ( name in pool ) {
log('ws', 'exit', name, 'close');
return delete pool[name];
}
// failure
log('ws', 'del', name, 'fail to remove (invalid connection)');
return false;
} | javascript | function ( name ) {
// valid connection
if ( name in pool ) {
log('ws', 'exit', name, 'close');
return delete pool[name];
}
// failure
log('ws', 'del', name, 'fail to remove (invalid connection)');
return false;
} | [
"function",
"(",
"name",
")",
"{",
"// valid connection",
"if",
"(",
"name",
"in",
"pool",
")",
"{",
"log",
"(",
"'ws'",
",",
"'exit'",
",",
"name",
",",
"'close'",
")",
";",
"return",
"delete",
"pool",
"[",
"name",
"]",
";",
"}",
"// failure",
"log"... | Clear resources on WebSocket deletion.
@param {String} name session name
@return {Boolean} true if was deleted successfully | [
"Clear",
"resources",
"on",
"WebSocket",
"deletion",
"."
] | d281c796706e26269bac99c92d5aca7884e68e19 | https://github.com/DarkPark/code-proxy/blob/d281c796706e26269bac99c92d5aca7884e68e19/server/wspool.js#L67-L77 | train | |
DarkPark/code-proxy | server/wspool.js | function ( name ) {
// valid connection
if ( name in pool ) {
return {
active: pool[name].active,
count: pool[name].count
};
}
// failure
return {active: false};
} | javascript | function ( name ) {
// valid connection
if ( name in pool ) {
return {
active: pool[name].active,
count: pool[name].count
};
}
// failure
return {active: false};
} | [
"function",
"(",
"name",
")",
"{",
"// valid connection",
"if",
"(",
"name",
"in",
"pool",
")",
"{",
"return",
"{",
"active",
":",
"pool",
"[",
"name",
"]",
".",
"active",
",",
"count",
":",
"pool",
"[",
"name",
"]",
".",
"count",
"}",
";",
"}",
... | Detailed information of the named WebSocket instance.
@param {String} name session name
@return {{active:Boolean, count:Number}|{active:Boolean}} info | [
"Detailed",
"information",
"of",
"the",
"named",
"WebSocket",
"instance",
"."
] | d281c796706e26269bac99c92d5aca7884e68e19 | https://github.com/DarkPark/code-proxy/blob/d281c796706e26269bac99c92d5aca7884e68e19/server/wspool.js#L86-L97 | train | |
DarkPark/code-proxy | server/wspool.js | function ( name, data, response ) {
log('ws', 'send', name, data);
// store link to talk back when ready
pool[name].response = response;
// actual post
pool[name].socket.send(data);
pool[name].count++;
} | javascript | function ( name, data, response ) {
log('ws', 'send', name, data);
// store link to talk back when ready
pool[name].response = response;
// actual post
pool[name].socket.send(data);
pool[name].count++;
} | [
"function",
"(",
"name",
",",
"data",
",",
"response",
")",
"{",
"log",
"(",
"'ws'",
",",
"'send'",
",",
"name",
",",
"data",
")",
";",
"// store link to talk back when ready",
"pool",
"[",
"name",
"]",
".",
"response",
"=",
"response",
";",
"// actual pos... | Forward the request to the given session.
@param {String} name session name
@param {String} data post data from guest to host
@param {ServerResponse} response link to HTTP response object to send back data | [
"Forward",
"the",
"request",
"to",
"the",
"given",
"session",
"."
] | d281c796706e26269bac99c92d5aca7884e68e19 | https://github.com/DarkPark/code-proxy/blob/d281c796706e26269bac99c92d5aca7884e68e19/server/wspool.js#L106-L113 | train | |
conoremclaughlin/bones-boiler | server/backbone.js | function(req, res) {
if (res.locals.success) {
options.success(model, response);
} else {
options.error(model, response);
}
} | javascript | function(req, res) {
if (res.locals.success) {
options.success(model, response);
} else {
options.error(model, response);
}
} | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"if",
"(",
"res",
".",
"locals",
".",
"success",
")",
"{",
"options",
".",
"success",
"(",
"model",
",",
"response",
")",
";",
"}",
"else",
"{",
"options",
".",
"error",
"(",
"model",
",",
"response",
... | Create a route handler wrapper to call success or error. | [
"Create",
"a",
"route",
"handler",
"wrapper",
"to",
"call",
"success",
"or",
"error",
"."
] | 65e8ce58da75f0f3235342ba3c42084ded0ea450 | https://github.com/conoremclaughlin/bones-boiler/blob/65e8ce58da75f0f3235342ba3c42084ded0ea450/server/backbone.js#L22-L28 | train | |
epferrari/immutable-state | index.js | function(s){
var currentState = history[historyIndex];
if(typeof s === 'function'){
s = s( history[historyIndex].toJS() );
}
var newState = currentState.merge(s);
history = history.slice(0,historyIndex + 1);
history.push(newState);
historyIndex++;
return new Immu... | javascript | function(s){
var currentState = history[historyIndex];
if(typeof s === 'function'){
s = s( history[historyIndex].toJS() );
}
var newState = currentState.merge(s);
history = history.slice(0,historyIndex + 1);
history.push(newState);
historyIndex++;
return new Immu... | [
"function",
"(",
"s",
")",
"{",
"var",
"currentState",
"=",
"history",
"[",
"historyIndex",
"]",
";",
"if",
"(",
"typeof",
"s",
"===",
"'function'",
")",
"{",
"s",
"=",
"s",
"(",
"history",
"[",
"historyIndex",
"]",
".",
"toJS",
"(",
")",
")",
";",... | ensure that setting state via assignment performs an immutable operation | [
"ensure",
"that",
"setting",
"state",
"via",
"assignment",
"performs",
"an",
"immutable",
"operation"
] | fe510a17f2f809032a6c8a9eb2e523b60d9f0e48 | https://github.com/epferrari/immutable-state/blob/fe510a17f2f809032a6c8a9eb2e523b60d9f0e48/index.js#L24-L35 | train | |
kmalakoff/backbone-articulation | vendor/optional/backbone-relational-0.4.0.js | function( name ) {
var type = _.reduce( name.split('.'), function( memo, val ) {
return memo[ val ];
}, exports);
return type !== exports ? type: null;
} | javascript | function( name ) {
var type = _.reduce( name.split('.'), function( memo, val ) {
return memo[ val ];
}, exports);
return type !== exports ? type: null;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"type",
"=",
"_",
".",
"reduce",
"(",
"name",
".",
"split",
"(",
"'.'",
")",
",",
"function",
"(",
"memo",
",",
"val",
")",
"{",
"return",
"memo",
"[",
"val",
"]",
";",
"}",
",",
"exports",
")",
";",
... | Find a type on the global object by name. Splits name on dots.
@param {string} name | [
"Find",
"a",
"type",
"on",
"the",
"global",
"object",
"by",
"name",
".",
"Splits",
"name",
"on",
"dots",
"."
] | ce093551bab078369b5f9f4244873d108a344eb5 | https://github.com/kmalakoff/backbone-articulation/blob/ce093551bab078369b5f9f4244873d108a344eb5/vendor/optional/backbone-relational-0.4.0.js#L179-L184 | train | |
kmalakoff/backbone-articulation | vendor/optional/backbone-relational-0.4.0.js | function( model ) {
var coll = this.getCollection( model );
coll._onModelEvent( 'change:' + model.idAttribute, model, coll );
} | javascript | function( model ) {
var coll = this.getCollection( model );
coll._onModelEvent( 'change:' + model.idAttribute, model, coll );
} | [
"function",
"(",
"model",
")",
"{",
"var",
"coll",
"=",
"this",
".",
"getCollection",
"(",
"model",
")",
";",
"coll",
".",
"_onModelEvent",
"(",
"'change:'",
"+",
"model",
".",
"idAttribute",
",",
"model",
",",
"coll",
")",
";",
"}"
] | Explicitly update a model's id in it's store collection | [
"Explicitly",
"update",
"a",
"model",
"s",
"id",
"in",
"it",
"s",
"store",
"collection"
] | ce093551bab078369b5f9f4244873d108a344eb5 | https://github.com/kmalakoff/backbone-articulation/blob/ce093551bab078369b5f9f4244873d108a344eb5/vendor/optional/backbone-relational-0.4.0.js#L223-L226 | train | |
kmalakoff/backbone-articulation | vendor/optional/backbone-relational-0.4.0.js | function() {
Backbone.Relational.store.getCollection( this.instance )
.unbind( 'relational:remove', this._modelRemovedFromCollection );
Backbone.Relational.store.getCollection( this.relatedModel )
.unbind( 'relational:add', this._relatedModelAdded )
.unbind( 'relational:remove', this._relatedModel... | javascript | function() {
Backbone.Relational.store.getCollection( this.instance )
.unbind( 'relational:remove', this._modelRemovedFromCollection );
Backbone.Relational.store.getCollection( this.relatedModel )
.unbind( 'relational:add', this._relatedModelAdded )
.unbind( 'relational:remove', this._relatedModel... | [
"function",
"(",
")",
"{",
"Backbone",
".",
"Relational",
".",
"store",
".",
"getCollection",
"(",
"this",
".",
"instance",
")",
".",
"unbind",
"(",
"'relational:remove'",
",",
"this",
".",
"_modelRemovedFromCollection",
")",
";",
"Backbone",
".",
"Relational"... | Cleanup. Get reverse relation, call removeRelated on each. | [
"Cleanup",
".",
"Get",
"reverse",
"relation",
"call",
"removeRelated",
"on",
"each",
"."
] | ce093551bab078369b5f9f4244873d108a344eb5 | https://github.com/kmalakoff/backbone-articulation/blob/ce093551bab078369b5f9f4244873d108a344eb5/vendor/optional/backbone-relational-0.4.0.js#L441-L452 | train | |
campsi/campsi-service-auth | lib/passportMiddleware.js | proxyVerifyCallback | function proxyVerifyCallback (fn, args, done) {
const {callback, index} = findCallback(args);
args[index] = function (err, user) {
done(err, user, callback);
};
fn.apply(null, args);
} | javascript | function proxyVerifyCallback (fn, args, done) {
const {callback, index} = findCallback(args);
args[index] = function (err, user) {
done(err, user, callback);
};
fn.apply(null, args);
} | [
"function",
"proxyVerifyCallback",
"(",
"fn",
",",
"args",
",",
"done",
")",
"{",
"const",
"{",
"callback",
",",
"index",
"}",
"=",
"findCallback",
"(",
"args",
")",
";",
"args",
"[",
"index",
"]",
"=",
"function",
"(",
"err",
",",
"user",
")",
"{",
... | Intercepts passport callback
@param fn
@param args
@param done | [
"Intercepts",
"passport",
"callback"
] | f877626496de2288f9cfb50024accca2a88e179d | https://github.com/campsi/campsi-service-auth/blob/f877626496de2288f9cfb50024accca2a88e179d/lib/passportMiddleware.js#L10-L16 | train |
IonicaBizau/set-or-get.js | lib/index.js | SetOrGet | function SetOrGet(input, field, def) {
return input[field] = Deffy(input[field], def);
} | javascript | function SetOrGet(input, field, def) {
return input[field] = Deffy(input[field], def);
} | [
"function",
"SetOrGet",
"(",
"input",
",",
"field",
",",
"def",
")",
"{",
"return",
"input",
"[",
"field",
"]",
"=",
"Deffy",
"(",
"input",
"[",
"field",
"]",
",",
"def",
")",
";",
"}"
] | SetOrGet
Sets or gets an object field value.
@name SetOrGet
@function
@param {Object|Array} input The cache/input object.
@param {String|Number} field The field you want to update/create.
@param {Object|Array} def The default value.
@return {Object|Array} The field value. | [
"SetOrGet",
"Sets",
"or",
"gets",
"an",
"object",
"field",
"value",
"."
] | 65baa42d1188dff894a2497b4cad25bb36a757fa | https://github.com/IonicaBizau/set-or-get.js/blob/65baa42d1188dff894a2497b4cad25bb36a757fa/lib/index.js#L15-L17 | train |
kemitchell/tcp-log-client.js | index.js | proxyEvent | function proxyEvent (emitter, event, optionalCallback) {
emitter.on(event, function () {
if (optionalCallback) {
optionalCallback.apply(client, arguments)
}
client.emit(event)
})
} | javascript | function proxyEvent (emitter, event, optionalCallback) {
emitter.on(event, function () {
if (optionalCallback) {
optionalCallback.apply(client, arguments)
}
client.emit(event)
})
} | [
"function",
"proxyEvent",
"(",
"emitter",
",",
"event",
",",
"optionalCallback",
")",
"{",
"emitter",
".",
"on",
"(",
"event",
",",
"function",
"(",
")",
"{",
"if",
"(",
"optionalCallback",
")",
"{",
"optionalCallback",
".",
"apply",
"(",
"client",
",",
... | Emit events from a stream the client manages as the client's own. | [
"Emit",
"events",
"from",
"a",
"stream",
"the",
"client",
"manages",
"as",
"the",
"client",
"s",
"own",
"."
] | bce29ef06c9306db269a6f3e0de83c48def16654 | https://github.com/kemitchell/tcp-log-client.js/blob/bce29ef06c9306db269a6f3e0de83c48def16654/index.js#L109-L116 | train |
conoremclaughlin/bones-boiler | servers/Middleware.bones.js | function(parent, app) {
this.use(middleware.sanitizeHost(app));
this.use(middleware.bodyParser());
this.use(middleware.cookieParser());
this.use(middleware.fragmentRedirect());
} | javascript | function(parent, app) {
this.use(middleware.sanitizeHost(app));
this.use(middleware.bodyParser());
this.use(middleware.cookieParser());
this.use(middleware.fragmentRedirect());
} | [
"function",
"(",
"parent",
",",
"app",
")",
"{",
"this",
".",
"use",
"(",
"middleware",
".",
"sanitizeHost",
"(",
"app",
")",
")",
";",
"this",
".",
"use",
"(",
"middleware",
".",
"bodyParser",
"(",
")",
")",
";",
"this",
".",
"use",
"(",
"middlewa... | Removing validateCSRFToken to replace with connect's csrf middleware.
Double CSRF protection makes dealing with static forms difficult by default. | [
"Removing",
"validateCSRFToken",
"to",
"replace",
"with",
"connect",
"s",
"csrf",
"middleware",
".",
"Double",
"CSRF",
"protection",
"makes",
"dealing",
"with",
"static",
"forms",
"difficult",
"by",
"default",
"."
] | 65e8ce58da75f0f3235342ba3c42084ded0ea450 | https://github.com/conoremclaughlin/bones-boiler/blob/65e8ce58da75f0f3235342ba3c42084ded0ea450/servers/Middleware.bones.js#L9-L14 | train | |
skira-project/core | src/scope.js | Scope | function Scope(site, page, params) {
this.site = site
this.page = page
this.params = params || {}
this.status = 200
this._headers = {}
this.locale = site.locales.default
// Set default headers.
this.header("Content-Type", "text/html; charset=utf-8")
this.header("Connection", "close")
this.header("Server", "S... | javascript | function Scope(site, page, params) {
this.site = site
this.page = page
this.params = params || {}
this.status = 200
this._headers = {}
this.locale = site.locales.default
// Set default headers.
this.header("Content-Type", "text/html; charset=utf-8")
this.header("Connection", "close")
this.header("Server", "S... | [
"function",
"Scope",
"(",
"site",
",",
"page",
",",
"params",
")",
"{",
"this",
".",
"site",
"=",
"site",
"this",
".",
"page",
"=",
"page",
"this",
".",
"params",
"=",
"params",
"||",
"{",
"}",
"this",
".",
"status",
"=",
"200",
"this",
".",
"_he... | The state object are all variables made available to views and modules.
@param {object} site - global Skira site
@param {object} page - resolved page
@param {object} params - params parsed by the router | [
"The",
"state",
"object",
"are",
"all",
"variables",
"made",
"available",
"to",
"views",
"and",
"modules",
"."
] | 41f93199acad0118aa3d86cc15b3afea67bf2085 | https://github.com/skira-project/core/blob/41f93199acad0118aa3d86cc15b3afea67bf2085/src/scope.js#L8-L20 | train |
OpenCrisp/Crisp.EventJS | dist/crisp-event.js | function( option ) {
if ( this._self === option.exporter ) {
return;
}
if ( this._action && !this._action.test( option.action ) ) {
return;
}
if ( this._path && !this._path.test( option.path ) ) {
return;
... | javascript | function( option ) {
if ( this._self === option.exporter ) {
return;
}
if ( this._action && !this._action.test( option.action ) ) {
return;
}
if ( this._path && !this._path.test( option.path ) ) {
return;
... | [
"function",
"(",
"option",
")",
"{",
"if",
"(",
"this",
".",
"_self",
"===",
"option",
".",
"exporter",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"_action",
"&&",
"!",
"this",
".",
"_action",
".",
"test",
"(",
"option",
".",
"action",
... | execute event list
@param {external:Object} option | [
"execute",
"event",
"list"
] | f9e29899a65cf8a8ab7ba1c04a5f591a64e12059 | https://github.com/OpenCrisp/Crisp.EventJS/blob/f9e29899a65cf8a8ab7ba1c04a5f591a64e12059/dist/crisp-event.js#L415-L437 | train | |
independentgeorge/glupost | index.js | glupost | function glupost(configuration) {
const tasks = configuration.tasks || {}
const template = configuration.template || {}
// Expand template object with defaults.
expand(template, { transforms: [], dest: "." })
// Create tasks.
const names = Object.keys(tasks)
for (const name of names) {
co... | javascript | function glupost(configuration) {
const tasks = configuration.tasks || {}
const template = configuration.template || {}
// Expand template object with defaults.
expand(template, { transforms: [], dest: "." })
// Create tasks.
const names = Object.keys(tasks)
for (const name of names) {
co... | [
"function",
"glupost",
"(",
"configuration",
")",
"{",
"const",
"tasks",
"=",
"configuration",
".",
"tasks",
"||",
"{",
"}",
"const",
"template",
"=",
"configuration",
".",
"template",
"||",
"{",
"}",
"// Expand template object with defaults.",
"expand",
"(",
"t... | Create gulp tasks. | [
"Create",
"gulp",
"tasks",
"."
] | 3a66d6d460d8e63552cecf28c32dfabe98fbd689 | https://github.com/independentgeorge/glupost/blob/3a66d6d460d8e63552cecf28c32dfabe98fbd689/index.js#L40-L62 | train |
independentgeorge/glupost | index.js | compose | function compose(task) {
// Already composed action.
if (task.action)
return task.action
// 1. named task.
if (typeof task === "string")
return task
// 2. a function directly.
if (typeof task === "function")
return task.length ? task : () => Promise.resolve(task())
// 3. task ... | javascript | function compose(task) {
// Already composed action.
if (task.action)
return task.action
// 1. named task.
if (typeof task === "string")
return task
// 2. a function directly.
if (typeof task === "function")
return task.length ? task : () => Promise.resolve(task())
// 3. task ... | [
"function",
"compose",
"(",
"task",
")",
"{",
"// Already composed action.",
"if",
"(",
"task",
".",
"action",
")",
"return",
"task",
".",
"action",
"// 1. named task.",
"if",
"(",
"typeof",
"task",
"===",
"\"string\"",
")",
"return",
"task",
"// 2. a function d... | Convert task object to a function. | [
"Convert",
"task",
"object",
"to",
"a",
"function",
"."
] | 3a66d6d460d8e63552cecf28c32dfabe98fbd689 | https://github.com/independentgeorge/glupost/blob/3a66d6d460d8e63552cecf28c32dfabe98fbd689/index.js#L66-L120 | train |
independentgeorge/glupost | index.js | pipify | function pipify(task) {
const options = task.base ? { base: task.base } : {}
let stream = gulp.src(task.src, options)
// This is used to abort any further transforms in case of error.
const state = { error: false }
for (const transform of task.transforms)
stream = stream.pipe(transform.pipe ? t... | javascript | function pipify(task) {
const options = task.base ? { base: task.base } : {}
let stream = gulp.src(task.src, options)
// This is used to abort any further transforms in case of error.
const state = { error: false }
for (const transform of task.transforms)
stream = stream.pipe(transform.pipe ? t... | [
"function",
"pipify",
"(",
"task",
")",
"{",
"const",
"options",
"=",
"task",
".",
"base",
"?",
"{",
"base",
":",
"task",
".",
"base",
"}",
":",
"{",
"}",
"let",
"stream",
"=",
"gulp",
".",
"src",
"(",
"task",
".",
"src",
",",
"options",
")",
"... | Convert transform functions to a Stream. | [
"Convert",
"transform",
"functions",
"to",
"a",
"Stream",
"."
] | 3a66d6d460d8e63552cecf28c32dfabe98fbd689 | https://github.com/independentgeorge/glupost/blob/3a66d6d460d8e63552cecf28c32dfabe98fbd689/index.js#L124-L144 | train |
independentgeorge/glupost | index.js | pluginate | function pluginate(transform, state) {
return through.obj((file, encoding, done) => {
// Nothing to transform.
if (file.isNull() || state.error) {
done(null, file)
return
}
// Transform function returns a vinyl file or file contents (in form of a
// stream, a buffer... | javascript | function pluginate(transform, state) {
return through.obj((file, encoding, done) => {
// Nothing to transform.
if (file.isNull() || state.error) {
done(null, file)
return
}
// Transform function returns a vinyl file or file contents (in form of a
// stream, a buffer... | [
"function",
"pluginate",
"(",
"transform",
",",
"state",
")",
"{",
"return",
"through",
".",
"obj",
"(",
"(",
"file",
",",
"encoding",
",",
"done",
")",
"=>",
"{",
"// Nothing to transform.",
"if",
"(",
"file",
".",
"isNull",
"(",
")",
"||",
"state",
"... | Convert a string transform function into a stream. | [
"Convert",
"a",
"string",
"transform",
"function",
"into",
"a",
"stream",
"."
] | 3a66d6d460d8e63552cecf28c32dfabe98fbd689 | https://github.com/independentgeorge/glupost/blob/3a66d6d460d8e63552cecf28c32dfabe98fbd689/index.js#L148-L185 | train |
independentgeorge/glupost | index.js | watch | function watch(tasks) {
if (tasks["watch"]) {
console.warn("`watch` task redefined.")
return
}
const names = Object.keys(tasks).filter((name) => tasks[name].watch)
if (!names.length)
return
gulp.task("watch", () => {
for (const name of names) {
const glob = tasks[name... | javascript | function watch(tasks) {
if (tasks["watch"]) {
console.warn("`watch` task redefined.")
return
}
const names = Object.keys(tasks).filter((name) => tasks[name].watch)
if (!names.length)
return
gulp.task("watch", () => {
for (const name of names) {
const glob = tasks[name... | [
"function",
"watch",
"(",
"tasks",
")",
"{",
"if",
"(",
"tasks",
"[",
"\"watch\"",
"]",
")",
"{",
"console",
".",
"warn",
"(",
"\"`watch` task redefined.\"",
")",
"return",
"}",
"const",
"names",
"=",
"Object",
".",
"keys",
"(",
"tasks",
")",
".",
"fil... | Create the watch task if declared and triggered. Only top level tasks may be watched. | [
"Create",
"the",
"watch",
"task",
"if",
"declared",
"and",
"triggered",
".",
"Only",
"top",
"level",
"tasks",
"may",
"be",
"watched",
"."
] | 3a66d6d460d8e63552cecf28c32dfabe98fbd689 | https://github.com/independentgeorge/glupost/blob/3a66d6d460d8e63552cecf28c32dfabe98fbd689/index.js#L190-L210 | train |
independentgeorge/glupost | index.js | expand | function expand(to, from) {
const keys = Object.keys(from)
for (const key of keys) {
if (!to.hasOwnProperty(key))
to[key] = from[key]
}
} | javascript | function expand(to, from) {
const keys = Object.keys(from)
for (const key of keys) {
if (!to.hasOwnProperty(key))
to[key] = from[key]
}
} | [
"function",
"expand",
"(",
"to",
",",
"from",
")",
"{",
"const",
"keys",
"=",
"Object",
".",
"keys",
"(",
"from",
")",
"for",
"(",
"const",
"key",
"of",
"keys",
")",
"{",
"if",
"(",
"!",
"to",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"to",
... | Add new properties on `from` to `to`. | [
"Add",
"new",
"properties",
"on",
"from",
"to",
"to",
"."
] | 3a66d6d460d8e63552cecf28c32dfabe98fbd689 | https://github.com/independentgeorge/glupost/blob/3a66d6d460d8e63552cecf28c32dfabe98fbd689/index.js#L215-L223 | train |
Qwerios/madlib-hostmapping | lib/index.js | HostMapping | function HostMapping(settings) {
settings.init("hostConfig", {});
settings.init("hostMapping", {});
settings.init("xdmConfig", {});
this.settings = settings;
} | javascript | function HostMapping(settings) {
settings.init("hostConfig", {});
settings.init("hostMapping", {});
settings.init("xdmConfig", {});
this.settings = settings;
} | [
"function",
"HostMapping",
"(",
"settings",
")",
"{",
"settings",
".",
"init",
"(",
"\"hostConfig\"",
",",
"{",
"}",
")",
";",
"settings",
".",
"init",
"(",
"\"hostMapping\"",
",",
"{",
"}",
")",
";",
"settings",
".",
"init",
"(",
"\"xdmConfig\"",
",",
... | The class constructor. You need to supply your instance of madlib-settings
@function constructor
@params settings {Object} madlib-settings instance
@return None | [
"The",
"class",
"constructor",
".",
"You",
"need",
"to",
"supply",
"your",
"instance",
"of",
"madlib",
"-",
"settings"
] | 88c87657e8739c4446ff80ed5b6b91fce892c9a3 | https://github.com/Qwerios/madlib-hostmapping/blob/88c87657e8739c4446ff80ed5b6b91fce892c9a3/lib/index.js#L33-L38 | train |
Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/utils.js | decorateWithCollation | function decorateWithCollation(command, target, options) {
const topology = target.s && target.s.topology;
if (!topology) {
throw new TypeError('parameter "target" is missing a topology');
}
const capabilities = target.s.topology.capabilities();
if (options.collation && typeof options.collation === 'obj... | javascript | function decorateWithCollation(command, target, options) {
const topology = target.s && target.s.topology;
if (!topology) {
throw new TypeError('parameter "target" is missing a topology');
}
const capabilities = target.s.topology.capabilities();
if (options.collation && typeof options.collation === 'obj... | [
"function",
"decorateWithCollation",
"(",
"command",
",",
"target",
",",
"options",
")",
"{",
"const",
"topology",
"=",
"target",
".",
"s",
"&&",
"target",
".",
"s",
".",
"topology",
";",
"if",
"(",
"!",
"topology",
")",
"{",
"throw",
"new",
"TypeError",... | Applies collation to a given command.
@param {object} [command] the command on which to apply collation
@param {(Cursor|Collection)} [target] target of command
@param {object} [options] options containing collation settings | [
"Applies",
"collation",
"to",
"a",
"given",
"command",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/utils.js#L584-L599 | train |
tandrewnichols/indeed | lib/expect.js | function(fn) {
// Save off the existing spy method as __functionName
var newName = '__' + fn;
self[newName] = self[fn];
// This is the actual function that will be called when,
// for example, calledWith() is invoked
return function() {
var func = self[newName]... | javascript | function(fn) {
// Save off the existing spy method as __functionName
var newName = '__' + fn;
self[newName] = self[fn];
// This is the actual function that will be called when,
// for example, calledWith() is invoked
return function() {
var func = self[newName]... | [
"function",
"(",
"fn",
")",
"{",
"// Save off the existing spy method as __functionName",
"var",
"newName",
"=",
"'__'",
"+",
"fn",
";",
"self",
"[",
"newName",
"]",
"=",
"self",
"[",
"fn",
"]",
";",
"// This is the actual function that will be called when,",
"// for ... | Wrapper to create a function for negating spy methods | [
"Wrapper",
"to",
"create",
"a",
"function",
"for",
"negating",
"spy",
"methods"
] | d29d4c17d8b7c063cccd3c1dfd7c571603a187b2 | https://github.com/tandrewnichols/indeed/blob/d29d4c17d8b7c063cccd3c1dfd7c571603a187b2/lib/expect.js#L31-L48 | train | |
GuillaumeIsabelleX/gixdeko | src/nodejs/gixdeko/gixdeko.js | function (decorator, txt) {
var decostr = "@" + decorator;
var r = txt
.replace(decostr, "")
.trim()
;
if (debug) console.log(`Cleaning deco: ${decorator} in ${txt}
Result: ${r}
`);
return r;
} | javascript | function (decorator, txt) {
var decostr = "@" + decorator;
var r = txt
.replace(decostr, "")
.trim()
;
if (debug) console.log(`Cleaning deco: ${decorator} in ${txt}
Result: ${r}
`);
return r;
} | [
"function",
"(",
"decorator",
",",
"txt",
")",
"{",
"var",
"decostr",
"=",
"\"@\"",
"+",
"decorator",
";",
"var",
"r",
"=",
"txt",
".",
"replace",
"(",
"decostr",
",",
"\"\"",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"debug",
")",
"console",
"... | Clean a string of a deko
@param {*} decorator
@param {*} txt | [
"Clean",
"a",
"string",
"of",
"a",
"deko"
] | 6762c04a27af8ff89e2bc3e53fc01b07b70afc9e | https://github.com/GuillaumeIsabelleX/gixdeko/blob/6762c04a27af8ff89e2bc3e53fc01b07b70afc9e/src/nodejs/gixdeko/gixdeko.js#L132-L144 | train | |
GuillaumeIsabelleX/gixdeko | src/nodejs/gixdeko/gixdeko.js | extractDecorator2 | function extractDecorator2(text) {
try {
var email =
text.match(reSTCDeco);
// console.log("DEBUG: reSTCDeco:" + email);
var deco = email[0].split('@')[1];
return deco;
} catch (error) {
return "";
}
// return text.match(/([a-zA-Z0-9._-]+@... | javascript | function extractDecorator2(text) {
try {
var email =
text.match(reSTCDeco);
// console.log("DEBUG: reSTCDeco:" + email);
var deco = email[0].split('@')[1];
return deco;
} catch (error) {
return "";
}
// return text.match(/([a-zA-Z0-9._-]+@... | [
"function",
"extractDecorator2",
"(",
"text",
")",
"{",
"try",
"{",
"var",
"email",
"=",
"text",
".",
"match",
"(",
"reSTCDeco",
")",
";",
"// console.log(\"DEBUG: reSTCDeco:\" + email);\r",
"var",
"deco",
"=",
"email",
"[",
"0",
"]",
".",
"split",
"(",
"'@... | extraction decorator logics
@param {*} text | [
"extraction",
"decorator",
"logics"
] | 6762c04a27af8ff89e2bc3e53fc01b07b70afc9e | https://github.com/GuillaumeIsabelleX/gixdeko/blob/6762c04a27af8ff89e2bc3e53fc01b07b70afc9e/src/nodejs/gixdeko/gixdeko.js#L175-L187 | train |
Nichejs/Seminarjs | private/lib/core/mount.js | function (err, req, res, next) {
if (seminarjs.get('logger')) {
if (err instanceof Error) {
console.log((err.type ? err.type + ' ' : '') + 'Error thrown for request: ' + req.url);
} else {
console.log('Error thrown for request: ' + req.url);
}
console.log(err.stack || err);
}
var ms... | javascript | function (err, req, res, next) {
if (seminarjs.get('logger')) {
if (err instanceof Error) {
console.log((err.type ? err.type + ' ' : '') + 'Error thrown for request: ' + req.url);
} else {
console.log('Error thrown for request: ' + req.url);
}
console.log(err.stack || err);
}
var ms... | [
"function",
"(",
"err",
",",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"seminarjs",
".",
"get",
"(",
"'logger'",
")",
")",
"{",
"if",
"(",
"err",
"instanceof",
"Error",
")",
"{",
"console",
".",
"log",
"(",
"(",
"err",
".",
"type",
"... | Handle other errors | [
"Handle",
"other",
"errors"
] | 53c4c1d5c33ffbf6320b10f25679bf181cbf853e | https://github.com/Nichejs/Seminarjs/blob/53c4c1d5c33ffbf6320b10f25679bf181cbf853e/private/lib/core/mount.js#L447-L475 | train | |
richRemer/twixt-mutant | mutant.js | Mutant | function Mutant(obj) {
var triggered,
i = 0;
mutations = {};
if (!obj.addEventListener) {
obj = EventTarget(obj);
}
function trigger() {
i++;
if (triggered) return;
triggered = setTimeout(function() {
var evt = new Mutat... | javascript | function Mutant(obj) {
var triggered,
i = 0;
mutations = {};
if (!obj.addEventListener) {
obj = EventTarget(obj);
}
function trigger() {
i++;
if (triggered) return;
triggered = setTimeout(function() {
var evt = new Mutat... | [
"function",
"Mutant",
"(",
"obj",
")",
"{",
"var",
"triggered",
",",
"i",
"=",
"0",
";",
"mutations",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"obj",
".",
"addEventListener",
")",
"{",
"obj",
"=",
"EventTarget",
"(",
"obj",
")",
";",
"}",
"function",
... | Create a object proxy that dispatches mutation events.
@param {object} obj
@returns {Mutant} | [
"Create",
"a",
"object",
"proxy",
"that",
"dispatches",
"mutation",
"events",
"."
] | 13f91844dc794dc01475fd6ed720735e16b748bf | https://github.com/richRemer/twixt-mutant/blob/13f91844dc794dc01475fd6ed720735e16b748bf/mutant.js#L10-L71 | train |
richRemer/twixt-mutant | mutant.js | mutant | function mutant(obj) {
if (!proxies.has(obj)) {
proxies.set(obj, Mutant(obj));
}
return proxies.get(obj);
} | javascript | function mutant(obj) {
if (!proxies.has(obj)) {
proxies.set(obj, Mutant(obj));
}
return proxies.get(obj);
} | [
"function",
"mutant",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"proxies",
".",
"has",
"(",
"obj",
")",
")",
"{",
"proxies",
".",
"set",
"(",
"obj",
",",
"Mutant",
"(",
"obj",
")",
")",
";",
"}",
"return",
"proxies",
".",
"get",
"(",
"obj",
")",
... | Return a Mutant proxy for the object.
@param {object} obj
@returns {Mutant} | [
"Return",
"a",
"Mutant",
"proxy",
"for",
"the",
"object",
"."
] | 13f91844dc794dc01475fd6ed720735e16b748bf | https://github.com/richRemer/twixt-mutant/blob/13f91844dc794dc01475fd6ed720735e16b748bf/mutant.js#L78-L84 | train |
robbyoconnor/tictactoe.js | lib/utils.js | ask | function ask(question, validValues, message) {
readline.setDefaultOptions({
limit: validValues,
limitMessage: message
});
return readline.question(question);
} | javascript | function ask(question, validValues, message) {
readline.setDefaultOptions({
limit: validValues,
limitMessage: message
});
return readline.question(question);
} | [
"function",
"ask",
"(",
"question",
",",
"validValues",
",",
"message",
")",
"{",
"readline",
".",
"setDefaultOptions",
"(",
"{",
"limit",
":",
"validValues",
",",
"limitMessage",
":",
"message",
"}",
")",
";",
"return",
"readline",
".",
"question",
"(",
"... | A helper function for getting user input
@param {string} question The question to be asked
@param {string} validValues Typically a regex or array
@param {string} message The validation message
@returns {string} the user input | [
"A",
"helper",
"function",
"for",
"getting",
"user",
"input"
] | 1fc5850aaa9477e79027cdc5a19fc2202612980c | https://github.com/robbyoconnor/tictactoe.js/blob/1fc5850aaa9477e79027cdc5a19fc2202612980c/lib/utils.js#L20-L26 | train |
robbyoconnor/tictactoe.js | lib/utils.js | color | function color(c, bold, msg) {
return bold ? clic.xterm(c).bold(msg) : clic.xterm(c)(msg);
} | javascript | function color(c, bold, msg) {
return bold ? clic.xterm(c).bold(msg) : clic.xterm(c)(msg);
} | [
"function",
"color",
"(",
"c",
",",
"bold",
",",
"msg",
")",
"{",
"return",
"bold",
"?",
"clic",
".",
"xterm",
"(",
"c",
")",
".",
"bold",
"(",
"msg",
")",
":",
"clic",
".",
"xterm",
"(",
"c",
")",
"(",
"msg",
")",
";",
"}"
] | Returns ANSI color strings for pretty CLI output
@param {string} c
@param {boolean} bold
@param {string} msg
@returns {string} the ANSI color string | [
"Returns",
"ANSI",
"color",
"strings",
"for",
"pretty",
"CLI",
"output"
] | 1fc5850aaa9477e79027cdc5a19fc2202612980c | https://github.com/robbyoconnor/tictactoe.js/blob/1fc5850aaa9477e79027cdc5a19fc2202612980c/lib/utils.js#L36-L38 | train |
springload/rikki-patterns | src/scripts/tasks/site.js | renderState | function renderState(env, stateDir, nav, componentData, state) {
const statePath = Path.join(stateDir, 'index.html');
const raw = env.render('component-raw.html', {
navigation: nav,
component: componentData,
state: state,
config: config,
tokens: getTokens(),
});
... | javascript | function renderState(env, stateDir, nav, componentData, state) {
const statePath = Path.join(stateDir, 'index.html');
const raw = env.render('component-raw.html', {
navigation: nav,
component: componentData,
state: state,
config: config,
tokens: getTokens(),
});
... | [
"function",
"renderState",
"(",
"env",
",",
"stateDir",
",",
"nav",
",",
"componentData",
",",
"state",
")",
"{",
"const",
"statePath",
"=",
"Path",
".",
"join",
"(",
"stateDir",
",",
"'index.html'",
")",
";",
"const",
"raw",
"=",
"env",
".",
"render",
... | Renders the `raw` view of each component's state | [
"Renders",
"the",
"raw",
"view",
"of",
"each",
"component",
"s",
"state"
] | 9906f69f9a29f587911ff66cf997fcf2f4f90452 | https://github.com/springload/rikki-patterns/blob/9906f69f9a29f587911ff66cf997fcf2f4f90452/src/scripts/tasks/site.js#L64-L77 | train |
springload/rikki-patterns | src/scripts/tasks/site.js | renderDocs | function renderDocs(SITE_DIR, name) {
const env = templates.configure();
const nav = navigation.getNavigation();
const components = _.find(nav.children, { id: name });
components.children.forEach(component => {
const dirPath = Path.join(SITE_DIR, component.path);
console.log(dirPath);
... | javascript | function renderDocs(SITE_DIR, name) {
const env = templates.configure();
const nav = navigation.getNavigation();
const components = _.find(nav.children, { id: name });
components.children.forEach(component => {
const dirPath = Path.join(SITE_DIR, component.path);
console.log(dirPath);
... | [
"function",
"renderDocs",
"(",
"SITE_DIR",
",",
"name",
")",
"{",
"const",
"env",
"=",
"templates",
".",
"configure",
"(",
")",
";",
"const",
"nav",
"=",
"navigation",
".",
"getNavigation",
"(",
")",
";",
"const",
"components",
"=",
"_",
".",
"find",
"... | Renders the documentation for each component | [
"Renders",
"the",
"documentation",
"for",
"each",
"component"
] | 9906f69f9a29f587911ff66cf997fcf2f4f90452 | https://github.com/springload/rikki-patterns/blob/9906f69f9a29f587911ff66cf997fcf2f4f90452/src/scripts/tasks/site.js#L80-L139 | train |
jdmota/mota-webdevtools | src/findFiles.js | function( string ) {
var negated, matches, patterns = this.patterns, i = patterns.length;
while ( i-- ) {
negated = patterns[ i ].negated;
matches = patterns[ i ].matcher( string );
if ( negated !== matches ) {
return matches;
}
}
return false;
} | javascript | function( string ) {
var negated, matches, patterns = this.patterns, i = patterns.length;
while ( i-- ) {
negated = patterns[ i ].negated;
matches = patterns[ i ].matcher( string );
if ( negated !== matches ) {
return matches;
}
}
return false;
} | [
"function",
"(",
"string",
")",
"{",
"var",
"negated",
",",
"matches",
",",
"patterns",
"=",
"this",
".",
"patterns",
",",
"i",
"=",
"patterns",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"negated",
"=",
"patterns",
"[",
"i",
"]",
".",
... | We start from the end negated matches 0 0 keep going 0 1 return true 1 0 return false 1 1 keep going | [
"We",
"start",
"from",
"the",
"end",
"negated",
"matches",
"0",
"0",
"keep",
"going",
"0",
"1",
"return",
"true",
"1",
"0",
"return",
"false",
"1",
"1",
"keep",
"going"
] | 7ecba6bee3ce83cec33931380b9dc1f63aa6904a | https://github.com/jdmota/mota-webdevtools/blob/7ecba6bee3ce83cec33931380b9dc1f63aa6904a/src/findFiles.js#L33-L43 | train | |
shinuza/captain-core | lib/models/users.js | find | function find(param) {
var fn, asInt = parseInt(param, 10);
fn = isNaN(asInt) ? findByUsername : findById;
fn.apply(null, arguments);
} | javascript | function find(param) {
var fn, asInt = parseInt(param, 10);
fn = isNaN(asInt) ? findByUsername : findById;
fn.apply(null, arguments);
} | [
"function",
"find",
"(",
"param",
")",
"{",
"var",
"fn",
",",
"asInt",
"=",
"parseInt",
"(",
"param",
",",
"10",
")",
";",
"fn",
"=",
"isNaN",
"(",
"asInt",
")",
"?",
"findByUsername",
":",
"findById",
";",
"fn",
".",
"apply",
"(",
"null",
",",
"... | Smart find, uses findByUsername or findBy
@param {*} param | [
"Smart",
"find",
"uses",
"findByUsername",
"or",
"findBy"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/users.js#L44-L48 | train |
shinuza/captain-core | lib/models/users.js | findByCredentials | function findByCredentials(username, password, cb) {
crypto.encode(password, function(err, encoded) {
if(err) { return cb(err); }
db.getClient(function(err, client, done) {
client.query(SELECT_CREDENTIALS, [username, encoded], function(err, r) {
var result = r && r.rows[0];
if(!err && !... | javascript | function findByCredentials(username, password, cb) {
crypto.encode(password, function(err, encoded) {
if(err) { return cb(err); }
db.getClient(function(err, client, done) {
client.query(SELECT_CREDENTIALS, [username, encoded], function(err, r) {
var result = r && r.rows[0];
if(!err && !... | [
"function",
"findByCredentials",
"(",
"username",
",",
"password",
",",
"cb",
")",
"{",
"crypto",
".",
"encode",
"(",
"password",
",",
"function",
"(",
"err",
",",
"encoded",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",... | Finds a user by `username` and `password`
`cb` is passed with the matching user or exceptions.AuthenticationFailed
@param {String} username
@param {String} password
@param {Function} cb | [
"Finds",
"a",
"user",
"by",
"username",
"and",
"password"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/users.js#L61-L79 | train |
shinuza/captain-core | lib/models/users.js | findByUsername | function findByUsername(username, cb) {
db.getClient(function(err, client, done) {
client.query(SELECT_USERNAME, [username], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) { err = new exceptions.NotFound(); }
if(err) {
cb(err);
done(err);
} else {
... | javascript | function findByUsername(username, cb) {
db.getClient(function(err, client, done) {
client.query(SELECT_USERNAME, [username], function(err, r) {
var result = r && r.rows[0];
if(!err && !result) { err = new exceptions.NotFound(); }
if(err) {
cb(err);
done(err);
} else {
... | [
"function",
"findByUsername",
"(",
"username",
",",
"cb",
")",
"{",
"db",
".",
"getClient",
"(",
"function",
"(",
"err",
",",
"client",
",",
"done",
")",
"{",
"client",
".",
"query",
"(",
"SELECT_USERNAME",
",",
"[",
"username",
"]",
",",
"function",
"... | Finds a user by `username`
`cb` is passed with the matching user or exceptions.NotFound
@param {String} username
@param {Function} cb | [
"Finds",
"a",
"user",
"by",
"username"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/users.js#L91-L105 | train |
shinuza/captain-core | lib/models/users.js | update | function update(id, body, cb) {
if(body.password) {
crypto.encode(body.password, function(err, encoded) {
if(err) { return cb(err); }
body.password = encoded;
_update(id, body, cb);
});
} else {
_update(id, body, cb);
}
} | javascript | function update(id, body, cb) {
if(body.password) {
crypto.encode(body.password, function(err, encoded) {
if(err) { return cb(err); }
body.password = encoded;
_update(id, body, cb);
});
} else {
_update(id, body, cb);
}
} | [
"function",
"update",
"(",
"id",
",",
"body",
",",
"cb",
")",
"{",
"if",
"(",
"body",
".",
"password",
")",
"{",
"crypto",
".",
"encode",
"(",
"body",
".",
"password",
",",
"function",
"(",
"err",
",",
"encoded",
")",
"{",
"if",
"(",
"err",
")",
... | Updates user with `id`
`cb` is passed with the updated user or:
* exceptions.NotFound if the `id` is not found in the database
* exceptions.AlreadyExists if the `username` conflicts with another user
@param {Number} id
@param {Object} body
@param {Function} cb | [
"Updates",
"user",
"with",
"id"
] | 02f3a404cdfca608e8726bbacc33e32fec484b21 | https://github.com/shinuza/captain-core/blob/02f3a404cdfca608e8726bbacc33e32fec484b21/lib/models/users.js#L190-L200 | train |
kriserickson/generator-topcoat-touch | app/templates/_app.js | createPlaceHolder | function createPlaceHolder($page, type) {
var placeHolders = { kittens : 'placekitten.com', bears: 'placebear.com', lorem: 'lorempixel.com',
bacon: 'baconmockup.com', murray: 'www.fillmurray.com'};
var gallery = '';
for (var i = 0; i < getRandomInt(50,100); i++) {
gallery... | javascript | function createPlaceHolder($page, type) {
var placeHolders = { kittens : 'placekitten.com', bears: 'placebear.com', lorem: 'lorempixel.com',
bacon: 'baconmockup.com', murray: 'www.fillmurray.com'};
var gallery = '';
for (var i = 0; i < getRandomInt(50,100); i++) {
gallery... | [
"function",
"createPlaceHolder",
"(",
"$page",
",",
"type",
")",
"{",
"var",
"placeHolders",
"=",
"{",
"kittens",
":",
"'placekitten.com'",
",",
"bears",
":",
"'placebear.com'",
",",
"lorem",
":",
"'lorempixel.com'",
",",
"bacon",
":",
"'baconmockup.com'",
",",
... | Create the placeholders in the gallery... | [
"Create",
"the",
"placeholders",
"in",
"the",
"gallery",
"..."
] | 47d0f95ccfb7ab3c20feb7ed12158b872caac1e3 | https://github.com/kriserickson/generator-topcoat-touch/blob/47d0f95ccfb7ab3c20feb7ed12158b872caac1e3/app/templates/_app.js#L116-L127 | train |
el-fuego/grunt-concat-properties | tasks/lib/writer.js | addToJSONRecursively | function addToJSONRecursively(contextNames, data, obj) {
var currentContexName = contextNames.shift();
// last name
if (!contextNames.length) {
obj[currentContexName] = data;
return;
}
if (!obj[currentContexName]) {
obj[currentContexName] = {... | javascript | function addToJSONRecursively(contextNames, data, obj) {
var currentContexName = contextNames.shift();
// last name
if (!contextNames.length) {
obj[currentContexName] = data;
return;
}
if (!obj[currentContexName]) {
obj[currentContexName] = {... | [
"function",
"addToJSONRecursively",
"(",
"contextNames",
",",
"data",
",",
"obj",
")",
"{",
"var",
"currentContexName",
"=",
"contextNames",
".",
"shift",
"(",
")",
";",
"// last name",
"if",
"(",
"!",
"contextNames",
".",
"length",
")",
"{",
"obj",
"[",
"... | Add data to object at specified context
obj.a.b.c = data;
@param contextNames [{String}] f.e. ['a', 'b', 'c'..]
@param data {String} data to set
@param obj {Object} changable | [
"Add",
"data",
"to",
"object",
"at",
"specified",
"context",
"obj",
".",
"a",
".",
"b",
".",
"c",
"=",
"data",
";"
] | a7efad68106d81aec262deee12190c75952f09b3 | https://github.com/el-fuego/grunt-concat-properties/blob/a7efad68106d81aec262deee12190c75952f09b3/tasks/lib/writer.js#L23-L37 | train |
el-fuego/grunt-concat-properties | tasks/lib/writer.js | propertyToString | function propertyToString(property) {
return property.comment +
utils.addQuotes(property.name.split('.').pop()) +
': ' +
(
typeof options.sourceProcessor === 'function' ?
options.sourceProcessor(property.source, property) :
... | javascript | function propertyToString(property) {
return property.comment +
utils.addQuotes(property.name.split('.').pop()) +
': ' +
(
typeof options.sourceProcessor === 'function' ?
options.sourceProcessor(property.source, property) :
... | [
"function",
"propertyToString",
"(",
"property",
")",
"{",
"return",
"property",
".",
"comment",
"+",
"utils",
".",
"addQuotes",
"(",
"property",
".",
"name",
".",
"split",
"(",
"'.'",
")",
".",
"pop",
"(",
")",
")",
"+",
"': '",
"+",
"(",
"typeof",
... | Concat property data to local definition as object method or attribute
@param property {Object}
@returns {string} | [
"Concat",
"property",
"data",
"to",
"local",
"definition",
"as",
"object",
"method",
"or",
"attribute"
] | a7efad68106d81aec262deee12190c75952f09b3 | https://github.com/el-fuego/grunt-concat-properties/blob/a7efad68106d81aec262deee12190c75952f09b3/tasks/lib/writer.js#L44-L54 | train |
el-fuego/grunt-concat-properties | tasks/lib/writer.js | stringifyJSONProperties | function stringifyJSONProperties(obj) {
var i,
properties = [];
for (i in obj) {
properties.push(
typeof obj[i] === 'string' ?
obj[i] :
utils.addQuotes(i) + ': ' + stringifyJSONProperties(obj[i])
);
... | javascript | function stringifyJSONProperties(obj) {
var i,
properties = [];
for (i in obj) {
properties.push(
typeof obj[i] === 'string' ?
obj[i] :
utils.addQuotes(i) + ': ' + stringifyJSONProperties(obj[i])
);
... | [
"function",
"stringifyJSONProperties",
"(",
"obj",
")",
"{",
"var",
"i",
",",
"properties",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"in",
"obj",
")",
"{",
"properties",
".",
"push",
"(",
"typeof",
"obj",
"[",
"i",
"]",
"===",
"'string'",
"?",
"obj",
"... | Concat properties object to string
@param obj {Object} properties as object f.e. {a: {b: '...'}}
@returns {String} | [
"Concat",
"properties",
"object",
"to",
"string"
] | a7efad68106d81aec262deee12190c75952f09b3 | https://github.com/el-fuego/grunt-concat-properties/blob/a7efad68106d81aec262deee12190c75952f09b3/tasks/lib/writer.js#L61-L74 | train |
el-fuego/grunt-concat-properties | tasks/lib/writer.js | addPropertiesToText | function addPropertiesToText(text, properties, filePath) {
if (!properties.length) {
return text;
}
var placeRegexp = patterns.getPlacePattern(properties[0].isFromPrototype),
matchedData = placeRegexp.exec(text);
// Can`t find properties place
if (!matc... | javascript | function addPropertiesToText(text, properties, filePath) {
if (!properties.length) {
return text;
}
var placeRegexp = patterns.getPlacePattern(properties[0].isFromPrototype),
matchedData = placeRegexp.exec(text);
// Can`t find properties place
if (!matc... | [
"function",
"addPropertiesToText",
"(",
"text",
",",
"properties",
",",
"filePath",
")",
"{",
"if",
"(",
"!",
"properties",
".",
"length",
")",
"{",
"return",
"text",
";",
"}",
"var",
"placeRegexp",
"=",
"patterns",
".",
"getPlacePattern",
"(",
"properties",... | Replace place pattern with concated properties
@param text {String}
@param properties {Array}
@param filePath {String}
@returns {String} | [
"Replace",
"place",
"pattern",
"with",
"concated",
"properties"
] | a7efad68106d81aec262deee12190c75952f09b3 | https://github.com/el-fuego/grunt-concat-properties/blob/a7efad68106d81aec262deee12190c75952f09b3/tasks/lib/writer.js#L119-L142 | train |
rich-97/are-arrays | are-arrays.js | areArrays | function areArrays () {
for (let i = 0; i < arguments.length; i++) {
if (!Array.isArray(arguments[i])) {
return false;
}
}
return true;
} | javascript | function areArrays () {
for (let i = 0; i < arguments.length; i++) {
if (!Array.isArray(arguments[i])) {
return false;
}
}
return true;
} | [
"function",
"areArrays",
"(",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"arguments",
"[",
"i",
"]",
")",
")",
"{",
"return",
... | areArrays
This takes any parameters
@returns {boolean} | [
"areArrays",
"This",
"takes",
"any",
"parameters"
] | af8d15d3768b26d9de290fed208c97ea3c1e068e | https://github.com/rich-97/are-arrays/blob/af8d15d3768b26d9de290fed208c97ea3c1e068e/are-arrays.js#L17-L25 | train |
numbervine/misc-utils | dist/index.es.js | deepDiff | function deepDiff(obj1, obj2, path) {
return merge_1(_deepDiff(obj1, obj2, path), _deepDiff(obj2, obj1, path));
} | javascript | function deepDiff(obj1, obj2, path) {
return merge_1(_deepDiff(obj1, obj2, path), _deepDiff(obj2, obj1, path));
} | [
"function",
"deepDiff",
"(",
"obj1",
",",
"obj2",
",",
"path",
")",
"{",
"return",
"merge_1",
"(",
"_deepDiff",
"(",
"obj1",
",",
"obj2",
",",
"path",
")",
",",
"_deepDiff",
"(",
"obj2",
",",
"obj1",
",",
"path",
")",
")",
";",
"}"
] | Compares key value paris between `obj1` and `obj2` recursively, optionally
starting from the node specified by `path` and returns an array of paths
that are not shared by both objects, or contain different values
@since 1.0.0
@category Misc
@param {Object} obj1 First object for comparison
@param {Object} obj2 Second o... | [
"Compares",
"key",
"value",
"paris",
"between",
"obj1",
"and",
"obj2",
"recursively",
"optionally",
"starting",
"from",
"the",
"node",
"specified",
"by",
"path",
"and",
"returns",
"an",
"array",
"of",
"paths",
"that",
"are",
"not",
"shared",
"by",
"both",
"o... | 763c2d646090ec6a74fda0d465b8124a9cf62a41 | https://github.com/numbervine/misc-utils/blob/763c2d646090ec6a74fda0d465b8124a9cf62a41/dist/index.es.js#L4476-L4478 | train |
recursivefunk/nyce | lib/validate.js | checkFunctions | function checkFunctions (impl, schema) {
const children = schema.describe().children
const ret = { ok: true }
for (let i in children) {
if (impl.hasOwnProperty(i) && children.hasOwnProperty(i)) {
if (children[ i ].flags && children[ i ].flags.func === true) {
const func = impl[ i ]
const... | javascript | function checkFunctions (impl, schema) {
const children = schema.describe().children
const ret = { ok: true }
for (let i in children) {
if (impl.hasOwnProperty(i) && children.hasOwnProperty(i)) {
if (children[ i ].flags && children[ i ].flags.func === true) {
const func = impl[ i ]
const... | [
"function",
"checkFunctions",
"(",
"impl",
",",
"schema",
")",
"{",
"const",
"children",
"=",
"schema",
".",
"describe",
"(",
")",
".",
"children",
"const",
"ret",
"=",
"{",
"ok",
":",
"true",
"}",
"for",
"(",
"let",
"i",
"in",
"children",
")",
"{",
... | Does some funky joi object parsing and parses the function signature to
extract parameter names | [
"Does",
"some",
"funky",
"joi",
"object",
"parsing",
"and",
"parses",
"the",
"function",
"signature",
"to",
"extract",
"parameter",
"names"
] | 2b62a853a0c9cce99d8c982c5b7a28e2b4852081 | https://github.com/recursivefunk/nyce/blob/2b62a853a0c9cce99d8c982c5b7a28e2b4852081/lib/validate.js#L41-L78 | train |
gmalysa/flux-link | lib/gen-dot.js | _dot_inner | function _dot_inner(elem, make_digraph, names) {
var builder = [];
var name = hash_name_get(elem, names);
// Only push graphs/clusters for chains
if (elem instanceof fl.ChainBase) {
if (make_digraph)
builder.push('digraph '+name+' {');
else
builder.push('subgraph cluster_'+name+' {');
builder.... | javascript | function _dot_inner(elem, make_digraph, names) {
var builder = [];
var name = hash_name_get(elem, names);
// Only push graphs/clusters for chains
if (elem instanceof fl.ChainBase) {
if (make_digraph)
builder.push('digraph '+name+' {');
else
builder.push('subgraph cluster_'+name+' {');
builder.... | [
"function",
"_dot_inner",
"(",
"elem",
",",
"make_digraph",
",",
"names",
")",
"{",
"var",
"builder",
"=",
"[",
"]",
";",
"var",
"name",
"=",
"hash_name_get",
"(",
"elem",
",",
"names",
")",
";",
"// Only push graphs/clusters for chains",
"if",
"(",
"elem",
... | Inner worker function used to build the actual DOT description
@param elem The element to describe
@param make_digraph Should this node be instantiated as a digraph or subgraph cluster
@param names The hash table of functions and their names that have been seen
@return Standard triple of [strings, first element, last e... | [
"Inner",
"worker",
"function",
"used",
"to",
"build",
"the",
"actual",
"DOT",
"description"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L30-L64 | train |
gmalysa/flux-link | lib/gen-dot.js | get_chain_content | function get_chain_content(elem, names) {
if (elem instanceof fl.Branch) {
return handle_branch(elem, names);
}
else if (elem instanceof fl.ParallelChain) {
return handle_parallel(elem, names);
}
else if (elem instanceof fl.LoopChain) {
return handle_loop(elem, names);
}
else if (elem instanceof ... | javascript | function get_chain_content(elem, names) {
if (elem instanceof fl.Branch) {
return handle_branch(elem, names);
}
else if (elem instanceof fl.ParallelChain) {
return handle_parallel(elem, names);
}
else if (elem instanceof fl.LoopChain) {
return handle_loop(elem, names);
}
else if (elem instanceof ... | [
"function",
"get_chain_content",
"(",
"elem",
",",
"names",
")",
"{",
"if",
"(",
"elem",
"instanceof",
"fl",
".",
"Branch",
")",
"{",
"return",
"handle_branch",
"(",
"elem",
",",
"names",
")",
";",
"}",
"else",
"if",
"(",
"elem",
"instanceof",
"fl",
".... | Breakout function that simply calls the correct handler based on the type
of the element supplied
@param elem A chain-type object to get a dot description for
@param names The hash table of functions and names that we've seen
@return Standard triple of [strings, first element, last element] | [
"Breakout",
"function",
"that",
"simply",
"calls",
"the",
"correct",
"handler",
"based",
"on",
"the",
"type",
"of",
"the",
"element",
"supplied"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L73-L90 | train |
gmalysa/flux-link | lib/gen-dot.js | handle_branch | function handle_branch(elem, names) {
var cond = _dot_inner(elem.cond.fn, false, names);
var if_true = _dot_inner(elem.if_true.fn, false, names);
var if_false = _dot_inner(elem.if_false.fn, false, names);
var terminator = hash_name_get({name : 'branch_end'}, names);
var builder = [];
Array.prototype.push.a... | javascript | function handle_branch(elem, names) {
var cond = _dot_inner(elem.cond.fn, false, names);
var if_true = _dot_inner(elem.if_true.fn, false, names);
var if_false = _dot_inner(elem.if_false.fn, false, names);
var terminator = hash_name_get({name : 'branch_end'}, names);
var builder = [];
Array.prototype.push.a... | [
"function",
"handle_branch",
"(",
"elem",
",",
"names",
")",
"{",
"var",
"cond",
"=",
"_dot_inner",
"(",
"elem",
".",
"cond",
".",
"fn",
",",
"false",
",",
"names",
")",
";",
"var",
"if_true",
"=",
"_dot_inner",
"(",
"elem",
".",
"if_true",
".",
"fn"... | Handle a branch-type chain, which includes fancy decision labels and
formatting
@param elem The branch element
@param names The hash table of names we've seen
@return Standard triple of [strings, first element, last element] | [
"Handle",
"a",
"branch",
"-",
"type",
"chain",
"which",
"includes",
"fancy",
"decision",
"labels",
"and",
"formatting"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L99-L116 | train |
gmalysa/flux-link | lib/gen-dot.js | handle_parallel | function handle_parallel(elem, names) {
var phead = hash_name_get({name : 'parallel_head'}, names);
var ptail = hash_name_get({name : 'parallel_tail'}, names);
var node;
var builder = [];
for (var i = 0; i < elem.fns.length; ++i) {
node = _dot_inner(elem.fns[i].fn, false, names);
Array.prototype.push.a... | javascript | function handle_parallel(elem, names) {
var phead = hash_name_get({name : 'parallel_head'}, names);
var ptail = hash_name_get({name : 'parallel_tail'}, names);
var node;
var builder = [];
for (var i = 0; i < elem.fns.length; ++i) {
node = _dot_inner(elem.fns[i].fn, false, names);
Array.prototype.push.a... | [
"function",
"handle_parallel",
"(",
"elem",
",",
"names",
")",
"{",
"var",
"phead",
"=",
"hash_name_get",
"(",
"{",
"name",
":",
"'parallel_head'",
"}",
",",
"names",
")",
";",
"var",
"ptail",
"=",
"hash_name_get",
"(",
"{",
"name",
":",
"'parallel_tail'",... | Handle a parallel chain, which inserts head and footer nodes around
the functions in the middle
@param elem The parallel chain to describe in DOT
@param names The hash table of functions and their names
@return Standard triple of [strings, first element, last element] | [
"Handle",
"a",
"parallel",
"chain",
"which",
"inserts",
"head",
"and",
"footer",
"nodes",
"around",
"the",
"functions",
"in",
"the",
"middle"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L125-L141 | train |
gmalysa/flux-link | lib/gen-dot.js | handle_loop | function handle_loop(elem, names) {
var cond = _dot_inner(elem.cond.fn, false, names);
var node1 = _dot_inner(elem.fns[0].fn, false, names);
var builder = [];
var node2 = node1;
Array.prototype.push.apply(builder, cond[0]);
Array.prototype.push.apply(builder, node1[0]);
builder.push(cond[2]+' [shape=Mdia... | javascript | function handle_loop(elem, names) {
var cond = _dot_inner(elem.cond.fn, false, names);
var node1 = _dot_inner(elem.fns[0].fn, false, names);
var builder = [];
var node2 = node1;
Array.prototype.push.apply(builder, cond[0]);
Array.prototype.push.apply(builder, node1[0]);
builder.push(cond[2]+' [shape=Mdia... | [
"function",
"handle_loop",
"(",
"elem",
",",
"names",
")",
"{",
"var",
"cond",
"=",
"_dot_inner",
"(",
"elem",
".",
"cond",
".",
"fn",
",",
"false",
",",
"names",
")",
";",
"var",
"node1",
"=",
"_dot_inner",
"(",
"elem",
".",
"fns",
"[",
"0",
"]",
... | Handle a loop chain, which is a lot like a serial chain but with a starter
condition node on top
@param elem The loop chain to describe in DOT
@param names The hash table of functions and their names
@return Standard triple of [strings, first element, last element] | [
"Handle",
"a",
"loop",
"chain",
"which",
"is",
"a",
"lot",
"like",
"a",
"serial",
"chain",
"but",
"with",
"a",
"starter",
"condition",
"node",
"on",
"top"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L150-L170 | train |
gmalysa/flux-link | lib/gen-dot.js | handle_chain | function handle_chain(elem, names) {
// Make sure the chain does something
if (elem.fns.length === 0) {
return [[], hash_name_get({name : '__empty__'}), hash_name_get({name : '__empty__'})];
}
var builder = [];
var node1 = _dot_inner(elem.fns[0].fn, false, names);
var first = node1;
var node2;
for ... | javascript | function handle_chain(elem, names) {
// Make sure the chain does something
if (elem.fns.length === 0) {
return [[], hash_name_get({name : '__empty__'}), hash_name_get({name : '__empty__'})];
}
var builder = [];
var node1 = _dot_inner(elem.fns[0].fn, false, names);
var first = node1;
var node2;
for ... | [
"function",
"handle_chain",
"(",
"elem",
",",
"names",
")",
"{",
"// Make sure the chain does something",
"if",
"(",
"elem",
".",
"fns",
".",
"length",
"===",
"0",
")",
"{",
"return",
"[",
"[",
"]",
",",
"hash_name_get",
"(",
"{",
"name",
":",
"'__empty__'... | Handle a serial chain of function, which just pushes each node with an
edge to the next node in the chain
@param elem The chain to pull elements from
@param names The hash table of names that we've seen
@return Standard triple of [strings, first element, last element] | [
"Handle",
"a",
"serial",
"chain",
"of",
"function",
"which",
"just",
"pushes",
"each",
"node",
"with",
"an",
"edge",
"to",
"the",
"next",
"node",
"in",
"the",
"chain"
] | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L179-L199 | train |
gmalysa/flux-link | lib/gen-dot.js | hash_name_get | function hash_name_get(elem, names) {
var fname;
if (elem.fn !== undefined)
fname = format_name(helpers.fname(elem, elem.fn.name));
else
fname = format_name(elem.name);
var list = names[fname];
// First unique instance of a function gets to use its proper name
if (list === undefined) {
names[fname... | javascript | function hash_name_get(elem, names) {
var fname;
if (elem.fn !== undefined)
fname = format_name(helpers.fname(elem, elem.fn.name));
else
fname = format_name(elem.name);
var list = names[fname];
// First unique instance of a function gets to use its proper name
if (list === undefined) {
names[fname... | [
"function",
"hash_name_get",
"(",
"elem",
",",
"names",
")",
"{",
"var",
"fname",
";",
"if",
"(",
"elem",
".",
"fn",
"!==",
"undefined",
")",
"fname",
"=",
"format_name",
"(",
"helpers",
".",
"fname",
"(",
"elem",
",",
"elem",
".",
"fn",
".",
"name",... | Retrieve the proper name to use in the graph, for a given element. If it doesn't
exist in the hash table given, then it is added, and its allocated name is returned
@param elem The element (chain or function) to look up in the hash table
@param names The hash table to use to resolve and store names
@return Properly for... | [
"Retrieve",
"the",
"proper",
"name",
"to",
"use",
"in",
"the",
"graph",
"for",
"a",
"given",
"element",
".",
"If",
"it",
"doesn",
"t",
"exist",
"in",
"the",
"hash",
"table",
"given",
"then",
"it",
"is",
"added",
"and",
"its",
"allocated",
"name",
"is",... | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/gen-dot.js#L208-L234 | train |
mwri/polylock | lib/polylock.js | polylock | function polylock (params) {
if (params === undefined)
params = {};
this.queue = new polylock_ll();
this.ex_locks = {};
this.ex_reserved = {};
this.sh_locks = {};
this.op_num = 1;
this.drain_for_writes = params.write_priority ? true : false;
} | javascript | function polylock (params) {
if (params === undefined)
params = {};
this.queue = new polylock_ll();
this.ex_locks = {};
this.ex_reserved = {};
this.sh_locks = {};
this.op_num = 1;
this.drain_for_writes = params.write_priority ? true : false;
} | [
"function",
"polylock",
"(",
"params",
")",
"{",
"if",
"(",
"params",
"===",
"undefined",
")",
"params",
"=",
"{",
"}",
";",
"this",
".",
"queue",
"=",
"new",
"polylock_ll",
"(",
")",
";",
"this",
".",
"ex_locks",
"=",
"{",
"}",
";",
"this",
".",
... | Construct a 'polylock' resource manager.
Optionally an object parameter may be passed with parameters.
The only key recognised is 'write_priority', which if set to true, causes
write locks to be prioritised over read locks. | [
"Construct",
"a",
"polylock",
"resource",
"manager",
"."
] | 09167924a38aad1a516de07d2a049900f88b89db | https://github.com/mwri/polylock/blob/09167924a38aad1a516de07d2a049900f88b89db/lib/polylock.js#L23-L36 | train |
adiwidjaja/frontend-pagebuilder | js/tinymce/plugins/link/plugin.js | function (editor, message, callback) {
var rng = editor.selection.getRng();
Delay.setEditorTimeout(editor, function () {
editor.windowManager.confirm(message, function (state) {
editor.selection.setRng(rng);
callback(state);
});
});
} | javascript | function (editor, message, callback) {
var rng = editor.selection.getRng();
Delay.setEditorTimeout(editor, function () {
editor.windowManager.confirm(message, function (state) {
editor.selection.setRng(rng);
callback(state);
});
});
} | [
"function",
"(",
"editor",
",",
"message",
",",
"callback",
")",
"{",
"var",
"rng",
"=",
"editor",
".",
"selection",
".",
"getRng",
"(",
")",
";",
"Delay",
".",
"setEditorTimeout",
"(",
"editor",
",",
"function",
"(",
")",
"{",
"editor",
".",
"windowMa... | Delay confirm since onSubmit will move focus | [
"Delay",
"confirm",
"since",
"onSubmit",
"will",
"move",
"focus"
] | a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f | https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/plugins/link/plugin.js#L527-L536 | train | |
cschuller/grunt-yakjs | grunt-yakjs.js | gruntYakTask | function gruntYakTask(grunt) {
'use strict';
/**
* @type {!Array<string>}
*/
let filesToUpload = [];
/**
* @type {RequestSender}
*/
let requestSender;
/**
* Register task for grunt.
*/
grunt.registerMultiTask('yakjs', 'A grunt task to update the YAKjs via res... | javascript | function gruntYakTask(grunt) {
'use strict';
/**
* @type {!Array<string>}
*/
let filesToUpload = [];
/**
* @type {RequestSender}
*/
let requestSender;
/**
* Register task for grunt.
*/
grunt.registerMultiTask('yakjs', 'A grunt task to update the YAKjs via res... | [
"function",
"gruntYakTask",
"(",
"grunt",
")",
"{",
"'use strict'",
";",
"/**\n * @type {!Array<string>}\n */",
"let",
"filesToUpload",
"=",
"[",
"]",
";",
"/**\n * @type {RequestSender}\n */",
"let",
"requestSender",
";",
"/**\n * Register task for grunt.\n... | Registers tasks for grunt
@param {?} grunt | [
"Registers",
"tasks",
"for",
"grunt"
] | 4e0c94220c1e8bb30a533ce204e70a57f41e1e43 | https://github.com/cschuller/grunt-yakjs/blob/4e0c94220c1e8bb30a533ce204e70a57f41e1e43/grunt-yakjs.js#L12-L70 | train |
75lb/req-then | index.js | request | function request (reqOptions, data) {
const t = require('typical')
if (!reqOptions) return Promise.reject(Error('need a URL or request options object'))
if (t.isString(reqOptions)) {
const urlUtils = require('url')
reqOptions = urlUtils.parse(reqOptions)
} else {
reqOptions = Object.assign({ headers... | javascript | function request (reqOptions, data) {
const t = require('typical')
if (!reqOptions) return Promise.reject(Error('need a URL or request options object'))
if (t.isString(reqOptions)) {
const urlUtils = require('url')
reqOptions = urlUtils.parse(reqOptions)
} else {
reqOptions = Object.assign({ headers... | [
"function",
"request",
"(",
"reqOptions",
",",
"data",
")",
"{",
"const",
"t",
"=",
"require",
"(",
"'typical'",
")",
"if",
"(",
"!",
"reqOptions",
")",
"return",
"Promise",
".",
"reject",
"(",
"Error",
"(",
"'need a URL or request options object'",
")",
")"... | Returns a promise for the response.
@param {string|object} - Target url string or a standard node.js http request options object.
@param [reqOptions.controller] {object} - If supplied, an `.abort()` method will be created on it which, if invoked, will cancel the request. Cancelling will cause the returned promise to re... | [
"Returns",
"a",
"promise",
"for",
"the",
"response",
"."
] | 1d7997054d6634702b5046e4eaf9e8e703705367 | https://github.com/75lb/req-then/blob/1d7997054d6634702b5046e4eaf9e8e703705367/index.js#L47-L115 | train |
patience-tema-baron/ember-createjs | vendor/createjs/cordova-audio-plugin.js | Loader | function Loader(loadItem) {
this.AbstractLoader_constructor(loadItem, true, createjs.AbstractLoader.SOUND);
/**
* A Media object used to determine if src exists and to get duration
* @property _media
* @type {Media}
* @protected
*/
this._media = null;
/**
* A time counter that triggers timeo... | javascript | function Loader(loadItem) {
this.AbstractLoader_constructor(loadItem, true, createjs.AbstractLoader.SOUND);
/**
* A Media object used to determine if src exists and to get duration
* @property _media
* @type {Media}
* @protected
*/
this._media = null;
/**
* A time counter that triggers timeo... | [
"function",
"Loader",
"(",
"loadItem",
")",
"{",
"this",
".",
"AbstractLoader_constructor",
"(",
"loadItem",
",",
"true",
",",
"createjs",
".",
"AbstractLoader",
".",
"SOUND",
")",
";",
"/**\n\t\t * A Media object used to determine if src exists and to get duration\n\t\t * ... | Loader provides a mechanism to preload Cordova audio content via PreloadJS or internally. Instances are returned to
the preloader, and the load method is called when the asset needs to be requested.
Currently files are assumed to be local and no loading actually takes place. This class exists to more easily support
th... | [
"Loader",
"provides",
"a",
"mechanism",
"to",
"preload",
"Cordova",
"audio",
"content",
"via",
"PreloadJS",
"or",
"internally",
".",
"Instances",
"are",
"returned",
"to",
"the",
"preloader",
"and",
"the",
"load",
"method",
"is",
"called",
"when",
"the",
"asset... | 4647611b4b7540a736ae63a641f1febbbd36145d | https://github.com/patience-tema-baron/ember-createjs/blob/4647611b4b7540a736ae63a641f1febbbd36145d/vendor/createjs/cordova-audio-plugin.js#L50-L76 | train |
rranauro/boxspringjs | utils.js | function (f) {
var separator
, temp = [];
[ '/', '-', ' '].forEach(function(sep) {
if (temp.length < 2) {
separator = sep;
temp = f.split(separator);
}
});
return separator;
} | javascript | function (f) {
var separator
, temp = [];
[ '/', '-', ' '].forEach(function(sep) {
if (temp.length < 2) {
separator = sep;
temp = f.split(separator);
}
});
return separator;
} | [
"function",
"(",
"f",
")",
"{",
"var",
"separator",
",",
"temp",
"=",
"[",
"]",
";",
"[",
"'/'",
",",
"'-'",
",",
"' '",
"]",
".",
"forEach",
"(",
"function",
"(",
"sep",
")",
"{",
"if",
"(",
"temp",
".",
"length",
"<",
"2",
")",
"{",
"separa... | get the separator for the date format | [
"get",
"the",
"separator",
"for",
"the",
"date",
"format"
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/utils.js#L368-L378 | train | |
ryedog/stallion | src/stallion.js | function(username, password) {
var restler_defaults = { baseURL: config.baseUrl };
var RestlerService = restler.service(default_init, restler_defaults, api);
return new RestlerService(username, password);
} | javascript | function(username, password) {
var restler_defaults = { baseURL: config.baseUrl };
var RestlerService = restler.service(default_init, restler_defaults, api);
return new RestlerService(username, password);
} | [
"function",
"(",
"username",
",",
"password",
")",
"{",
"var",
"restler_defaults",
"=",
"{",
"baseURL",
":",
"config",
".",
"baseUrl",
"}",
";",
"var",
"RestlerService",
"=",
"restler",
".",
"service",
"(",
"default_init",
",",
"restler_defaults",
",",
"api"... | Can't use multilple instances of Reslter services Because each instance shares the defaults and the only way to set the username & password is to use the defaults each instance will actually be the same So instead when we create another instance of a Stallion service we'll actually create a seperate instance of a Res... | [
"Can",
"t",
"use",
"multilple",
"instances",
"of",
"Reslter",
"services",
"Because",
"each",
"instance",
"shares",
"the",
"defaults",
"and",
"the",
"only",
"way",
"to",
"set",
"the",
"username",
"&",
"password",
"is",
"to",
"use",
"the",
"defaults",
"each",
... | 08d200aeea5b0ed2fbfd7d4b757ab9a7ba85c30a | https://github.com/ryedog/stallion/blob/08d200aeea5b0ed2fbfd7d4b757ab9a7ba85c30a/src/stallion.js#L50-L55 | train | |
ryedog/stallion | src/stallion.js | get_id | function get_id(val) {
if ( typeof val === 'string' || typeof val === 'number' )
return val;
if ( typeof val === 'object' && val.id )
return val.id;
return false;
} | javascript | function get_id(val) {
if ( typeof val === 'string' || typeof val === 'number' )
return val;
if ( typeof val === 'object' && val.id )
return val.id;
return false;
} | [
"function",
"get_id",
"(",
"val",
")",
"{",
"if",
"(",
"typeof",
"val",
"===",
"'string'",
"||",
"typeof",
"val",
"===",
"'number'",
")",
"return",
"val",
";",
"if",
"(",
"typeof",
"val",
"===",
"'object'",
"&&",
"val",
".",
"id",
")",
"return",
"val... | Whether the value can be used in the REST endpoint
@param {Mixed} val
@return {Boolean} TRUE if value can be inserted into the endpoint | [
"Whether",
"the",
"value",
"can",
"be",
"used",
"in",
"the",
"REST",
"endpoint"
] | 08d200aeea5b0ed2fbfd7d4b757ab9a7ba85c30a | https://github.com/ryedog/stallion/blob/08d200aeea5b0ed2fbfd7d4b757ab9a7ba85c30a/src/stallion.js#L246-L254 | train |
ryedog/stallion | src/stallion.js | default_init | function default_init(user, password) {
this.defaults.username = user;
this.defaults.password = password;
this.defaults.headers = {
Accept: 'application/json'
};
this.defaults.headers['Content-Type'] = 'application/json';
} | javascript | function default_init(user, password) {
this.defaults.username = user;
this.defaults.password = password;
this.defaults.headers = {
Accept: 'application/json'
};
this.defaults.headers['Content-Type'] = 'application/json';
} | [
"function",
"default_init",
"(",
"user",
",",
"password",
")",
"{",
"this",
".",
"defaults",
".",
"username",
"=",
"user",
";",
"this",
".",
"defaults",
".",
"password",
"=",
"password",
";",
"this",
".",
"defaults",
".",
"headers",
"=",
"{",
"Accept",
... | Default Restler service function
@param {String} user
@param {String} password | [
"Default",
"Restler",
"service",
"function"
] | 08d200aeea5b0ed2fbfd7d4b757ab9a7ba85c30a | https://github.com/ryedog/stallion/blob/08d200aeea5b0ed2fbfd7d4b757ab9a7ba85c30a/src/stallion.js#L261-L269 | train |
gmalysa/flux-link | lib/environment.js | LocalEnvironment | function LocalEnvironment(env, id) {
Environment.call(this, {}, env._fm.$log);
this._env = env;
this._thread_id = id;
} | javascript | function LocalEnvironment(env, id) {
Environment.call(this, {}, env._fm.$log);
this._env = env;
this._thread_id = id;
} | [
"function",
"LocalEnvironment",
"(",
"env",
",",
"id",
")",
"{",
"Environment",
".",
"call",
"(",
"this",
",",
"{",
"}",
",",
"env",
".",
"_fm",
".",
"$log",
")",
";",
"this",
".",
"_env",
"=",
"env",
";",
"this",
".",
"_thread_id",
"=",
"id",
";... | The LocalEnvironment class, which is the same as an environment class, except that it is
unique to each "thread" in parallel execution chains, similar to thread-local storage.
It has a pointer to the shared state, so that it may still be accessed.
@param env The environment variable to use as parent
@param id The threa... | [
"The",
"LocalEnvironment",
"class",
"which",
"is",
"the",
"same",
"as",
"an",
"environment",
"class",
"except",
"that",
"it",
"is",
"unique",
"to",
"each",
"thread",
"in",
"parallel",
"execution",
"chains",
"similar",
"to",
"thread",
"-",
"local",
"storage",
... | 567ac39a1f4a74f85465a58fb6fd96d64b1b765f | https://github.com/gmalysa/flux-link/blob/567ac39a1f4a74f85465a58fb6fd96d64b1b765f/lib/environment.js#L192-L196 | train |
MiguelCastillo/spromise | src/promise.js | StateManager | function StateManager(options) {
// Initial state is pending
this.state = states.pending;
// If a state is passed in, then we go ahead and initialize the state manager with it
if (options && options.state) {
this.transition(options.state, options.value, options.context);
}
} | javascript | function StateManager(options) {
// Initial state is pending
this.state = states.pending;
// If a state is passed in, then we go ahead and initialize the state manager with it
if (options && options.state) {
this.transition(options.state, options.value, options.context);
}
} | [
"function",
"StateManager",
"(",
"options",
")",
"{",
"// Initial state is pending",
"this",
".",
"state",
"=",
"states",
".",
"pending",
";",
"// If a state is passed in, then we go ahead and initialize the state manager with it",
"if",
"(",
"options",
"&&",
"options",
"."... | Provides a set of interfaces to manage callback queues and the resolution state
of the promises. | [
"Provides",
"a",
"set",
"of",
"interfaces",
"to",
"manage",
"callback",
"queues",
"and",
"the",
"resolution",
"state",
"of",
"the",
"promises",
"."
] | faef0a81e88a871095393980fccdd7980e7c3f89 | https://github.com/MiguelCastillo/spromise/blob/faef0a81e88a871095393980fccdd7980e7c3f89/src/promise.js#L115-L123 | train |
limi58/ease-animate | src/ease-animate-dom.js | startDomAnimate | function startDomAnimate(selector, animationProps, interval, onDone){
let numberIndex = 0
const numbersLength = animationProps[0].numbers.length
this.isDomRunning = true
const tick = setInterval(() => {
animationProps.forEach(prop => {
setStyle(selector, prop.attr, prop.numbers[numberIndex], prop.unit... | javascript | function startDomAnimate(selector, animationProps, interval, onDone){
let numberIndex = 0
const numbersLength = animationProps[0].numbers.length
this.isDomRunning = true
const tick = setInterval(() => {
animationProps.forEach(prop => {
setStyle(selector, prop.attr, prop.numbers[numberIndex], prop.unit... | [
"function",
"startDomAnimate",
"(",
"selector",
",",
"animationProps",
",",
"interval",
",",
"onDone",
")",
"{",
"let",
"numberIndex",
"=",
"0",
"const",
"numbersLength",
"=",
"animationProps",
"[",
"0",
"]",
".",
"numbers",
".",
"length",
"this",
".",
"isDo... | let dom animate | [
"let",
"dom",
"animate"
] | 5072ef7798749228febcf1b778cca17461592982 | https://github.com/limi58/ease-animate/blob/5072ef7798749228febcf1b778cca17461592982/src/ease-animate-dom.js#L15-L30 | train |
powmedia/pow-mongoose-plugins | lib/authenticator.js | encryptPassword | function encryptPassword(password, callback) {
bcrypt.gen_salt(workFactor, function(err, salt) {
if (err) callback(err);
bcrypt.encrypt(password, salt, function(err, hashedPassword) {
if (err) callback(err);
callback(null, has... | javascript | function encryptPassword(password, callback) {
bcrypt.gen_salt(workFactor, function(err, salt) {
if (err) callback(err);
bcrypt.encrypt(password, salt, function(err, hashedPassword) {
if (err) callback(err);
callback(null, has... | [
"function",
"encryptPassword",
"(",
"password",
",",
"callback",
")",
"{",
"bcrypt",
".",
"gen_salt",
"(",
"workFactor",
",",
"function",
"(",
"err",
",",
"salt",
")",
"{",
"if",
"(",
"err",
")",
"callback",
"(",
"err",
")",
";",
"bcrypt",
".",
"encryp... | Encrypts a password
@param {String} Password
@param {Function} Callback (receives: err, hashedPassword) | [
"Encrypts",
"a",
"password"
] | 4dff978adb012136eb773741ae1e9e2efb0224ca | https://github.com/powmedia/pow-mongoose-plugins/blob/4dff978adb012136eb773741ae1e9e2efb0224ca/lib/authenticator.js#L49-L59 | train |
dominictarr/npmd-tree | index.js | ls | function ls (dir, cb) {
if(!cb) cb = dir, dir = null
dir = dir || process.cwd()
pull(
pfs.ancestors(dir),
pfs.resolve('node_modules'),
pfs.star(),
pull.filter(Boolean),
paramap(maybe(readPackage)),
filter(),
pull.unique('name'),
pull.reduce(function (obj, val) {
if(!obj[val... | javascript | function ls (dir, cb) {
if(!cb) cb = dir, dir = null
dir = dir || process.cwd()
pull(
pfs.ancestors(dir),
pfs.resolve('node_modules'),
pfs.star(),
pull.filter(Boolean),
paramap(maybe(readPackage)),
filter(),
pull.unique('name'),
pull.reduce(function (obj, val) {
if(!obj[val... | [
"function",
"ls",
"(",
"dir",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"cb",
")",
"cb",
"=",
"dir",
",",
"dir",
"=",
"null",
"dir",
"=",
"dir",
"||",
"process",
".",
"cwd",
"(",
")",
"pull",
"(",
"pfs",
".",
"ancestors",
"(",
"dir",
")",
",",
"... | retrive the current files, | [
"retrive",
"the",
"current",
"files"
] | 97d56a4414520266b736d7d6442a05b82cb43ebb | https://github.com/dominictarr/npmd-tree/blob/97d56a4414520266b736d7d6442a05b82cb43ebb/index.js#L89-L110 | train |
dominictarr/npmd-tree | index.js | tree | function tree (dir, opts, cb) {
var i = 0
findPackage(dir, function (err, pkg) {
pull(
pull.depthFirst(pkg, function (pkg) {
pkg.tree = {}
return pull(
pfs.readdir(path.resolve(pkg.path, 'node_modules')),
paramap(maybe(readPackage)),
pull.filter(function (_pkg... | javascript | function tree (dir, opts, cb) {
var i = 0
findPackage(dir, function (err, pkg) {
pull(
pull.depthFirst(pkg, function (pkg) {
pkg.tree = {}
return pull(
pfs.readdir(path.resolve(pkg.path, 'node_modules')),
paramap(maybe(readPackage)),
pull.filter(function (_pkg... | [
"function",
"tree",
"(",
"dir",
",",
"opts",
",",
"cb",
")",
"{",
"var",
"i",
"=",
"0",
"findPackage",
"(",
"dir",
",",
"function",
"(",
"err",
",",
"pkg",
")",
"{",
"pull",
"(",
"pull",
".",
"depthFirst",
"(",
"pkg",
",",
"function",
"(",
"pkg",... | creates the same datastructure as resolve, selecting all dependencies... | [
"creates",
"the",
"same",
"datastructure",
"as",
"resolve",
"selecting",
"all",
"dependencies",
"..."
] | 97d56a4414520266b736d7d6442a05b82cb43ebb | https://github.com/dominictarr/npmd-tree/blob/97d56a4414520266b736d7d6442a05b82cb43ebb/index.js#L115-L142 | train |
JBZoo/JS-Utils | src/helper.js | function () {
var args = arguments,
argc = arguments.length;
if (argc === 1) {
if (args[0] === undefined || args[0] === null) {
return undefined;
}
return args[0];
} else if (argc === 2) {
... | javascript | function () {
var args = arguments,
argc = arguments.length;
if (argc === 1) {
if (args[0] === undefined || args[0] === null) {
return undefined;
}
return args[0];
} else if (argc === 2) {
... | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
",",
"argc",
"=",
"arguments",
".",
"length",
";",
"if",
"(",
"argc",
"===",
"1",
")",
"{",
"if",
"(",
"args",
"[",
"0",
"]",
"===",
"undefined",
"||",
"args",
"[",
"0",
"]",
"===",
"n... | Check and get variable
@returns {*} | [
"Check",
"and",
"get",
"variable"
] | 7b188893c4e2da81279e00e07e65b930685d05d3 | https://github.com/JBZoo/JS-Utils/blob/7b188893c4e2da81279e00e07e65b930685d05d3/src/helper.js#L150-L178 | train | |
JBZoo/JS-Utils | src/helper.js | function (variable, isRecursive) {
var property, result = 0;
isRecursive = (typeof isRecursive !== "undefined" && isRecursive) ? true : false;
if (variable === false ||
variable === null ||
typeof variable === "undefined"
) {
... | javascript | function (variable, isRecursive) {
var property, result = 0;
isRecursive = (typeof isRecursive !== "undefined" && isRecursive) ? true : false;
if (variable === false ||
variable === null ||
typeof variable === "undefined"
) {
... | [
"function",
"(",
"variable",
",",
"isRecursive",
")",
"{",
"var",
"property",
",",
"result",
"=",
"0",
";",
"isRecursive",
"=",
"(",
"typeof",
"isRecursive",
"!==",
"\"undefined\"",
"&&",
"isRecursive",
")",
"?",
"true",
":",
"false",
";",
"if",
"(",
"va... | Count all elements in an array, or something in an object
@link http://php.net/manual/en/function.count.php
@link http://phpjs.org/functions/count/
@param variable
@param isRecursive bool
@returns {number} | [
"Count",
"all",
"elements",
"in",
"an",
"array",
"or",
"something",
"in",
"an",
"object"
] | 7b188893c4e2da81279e00e07e65b930685d05d3 | https://github.com/JBZoo/JS-Utils/blob/7b188893c4e2da81279e00e07e65b930685d05d3/src/helper.js#L228-L261 | train | |
JBZoo/JS-Utils | src/helper.js | function (needle, haystack, strict) {
var found = false;
strict = !!strict;
$this.each(haystack, function (key) {
/* jshint -W116 */
if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
found = true... | javascript | function (needle, haystack, strict) {
var found = false;
strict = !!strict;
$this.each(haystack, function (key) {
/* jshint -W116 */
if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
found = true... | [
"function",
"(",
"needle",
",",
"haystack",
",",
"strict",
")",
"{",
"var",
"found",
"=",
"false",
";",
"strict",
"=",
"!",
"!",
"strict",
";",
"$this",
".",
"each",
"(",
"haystack",
",",
"function",
"(",
"key",
")",
"{",
"/* jshint -W116 */",
"if",
... | Finds whether a variable is a number or a numeric string
@link http://php.net/manual/ru/function.in-array.php
@link http://phpjs.org/functions/in_array/
@param needle
@param haystack
@param strict
@return {Boolean} | [
"Finds",
"whether",
"a",
"variable",
"is",
"a",
"number",
"or",
"a",
"numeric",
"string"
] | 7b188893c4e2da81279e00e07e65b930685d05d3 | https://github.com/JBZoo/JS-Utils/blob/7b188893c4e2da81279e00e07e65b930685d05d3/src/helper.js#L274-L290 | train | |
JBZoo/JS-Utils | src/helper.js | function (value, precision, mode) {
/* jshint -W016 */
/* jshint -W018 */
// Helper variables
var base, floorNum, isHalf, sign;
// Making sure precision is integer
precision |= 0;
base = Math.pow(10, precision);
value *= b... | javascript | function (value, precision, mode) {
/* jshint -W016 */
/* jshint -W018 */
// Helper variables
var base, floorNum, isHalf, sign;
// Making sure precision is integer
precision |= 0;
base = Math.pow(10, precision);
value *= b... | [
"function",
"(",
"value",
",",
"precision",
",",
"mode",
")",
"{",
"/* jshint -W016 */",
"/* jshint -W018 */",
"// Helper variables",
"var",
"base",
",",
"floorNum",
",",
"isHalf",
",",
"sign",
";",
"// Making sure precision is integer",
"precision",
"|=",
"0",
";",... | Rounds a float
@link http://php.net/manual/en/function.round.php
@link http://phpjs.org/functions/round/
@param value
@param precision
@param mode
@returns {number} | [
"Rounds",
"a",
"float"
] | 7b188893c4e2da81279e00e07e65b930685d05d3 | https://github.com/JBZoo/JS-Utils/blob/7b188893c4e2da81279e00e07e65b930685d05d3/src/helper.js#L385-L426 | train | |
JBZoo/JS-Utils | src/helper.js | function (glue, pieces) {
var retVal = "",
tGlue = "";
if (arguments.length === 1) {
pieces = glue;
glue = "";
}
if (typeof pieces === "object") {
if ($this.type(pieces) === "array") {
... | javascript | function (glue, pieces) {
var retVal = "",
tGlue = "";
if (arguments.length === 1) {
pieces = glue;
glue = "";
}
if (typeof pieces === "object") {
if ($this.type(pieces) === "array") {
... | [
"function",
"(",
"glue",
",",
"pieces",
")",
"{",
"var",
"retVal",
"=",
"\"\"",
",",
"tGlue",
"=",
"\"\"",
";",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"pieces",
"=",
"glue",
";",
"glue",
"=",
"\"\"",
";",
"}",
"if",
"(",
"... | Join array elements with a string
@link http://php.net/manual/en/function.implode.php
@link http://phpjs.org/functions/implode/
@param glue
@param pieces
@returns {*} | [
"Join",
"array",
"elements",
"with",
"a",
"string"
] | 7b188893c4e2da81279e00e07e65b930685d05d3 | https://github.com/JBZoo/JS-Utils/blob/7b188893c4e2da81279e00e07e65b930685d05d3/src/helper.js#L466-L488 | train | |
JBZoo/JS-Utils | src/helper.js | function (delimiter, string, limit) {
if (arguments.length < 2 ||
typeof delimiter === "undefined" ||
typeof string === "undefined"
) {
return null;
}
if (delimiter === "" ||
delimiter === false ||
... | javascript | function (delimiter, string, limit) {
if (arguments.length < 2 ||
typeof delimiter === "undefined" ||
typeof string === "undefined"
) {
return null;
}
if (delimiter === "" ||
delimiter === false ||
... | [
"function",
"(",
"delimiter",
",",
"string",
",",
"limit",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"<",
"2",
"||",
"typeof",
"delimiter",
"===",
"\"undefined\"",
"||",
"typeof",
"string",
"===",
"\"undefined\"",
")",
"{",
"return",
"null",
";",
... | Split a string by string
@link http://phpjs.org/functions/explode/
@link http://php.net/manual/en/function.explode.php
@param delimiter
@param string
@param limit
@returns {*} | [
"Split",
"a",
"string",
"by",
"string"
] | 7b188893c4e2da81279e00e07e65b930685d05d3 | https://github.com/JBZoo/JS-Utils/blob/7b188893c4e2da81279e00e07e65b930685d05d3/src/helper.js#L501-L556 | train | |
webinverters/robust-auth | src/robust-auth.js | authDetectionMiddleware | function authDetectionMiddleware(req, res, next) {
logger.debug('Running Auth Detection Middleware...', req.body);
if (req.headers['token']) {
try {
req.user = encryption.decode(req.headers['token'], config.secret);
req.session = { user: req.user };
} catch (ex) {
logger.log... | javascript | function authDetectionMiddleware(req, res, next) {
logger.debug('Running Auth Detection Middleware...', req.body);
if (req.headers['token']) {
try {
req.user = encryption.decode(req.headers['token'], config.secret);
req.session = { user: req.user };
} catch (ex) {
logger.log... | [
"function",
"authDetectionMiddleware",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"logger",
".",
"debug",
"(",
"'Running Auth Detection Middleware...'",
",",
"req",
".",
"body",
")",
";",
"if",
"(",
"req",
".",
"headers",
"[",
"'token'",
"]",
")",
"{",... | Detects if the user is sending an authenticated request. If it is, it will set req.user and req.session.user details.
@param req
@param res
@param next | [
"Detects",
"if",
"the",
"user",
"is",
"sending",
"an",
"authenticated",
"request",
".",
"If",
"it",
"is",
"it",
"will",
"set",
"req",
".",
"user",
"and",
"req",
".",
"session",
".",
"user",
"details",
"."
] | ec2058d34837f97da48129998d8af72fef87018a | https://github.com/webinverters/robust-auth/blob/ec2058d34837f97da48129998d8af72fef87018a/src/robust-auth.js#L203-L239 | train |
Zingle/http-later-storage | http-later-storage.js | createStorage | function createStorage(defaults, queue, unqueue, log) {
if (typeof defaults !== "object") {
log = unqueue;
unqueue = queue;
queue = defaults;
defaults = {};
}
/**
* @constructor
* @param {object} [opts]
*/
function Storage(opts) {
mixin(mixin(this,... | javascript | function createStorage(defaults, queue, unqueue, log) {
if (typeof defaults !== "object") {
log = unqueue;
unqueue = queue;
queue = defaults;
defaults = {};
}
/**
* @constructor
* @param {object} [opts]
*/
function Storage(opts) {
mixin(mixin(this,... | [
"function",
"createStorage",
"(",
"defaults",
",",
"queue",
",",
"unqueue",
",",
"log",
")",
"{",
"if",
"(",
"typeof",
"defaults",
"!==",
"\"object\"",
")",
"{",
"log",
"=",
"unqueue",
";",
"unqueue",
"=",
"queue",
";",
"queue",
"=",
"defaults",
";",
"... | Log task result
@callback logResult
@param {string} key
@param {object} result
@param {doneCallback} done
Create http-later storage driver.
@param {object} [defaults]
@param {queueTask} queue
@param {unqueueTask} unqueue
@param {logResult} log
@returns {function} | [
"Log",
"task",
"result"
] | df555a8720a77aa52a37fdcca2d5c01d326b5e3a | https://github.com/Zingle/http-later-storage/blob/df555a8720a77aa52a37fdcca2d5c01d326b5e3a/http-later-storage.js#L55-L119 | train |
crcn/beet | lib/group.js | function(callback) {
var self = this;
this.beet.client.getAllProcessInfo(function(err, processes) {
if(processes)
for(var i = processes.length; i--;) {
var proc = processes[i],
nameParts = proc.name.split('_');
if(namePa... | javascript | function(callback) {
var self = this;
this.beet.client.getAllProcessInfo(function(err, processes) {
if(processes)
for(var i = processes.length; i--;) {
var proc = processes[i],
nameParts = proc.name.split('_');
if(namePa... | [
"function",
"(",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"beet",
".",
"client",
".",
"getAllProcessInfo",
"(",
"function",
"(",
"err",
",",
"processes",
")",
"{",
"if",
"(",
"processes",
")",
"for",
"(",
"var",
"i",
"=",
... | Lists all the processes under the given group | [
"Lists",
"all",
"the",
"processes",
"under",
"the",
"given",
"group"
] | e8622c5c48592bddcf9507a388022aea1f571f01 | https://github.com/crcn/beet/blob/e8622c5c48592bddcf9507a388022aea1f571f01/lib/group.js#L32-L54 | 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.