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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
repetere/periodicjs.ext.login | controller/token_controller.js | function (req, res, next) {
if (periodic.app.controller.extension.reactadmin) {
let reactadmin = periodic.app.controller.extension.reactadmin;
// console.log({ reactadmin });
// console.log('ensureAuthenticated req.session', req.session);
// console.log('ensureAuthenticated req.user', req.user);
next();... | javascript | function (req, res, next) {
if (periodic.app.controller.extension.reactadmin) {
let reactadmin = periodic.app.controller.extension.reactadmin;
// console.log({ reactadmin });
// console.log('ensureAuthenticated req.session', req.session);
// console.log('ensureAuthenticated req.user', req.user);
next();... | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"periodic",
".",
"app",
".",
"controller",
".",
"extension",
".",
"reactadmin",
")",
"{",
"let",
"reactadmin",
"=",
"periodic",
".",
"app",
".",
"controller",
".",
"extension",
".",
... | GET if the user token is vaild show the change password page | [
"GET",
"if",
"the",
"user",
"token",
"is",
"vaild",
"show",
"the",
"change",
"password",
"page"
] | f0e83fc0224242a841c013435c0f75d5f4ae15cd | https://github.com/repetere/periodicjs.ext.login/blob/f0e83fc0224242a841c013435c0f75d5f4ae15cd/controller/token_controller.js#L385-L449 | train | |
repetere/periodicjs.ext.login | controller/token_controller.js | function (req, res, next) {
// console.log('req.body', req.body);
// console.log('req.params', req.params);
var user_token = req.params.token || req.body.token; //req.controllerData.token;
waterfall([
function (cb) {
cb(null, req, res, next);
},
invalidateUserToken,
resetPassword,
saveUs... | javascript | function (req, res, next) {
// console.log('req.body', req.body);
// console.log('req.params', req.params);
var user_token = req.params.token || req.body.token; //req.controllerData.token;
waterfall([
function (cb) {
cb(null, req, res, next);
},
invalidateUserToken,
resetPassword,
saveUs... | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// console.log('req.body', req.body);",
"// console.log('req.params', req.params);",
"var",
"user_token",
"=",
"req",
".",
"params",
".",
"token",
"||",
"req",
".",
"body",
".",
"token",
";",
"//req.contr... | POST change the users old password to the new password in the form | [
"POST",
"change",
"the",
"users",
"old",
"password",
"to",
"the",
"new",
"password",
"in",
"the",
"form"
] | f0e83fc0224242a841c013435c0f75d5f4ae15cd | https://github.com/repetere/periodicjs.ext.login/blob/f0e83fc0224242a841c013435c0f75d5f4ae15cd/controller/token_controller.js#L452-L504 | train | |
michbuett/immutabilis | src/immutabilis.js | createSub | function createSub(value, computed) {
if (isArray(value)) {
return new List(value, computed);
} else if (isObject(value)) {
if (isImmutable(value)) {
return value;
} else if (value.constructor === Object) {
return new Struct(value, comp... | javascript | function createSub(value, computed) {
if (isArray(value)) {
return new List(value, computed);
} else if (isObject(value)) {
if (isImmutable(value)) {
return value;
} else if (value.constructor === Object) {
return new Struct(value, comp... | [
"function",
"createSub",
"(",
"value",
",",
"computed",
")",
"{",
"if",
"(",
"isArray",
"(",
"value",
")",
")",
"{",
"return",
"new",
"List",
"(",
"value",
",",
"computed",
")",
";",
"}",
"else",
"if",
"(",
"isObject",
"(",
"value",
")",
")",
"{",
... | Helper to create an immutable data object depending on the type of the input
@private | [
"Helper",
"to",
"create",
"an",
"immutable",
"data",
"object",
"depending",
"on",
"the",
"type",
"of",
"the",
"input"
] | 3b3b9eaa69e7a7d718a9804ca2d3f5d439716c79 | https://github.com/michbuett/immutabilis/blob/3b3b9eaa69e7a7d718a9804ca2d3f5d439716c79/src/immutabilis.js#L39-L51 | train |
michbuett/immutabilis | src/immutabilis.js | Abstract | function Abstract(value, data, computed) {
this.value = value;
this.data = data && each(data, function (item) {
return createSub(item);
});
this.computedProps = computed;
} | javascript | function Abstract(value, data, computed) {
this.value = value;
this.data = data && each(data, function (item) {
return createSub(item);
});
this.computedProps = computed;
} | [
"function",
"Abstract",
"(",
"value",
",",
"data",
",",
"computed",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"this",
".",
"data",
"=",
"data",
"&&",
"each",
"(",
"data",
",",
"function",
"(",
"item",
")",
"{",
"return",
"createSub",
"(",
... | The abstract base class for immutable values
@class Abstract
@private | [
"The",
"abstract",
"base",
"class",
"for",
"immutable",
"values"
] | 3b3b9eaa69e7a7d718a9804ca2d3f5d439716c79 | https://github.com/michbuett/immutabilis/blob/3b3b9eaa69e7a7d718a9804ca2d3f5d439716c79/src/immutabilis.js#L59-L65 | train |
koop-retired/koop-server | lib/SQLite.js | function(name, schema, callback){
var self = this;
this.db.serialize(function() {
self.db.run("CREATE TABLE IF NOT EXISTS\"" + name + "\" " + schema, callback);
});
} | javascript | function(name, schema, callback){
var self = this;
this.db.serialize(function() {
self.db.run("CREATE TABLE IF NOT EXISTS\"" + name + "\" " + schema, callback);
});
} | [
"function",
"(",
"name",
",",
"schema",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"db",
".",
"serialize",
"(",
"function",
"(",
")",
"{",
"self",
".",
"db",
".",
"run",
"(",
"\"CREATE TABLE IF NOT EXISTS\\\"\"",
"+",
"nam... | checks to see in the info table exists, create it if not | [
"checks",
"to",
"see",
"in",
"the",
"info",
"table",
"exists",
"create",
"it",
"if",
"not"
] | 7b4404aa0db92023bfd59b475ad43aa36e02aee8 | https://github.com/koop-retired/koop-server/blob/7b4404aa0db92023bfd59b475ad43aa36e02aee8/lib/SQLite.js#L349-L354 | train | |
mdasberg/angular-test-setup | app/todo/todo.component.po.js | function () {
this.el = element(by.tagName('todo'));
this.available = function() {
return this.el.element(by.binding('$ctrl.todos.length')).getText();
};
this.uncompleted = function() {
return this.el.element(by.binding('$ctrl.uncompleted()')).getText();
};
this.todos = function(... | javascript | function () {
this.el = element(by.tagName('todo'));
this.available = function() {
return this.el.element(by.binding('$ctrl.todos.length')).getText();
};
this.uncompleted = function() {
return this.el.element(by.binding('$ctrl.uncompleted()')).getText();
};
this.todos = function(... | [
"function",
"(",
")",
"{",
"this",
".",
"el",
"=",
"element",
"(",
"by",
".",
"tagName",
"(",
"'todo'",
")",
")",
";",
"this",
".",
"available",
"=",
"function",
"(",
")",
"{",
"return",
"this",
".",
"el",
".",
"element",
"(",
"by",
".",
"binding... | PageObject is an API for the Todo.
@constructor | [
"PageObject",
"is",
"an",
"API",
"for",
"the",
"Todo",
"."
] | 4a1ef0742bac233b94e7c3682e8158c00aa87552 | https://github.com/mdasberg/angular-test-setup/blob/4a1ef0742bac233b94e7c3682e8158c00aa87552/app/todo/todo.component.po.js#L7-L32 | train | |
xiamidaxia/xiami | meteor/mongo-livedata/oplog_observe_driver.js | function (id) {
var self = this;
self._unpublishedBuffer.remove(id);
// To keep the contract "buffer is never empty in STEADY phase unless the
// everything matching fits into published" true, we poll everything as soon
// as we see the buffer becoming empty.
if (! self._unpublishedBuffer.size()... | javascript | function (id) {
var self = this;
self._unpublishedBuffer.remove(id);
// To keep the contract "buffer is never empty in STEADY phase unless the
// everything matching fits into published" true, we poll everything as soon
// as we see the buffer becoming empty.
if (! self._unpublishedBuffer.size()... | [
"function",
"(",
"id",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"_unpublishedBuffer",
".",
"remove",
"(",
"id",
")",
";",
"// To keep the contract \"buffer is never empty in STEADY phase unless the",
"// everything matching fits into published\" true, we poll e... | Is called either to remove the doc completely from matching set or to move it to the published set later. | [
"Is",
"called",
"either",
"to",
"remove",
"the",
"doc",
"completely",
"from",
"matching",
"set",
"or",
"to",
"move",
"it",
"to",
"the",
"published",
"set",
"later",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/mongo-livedata/oplog_observe_driver.js#L286-L294 | train | |
xiamidaxia/xiami | meteor/mongo-livedata/oplog_observe_driver.js | function (doc) {
var self = this;
var id = doc._id;
if (self._published.has(id))
throw Error("tried to add something already published " + id);
if (self._limit && self._unpublishedBuffer.has(id))
throw Error("tried to add something already existed in buffer " + id);
var limit = self._li... | javascript | function (doc) {
var self = this;
var id = doc._id;
if (self._published.has(id))
throw Error("tried to add something already published " + id);
if (self._limit && self._unpublishedBuffer.has(id))
throw Error("tried to add something already existed in buffer " + id);
var limit = self._li... | [
"function",
"(",
"doc",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"id",
"=",
"doc",
".",
"_id",
";",
"if",
"(",
"self",
".",
"_published",
".",
"has",
"(",
"id",
")",
")",
"throw",
"Error",
"(",
"\"tried to add something already published \"",
... | Called when a document has joined the "Matching" results set. Takes responsibility of keeping _unpublishedBuffer in sync with _published and the effect of limit enforced. | [
"Called",
"when",
"a",
"document",
"has",
"joined",
"the",
"Matching",
"results",
"set",
".",
"Takes",
"responsibility",
"of",
"keeping",
"_unpublishedBuffer",
"in",
"sync",
"with",
"_published",
"and",
"the",
"effect",
"of",
"limit",
"enforced",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/mongo-livedata/oplog_observe_driver.js#L298-L339 | train | |
xiamidaxia/xiami | meteor/mongo-livedata/oplog_observe_driver.js | function (id) {
var self = this;
if (! self._published.has(id) && ! self._limit)
throw Error("tried to remove something matching but not cached " + id);
if (self._published.has(id)) {
self._removePublished(id);
} else if (self._unpublishedBuffer.has(id)) {
self._removeBuffered(id);
... | javascript | function (id) {
var self = this;
if (! self._published.has(id) && ! self._limit)
throw Error("tried to remove something matching but not cached " + id);
if (self._published.has(id)) {
self._removePublished(id);
} else if (self._unpublishedBuffer.has(id)) {
self._removeBuffered(id);
... | [
"function",
"(",
"id",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"self",
".",
"_published",
".",
"has",
"(",
"id",
")",
"&&",
"!",
"self",
".",
"_limit",
")",
"throw",
"Error",
"(",
"\"tried to remove something matching but not cached \"",... | Called when a document leaves the "Matching" results set. Takes responsibility of keeping _unpublishedBuffer in sync with _published and the effect of limit enforced. | [
"Called",
"when",
"a",
"document",
"leaves",
"the",
"Matching",
"results",
"set",
".",
"Takes",
"responsibility",
"of",
"keeping",
"_unpublishedBuffer",
"in",
"sync",
"with",
"_published",
"and",
"the",
"effect",
"of",
"limit",
"enforced",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/mongo-livedata/oplog_observe_driver.js#L343-L353 | train | |
xiamidaxia/xiami | meteor/mongo-livedata/oplog_observe_driver.js | function () {
var self = this;
if (self._stopped)
return;
self._stopped = true;
_.each(self._stopHandles, function (handle) {
handle.stop();
});
// Note: we *don't* use multiplexer.onFlush here because this stop
// callback is actually invoked by the multiplexer itself when it h... | javascript | function () {
var self = this;
if (self._stopped)
return;
self._stopped = true;
_.each(self._stopHandles, function (handle) {
handle.stop();
});
// Note: we *don't* use multiplexer.onFlush here because this stop
// callback is actually invoked by the multiplexer itself when it h... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"self",
".",
"_stopped",
")",
"return",
";",
"self",
".",
"_stopped",
"=",
"true",
";",
"_",
".",
"each",
"(",
"self",
".",
"_stopHandles",
",",
"function",
"(",
"handle",
")",
... | This stop function is invoked from the onStop of the ObserveMultiplexer, so it shouldn't actually be possible to call it until the multiplexer is ready. | [
"This",
"stop",
"function",
"is",
"invoked",
"from",
"the",
"onStop",
"of",
"the",
"ObserveMultiplexer",
"so",
"it",
"shouldn",
"t",
"actually",
"be",
"possible",
"to",
"call",
"it",
"until",
"the",
"multiplexer",
"is",
"ready",
"."
] | 6fcee92c493c12bf8fd67c7068e67fa6a72a306b | https://github.com/xiamidaxia/xiami/blob/6fcee92c493c12bf8fd67c7068e67fa6a72a306b/meteor/mongo-livedata/oplog_observe_driver.js#L797-L826 | train | |
gameclosure/jash | src/jash.js | addBinaries | function addBinaries(binaries) {
var SLICE = Array.prototype.slice;
//iterate backwards to mimic normal resolution order
for (var i = binaries.length-1; i >= 0; i--) {
var parts = binaries[i].split('/');
(function() {var name = parts[parts.length-1];
exports[name] = function() {
//grab the last argument, w... | javascript | function addBinaries(binaries) {
var SLICE = Array.prototype.slice;
//iterate backwards to mimic normal resolution order
for (var i = binaries.length-1; i >= 0; i--) {
var parts = binaries[i].split('/');
(function() {var name = parts[parts.length-1];
exports[name] = function() {
//grab the last argument, w... | [
"function",
"addBinaries",
"(",
"binaries",
")",
"{",
"var",
"SLICE",
"=",
"Array",
".",
"prototype",
".",
"slice",
";",
"//iterate backwards to mimic normal resolution order",
"for",
"(",
"var",
"i",
"=",
"binaries",
".",
"length",
"-",
"1",
";",
"i",
">=",
... | for all the binaries in the path, setup a proxy function with the binary's name that will execute it. | [
"for",
"all",
"the",
"binaries",
"in",
"the",
"path",
"setup",
"a",
"proxy",
"function",
"with",
"the",
"binary",
"s",
"name",
"that",
"will",
"execute",
"it",
"."
] | 93bcffcc2392b168538834ec8d01b172121a8c09 | https://github.com/gameclosure/jash/blob/93bcffcc2392b168538834ec8d01b172121a8c09/src/jash.js#L115-L160 | train |
lordfpx/AB | index.js | function() {
var extended = {},
deep = false,
i = 0,
length = arguments.length;
if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]'){
deep = arguments[0];
i++;
}
var merge = function(obj) {
for (var prop in obj) {
if (O... | javascript | function() {
var extended = {},
deep = false,
i = 0,
length = arguments.length;
if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]'){
deep = arguments[0];
i++;
}
var merge = function(obj) {
for (var prop in obj) {
if (O... | [
"function",
"(",
")",
"{",
"var",
"extended",
"=",
"{",
"}",
",",
"deep",
"=",
"false",
",",
"i",
"=",
"0",
",",
"length",
"=",
"arguments",
".",
"length",
";",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"arguments",
... | deep extend function | [
"deep",
"extend",
"function"
] | 05efbec0758b77dd1e146805437f132d1398c7d9 | https://github.com/lordfpx/AB/blob/05efbec0758b77dd1e146805437f132d1398c7d9/index.js#L17-L45 | train | |
idiocc/core | build/lib/start-app.js | createApp | async function createApp(middlewareConfig) {
const app = new Koa()
const middleware = await setupMiddleware(middlewareConfig, app)
if (app.env == 'production') {
app.proxy = true
}
return {
app,
middleware,
}
} | javascript | async function createApp(middlewareConfig) {
const app = new Koa()
const middleware = await setupMiddleware(middlewareConfig, app)
if (app.env == 'production') {
app.proxy = true
}
return {
app,
middleware,
}
} | [
"async",
"function",
"createApp",
"(",
"middlewareConfig",
")",
"{",
"const",
"app",
"=",
"new",
"Koa",
"(",
")",
"const",
"middleware",
"=",
"await",
"setupMiddleware",
"(",
"middlewareConfig",
",",
"app",
")",
"if",
"(",
"app",
".",
"env",
"==",
"'produc... | Create an application and setup middleware.
@param {MiddlewareConfig} middlewareConfig | [
"Create",
"an",
"application",
"and",
"setup",
"middleware",
"."
] | 27aa14cf339b783777b6523670629ea40955bf3c | https://github.com/idiocc/core/blob/27aa14cf339b783777b6523670629ea40955bf3c/build/lib/start-app.js#L12-L25 | train |
alexander-heimbuch/utterson | pipe/plumber.js | function (defaults, attr, custom) {
var resolvedPath;
if (defaults === undefined || defaults[attr] === undefined) {
throw new Error('Missing Parameter', 'Expect a given defaults object');
}
if (attr === undefined) {
throw new Error('Missing Parameter', 'Expect a... | javascript | function (defaults, attr, custom) {
var resolvedPath;
if (defaults === undefined || defaults[attr] === undefined) {
throw new Error('Missing Parameter', 'Expect a given defaults object');
}
if (attr === undefined) {
throw new Error('Missing Parameter', 'Expect a... | [
"function",
"(",
"defaults",
",",
"attr",
",",
"custom",
")",
"{",
"var",
"resolvedPath",
";",
"if",
"(",
"defaults",
"===",
"undefined",
"||",
"defaults",
"[",
"attr",
"]",
"===",
"undefined",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Missing Parameter'",... | Retrieving a resolved path from defaults or custom options
@param {Object} defaults Fallback options
@param {String} attr Attribute to be resolved
@param {Object} custom Custom options
@return {String} Resolved path from custom options or default if undefined | [
"Retrieving",
"a",
"resolved",
"path",
"from",
"defaults",
"or",
"custom",
"options"
] | e4c03f48c50c656990774d55494db966d3f8992f | https://github.com/alexander-heimbuch/utterson/blob/e4c03f48c50c656990774d55494db966d3f8992f/pipe/plumber.js#L21-L39 | train | |
alexander-heimbuch/utterson | pipe/plumber.js | function (content, type) {
var results = {};
if (content === undefined) {
return results;
}
_.forEach(content, function (element, key) {
if (element === undefined || element.type === undefined || element.type !== type) {
return;
}
... | javascript | function (content, type) {
var results = {};
if (content === undefined) {
return results;
}
_.forEach(content, function (element, key) {
if (element === undefined || element.type === undefined || element.type !== type) {
return;
}
... | [
"function",
"(",
"content",
",",
"type",
")",
"{",
"var",
"results",
"=",
"{",
"}",
";",
"if",
"(",
"content",
"===",
"undefined",
")",
"{",
"return",
"results",
";",
"}",
"_",
".",
"forEach",
"(",
"content",
",",
"function",
"(",
"element",
",",
"... | Sorts out a given type of content containers from the pipe
@param {Object} content Pipe content
@param {String} type Type of content to sort out (e.g. Pages, Posts or Statics)
@return {Object} Object containing only content containers from a given type | [
"Sorts",
"out",
"a",
"given",
"type",
"of",
"content",
"containers",
"from",
"the",
"pipe"
] | e4c03f48c50c656990774d55494db966d3f8992f | https://github.com/alexander-heimbuch/utterson/blob/e4c03f48c50c656990774d55494db966d3f8992f/pipe/plumber.js#L47-L63 | train | |
alexander-heimbuch/utterson | pipe/plumber.js | function (content, type) {
var results = [];
if (content === undefined) {
return results;
}
_.forEach(content, function (element) {
if (element === undefined || element.type === undefined || element.type !== type) {
return;
}
... | javascript | function (content, type) {
var results = [];
if (content === undefined) {
return results;
}
_.forEach(content, function (element) {
if (element === undefined || element.type === undefined || element.type !== type) {
return;
}
... | [
"function",
"(",
"content",
",",
"type",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"content",
"===",
"undefined",
")",
"{",
"return",
"results",
";",
"}",
"_",
".",
"forEach",
"(",
"content",
",",
"function",
"(",
"element",
")",
"... | Filters a given type of content files from the pipe
@param {Object} content Pipe content
@param {String} type Type of content to sort out (e.g. Pages, Posts or Statics)
@return {Array} Object containing single content files from a given type | [
"Filters",
"a",
"given",
"type",
"of",
"content",
"files",
"from",
"the",
"pipe"
] | e4c03f48c50c656990774d55494db966d3f8992f | https://github.com/alexander-heimbuch/utterson/blob/e4c03f48c50c656990774d55494db966d3f8992f/pipe/plumber.js#L71-L95 | train | |
alexander-heimbuch/utterson | pipe/plumber.js | function (file, parent, type) {
var fileDetails = path.parse(file),
filePath = (type === 'static') ?
path.join(fileDetails.dir, fileDetails.name + fileDetails.ext) :
path.join(fileDetails.dir, fileDetails.name);
return {
name: filePath,
... | javascript | function (file, parent, type) {
var fileDetails = path.parse(file),
filePath = (type === 'static') ?
path.join(fileDetails.dir, fileDetails.name + fileDetails.ext) :
path.join(fileDetails.dir, fileDetails.name);
return {
name: filePath,
... | [
"function",
"(",
"file",
",",
"parent",
",",
"type",
")",
"{",
"var",
"fileDetails",
"=",
"path",
".",
"parse",
"(",
"file",
")",
",",
"filePath",
"=",
"(",
"type",
"===",
"'static'",
")",
"?",
"path",
".",
"join",
"(",
"fileDetails",
".",
"dir",
"... | Resolves relative parent and own name of a specific file
@param {String} file Path to corresponding file
@param {String} parent Parent relative to the corresponding file
@param {String} type Type of the corresponding file [post, page, static]
@return {Object} Object containing single conte... | [
"Resolves",
"relative",
"parent",
"and",
"own",
"name",
"of",
"a",
"specific",
"file"
] | e4c03f48c50c656990774d55494db966d3f8992f | https://github.com/alexander-heimbuch/utterson/blob/e4c03f48c50c656990774d55494db966d3f8992f/pipe/plumber.js#L104-L115 | train | |
meltmedia/node-usher | lib/decider/tasks/accumulator.js | Accumulator | function Accumulator(name, deps, fragment, resultsFn, options) {
if (!(this instanceof Accumulator)) {
return new Accumulator(name, deps, fragment, resultsFn, options);
}
Task.apply(this, Array.prototype.slice.call(arguments));
this.fragment = fragment;
if (!_.isFunction(resultsFn)) {
throw new Err... | javascript | function Accumulator(name, deps, fragment, resultsFn, options) {
if (!(this instanceof Accumulator)) {
return new Accumulator(name, deps, fragment, resultsFn, options);
}
Task.apply(this, Array.prototype.slice.call(arguments));
this.fragment = fragment;
if (!_.isFunction(resultsFn)) {
throw new Err... | [
"function",
"Accumulator",
"(",
"name",
",",
"deps",
",",
"fragment",
",",
"resultsFn",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Accumulator",
")",
")",
"{",
"return",
"new",
"Accumulator",
"(",
"name",
",",
"deps",
",",
"f... | The Accumulator loop executes the `fragment` until the `resultsFn` returns an empty array,
the results of each execution are then pushed into an array via the `resultsFn` for use by other tasks.
@constructor | [
"The",
"Accumulator",
"loop",
"executes",
"the",
"fragment",
"until",
"the",
"resultsFn",
"returns",
"an",
"empty",
"array",
"the",
"results",
"of",
"each",
"execution",
"are",
"then",
"pushed",
"into",
"an",
"array",
"via",
"the",
"resultsFn",
"for",
"use",
... | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/decider/tasks/accumulator.js#L26-L41 | train |
bigpipe/500-pagelet | index.js | constructor | function constructor(options, error, name) {
Pagelet.prototype.constructor.call(this, options);
if (name) this.name = name;
this.data = error instanceof Error ? error : {};
} | javascript | function constructor(options, error, name) {
Pagelet.prototype.constructor.call(this, options);
if (name) this.name = name;
this.data = error instanceof Error ? error : {};
} | [
"function",
"constructor",
"(",
"options",
",",
"error",
",",
"name",
")",
"{",
"Pagelet",
".",
"prototype",
".",
"constructor",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"if",
"(",
"name",
")",
"this",
".",
"name",
"=",
"name",
";",
"this"... | Extend the default constructor to allow second data parameter.
@param {Object} options Optional options.
@param {Error} error Error data and stack.
@param {String} name Pagelet name that the Error pagelet replaces.
@api public | [
"Extend",
"the",
"default",
"constructor",
"to",
"allow",
"second",
"data",
"parameter",
"."
] | cf0b3c46603064df50a16d86d6e78237d6f1f345 | https://github.com/bigpipe/500-pagelet/blob/cf0b3c46603064df50a16d86d6e78237d6f1f345/index.js#L25-L30 | train |
bigpipe/500-pagelet | index.js | get | function get(render) {
render(null, {
env: this.env,
message: this.data.message,
stack: this.env !== 'production' ? this.data.stack : ''
});
} | javascript | function get(render) {
render(null, {
env: this.env,
message: this.data.message,
stack: this.env !== 'production' ? this.data.stack : ''
});
} | [
"function",
"get",
"(",
"render",
")",
"{",
"render",
"(",
"null",
",",
"{",
"env",
":",
"this",
".",
"env",
",",
"message",
":",
"this",
".",
"data",
".",
"message",
",",
"stack",
":",
"this",
".",
"env",
"!==",
"'production'",
"?",
"this",
".",
... | Return available data depending on environment settings.
@param {Function} render Completion callback.
@api private | [
"Return",
"available",
"data",
"depending",
"on",
"environment",
"settings",
"."
] | cf0b3c46603064df50a16d86d6e78237d6f1f345 | https://github.com/bigpipe/500-pagelet/blob/cf0b3c46603064df50a16d86d6e78237d6f1f345/index.js#L38-L44 | train |
damsonjs/damson-server-core | index.js | pushTask | function pushTask(client, task) {
/*jshint validthis: true */
if (!this.tasks[client]) {
this.tasks[client] = [];
}
this.tasks[client].push(task);
} | javascript | function pushTask(client, task) {
/*jshint validthis: true */
if (!this.tasks[client]) {
this.tasks[client] = [];
}
this.tasks[client].push(task);
} | [
"function",
"pushTask",
"(",
"client",
",",
"task",
")",
"{",
"/*jshint validthis: true */",
"if",
"(",
"!",
"this",
".",
"tasks",
"[",
"client",
"]",
")",
"{",
"this",
".",
"tasks",
"[",
"client",
"]",
"=",
"[",
"]",
";",
"}",
"this",
".",
"tasks",
... | Pushes task for client.
@param {string} client Client identificator
@param {object} task Task information
@param {string} task.task_name Damson task name
@param {object} task.options Damson task arguments
@param {string} task.driver_name Damson driver name | [
"Pushes",
"task",
"for",
"client",
"."
] | 4490d8140dc585b0e55b1beb8d6db013445bbc94 | https://github.com/damsonjs/damson-server-core/blob/4490d8140dc585b0e55b1beb8d6db013445bbc94/index.js#L11-L17 | train |
sendanor/nor-nopg | src/Cache.js | Cache | function Cache(opts) {
//debug.log('new Cache');
opts = opts || {};
debug.assert(opts).is('object');
/** {boolean} True if this cache is using cursors */
this._has_cursors = opts.cursors ? true : false;
// All cursors in a VariableStore
if(this._has_cursors) {
this._cursors = new VariableStore();
this._pa... | javascript | function Cache(opts) {
//debug.log('new Cache');
opts = opts || {};
debug.assert(opts).is('object');
/** {boolean} True if this cache is using cursors */
this._has_cursors = opts.cursors ? true : false;
// All cursors in a VariableStore
if(this._has_cursors) {
this._cursors = new VariableStore();
this._pa... | [
"function",
"Cache",
"(",
"opts",
")",
"{",
"//debug.log('new Cache');",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"debug",
".",
"assert",
"(",
"opts",
")",
".",
"is",
"(",
"'object'",
")",
";",
"/** {boolean} True if this cache is using cursors */",
"this",
"... | The cache object | [
"The",
"cache",
"object"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/Cache.js#L11-L36 | train |
vkiding/judpack-lib | src/plugman/platforms/common.js | function(plugin_dir, src, project_dir, dest, link) {
var target_path = common.resolveTargetPath(project_dir, dest);
if (fs.existsSync(target_path))
throw new Error('"' + target_path + '" already exists!');
common.copyFile(plugin_dir, src, project_dir, dest, !!link);
} | javascript | function(plugin_dir, src, project_dir, dest, link) {
var target_path = common.resolveTargetPath(project_dir, dest);
if (fs.existsSync(target_path))
throw new Error('"' + target_path + '" already exists!');
common.copyFile(plugin_dir, src, project_dir, dest, !!link);
} | [
"function",
"(",
"plugin_dir",
",",
"src",
",",
"project_dir",
",",
"dest",
",",
"link",
")",
"{",
"var",
"target_path",
"=",
"common",
".",
"resolveTargetPath",
"(",
"project_dir",
",",
"dest",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"target_... | Same as copy file but throws error if target exists | [
"Same",
"as",
"copy",
"file",
"but",
"throws",
"error",
"if",
"target",
"exists"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/plugman/platforms/common.js#L96-L102 | train | |
manvalls/iku-hub | server.js | Peer | function Peer(internalPeer){
Emitter.Target.call(this,emitter);
this[rooms] = {};
this[pids] = {};
this[ip] = internalPeer;
plugins.give('peer',this);
} | javascript | function Peer(internalPeer){
Emitter.Target.call(this,emitter);
this[rooms] = {};
this[pids] = {};
this[ip] = internalPeer;
plugins.give('peer',this);
} | [
"function",
"Peer",
"(",
"internalPeer",
")",
"{",
"Emitter",
".",
"Target",
".",
"call",
"(",
"this",
",",
"emitter",
")",
";",
"this",
"[",
"rooms",
"]",
"=",
"{",
"}",
";",
"this",
"[",
"pids",
"]",
"=",
"{",
"}",
";",
"this",
"[",
"ip",
"]"... | External Peer object | [
"External",
"Peer",
"object"
] | ce7bf254e05f9e901b61bb0370cfa0b8f21a56aa | https://github.com/manvalls/iku-hub/blob/ce7bf254e05f9e901b61bb0370cfa0b8f21a56aa/server.js#L484-L492 | train |
redisjs/jsr-server | lib/info.js | Info | function Info(state) {
this.state = state;
this.conf = state.conf;
this.stats = state.stats;
this.name = pkg.name;
this.version = pkg.version;
} | javascript | function Info(state) {
this.state = state;
this.conf = state.conf;
this.stats = state.stats;
this.name = pkg.name;
this.version = pkg.version;
} | [
"function",
"Info",
"(",
"state",
")",
"{",
"this",
".",
"state",
"=",
"state",
";",
"this",
".",
"conf",
"=",
"state",
".",
"conf",
";",
"this",
".",
"stats",
"=",
"state",
".",
"stats",
";",
"this",
".",
"name",
"=",
"pkg",
".",
"name",
";",
... | Encapsulates server information. | [
"Encapsulates",
"server",
"information",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L32-L38 | train |
redisjs/jsr-server | lib/info.js | getServer | function getServer() {
var o = {}
, uptime = process.uptime()
o.version = this.version;
o.os = process.platform;
o.arch = process.arch;
o.process_id = process.pid;
o.tcp_port = this.state.addr && this.state.addr.port
? this.state.addr.port : NA;
o.uptime_in_seconds = uptime;
o.uptime_in_days =... | javascript | function getServer() {
var o = {}
, uptime = process.uptime()
o.version = this.version;
o.os = process.platform;
o.arch = process.arch;
o.process_id = process.pid;
o.tcp_port = this.state.addr && this.state.addr.port
? this.state.addr.port : NA;
o.uptime_in_seconds = uptime;
o.uptime_in_days =... | [
"function",
"getServer",
"(",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"uptime",
"=",
"process",
".",
"uptime",
"(",
")",
"o",
".",
"version",
"=",
"this",
".",
"version",
";",
"o",
".",
"os",
"=",
"process",
".",
"platform",
";",
"o",
".",
"a... | Get server info section. | [
"Get",
"server",
"info",
"section",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L57-L73 | train |
redisjs/jsr-server | lib/info.js | getMemory | function getMemory(rusage) {
var o = {}, mem = process.memoryUsage();
o.used_memory = mem.heapUsed;
o.used_memory_human = bytes.humanize(mem.heapUsed, 2, true);
o.used_memory_rss = mem.rss;
o.used_memory_peak = rusage.maxrss;
o.used_memory_peak_human = bytes.humanize(rusage.maxrss, 2, true);
return o;
} | javascript | function getMemory(rusage) {
var o = {}, mem = process.memoryUsage();
o.used_memory = mem.heapUsed;
o.used_memory_human = bytes.humanize(mem.heapUsed, 2, true);
o.used_memory_rss = mem.rss;
o.used_memory_peak = rusage.maxrss;
o.used_memory_peak_human = bytes.humanize(rusage.maxrss, 2, true);
return o;
} | [
"function",
"getMemory",
"(",
"rusage",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"mem",
"=",
"process",
".",
"memoryUsage",
"(",
")",
";",
"o",
".",
"used_memory",
"=",
"mem",
".",
"heapUsed",
";",
"o",
".",
"used_memory_human",
"=",
"bytes",
".",
... | Get memory info section. | [
"Get",
"memory",
"info",
"section",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L87-L95 | train |
redisjs/jsr-server | lib/info.js | getStats | function getStats() {
var o = {};
o.total_connections_received = this.stats.connections;
o.total_commands_processed = this.stats.commands;
o.total_net_input_bytes = this.stats.ibytes;
o.total_net_output_bytes = this.stats.obytes;
o.rejected_connections = this.stats.rejected;
o.expired_keys = this.stats.... | javascript | function getStats() {
var o = {};
o.total_connections_received = this.stats.connections;
o.total_commands_processed = this.stats.commands;
o.total_net_input_bytes = this.stats.ibytes;
o.total_net_output_bytes = this.stats.obytes;
o.rejected_connections = this.stats.rejected;
o.expired_keys = this.stats.... | [
"function",
"getStats",
"(",
")",
"{",
"var",
"o",
"=",
"{",
"}",
";",
"o",
".",
"total_connections_received",
"=",
"this",
".",
"stats",
".",
"connections",
";",
"o",
".",
"total_commands_processed",
"=",
"this",
".",
"stats",
".",
"commands",
";",
"o",... | Get stats info section. | [
"Get",
"stats",
"info",
"section",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L108-L125 | train |
redisjs/jsr-server | lib/info.js | getCpu | function getCpu(rusage) {
var o = {};
//console.dir(rusage);
o.used_cpu_sys = rusage.stime.toFixed(2);
o.used_cpu_user = rusage.utime.toFixed(2);
return o;
} | javascript | function getCpu(rusage) {
var o = {};
//console.dir(rusage);
o.used_cpu_sys = rusage.stime.toFixed(2);
o.used_cpu_user = rusage.utime.toFixed(2);
return o;
} | [
"function",
"getCpu",
"(",
"rusage",
")",
"{",
"var",
"o",
"=",
"{",
"}",
";",
"//console.dir(rusage);",
"o",
".",
"used_cpu_sys",
"=",
"rusage",
".",
"stime",
".",
"toFixed",
"(",
"2",
")",
";",
"o",
".",
"used_cpu_user",
"=",
"rusage",
".",
"utime",
... | Get cpu info section. | [
"Get",
"cpu",
"info",
"section",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L138-L144 | train |
redisjs/jsr-server | lib/info.js | getKeyspace | function getKeyspace() {
var o = {}
, i
, db
, size;
for(i in this.state.store.databases) {
db = this.state.store.databases[i];
size = db.dbsize();
if(size) {
o['db' + i] = util.format('keys=%s,expires=%s', size, db.expiring);
}
}
return o;
} | javascript | function getKeyspace() {
var o = {}
, i
, db
, size;
for(i in this.state.store.databases) {
db = this.state.store.databases[i];
size = db.dbsize();
if(size) {
o['db' + i] = util.format('keys=%s,expires=%s', size, db.expiring);
}
}
return o;
} | [
"function",
"getKeyspace",
"(",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"i",
",",
"db",
",",
"size",
";",
"for",
"(",
"i",
"in",
"this",
".",
"state",
".",
"store",
".",
"databases",
")",
"{",
"db",
"=",
"this",
".",
"state",
".",
"store",
... | Get keyspace info section. | [
"Get",
"keyspace",
"info",
"section",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L149-L162 | train |
redisjs/jsr-server | lib/info.js | getObject | function getObject(section) {
var o = {}
, i
, k
, name
, method
, sections = section ? [section] : keys
, rusage = proc.usage();
for(i = 0;i < sections.length;i++) {
k = sections[i];
name = k.charAt(0).toUpperCase() + k.substr(1);
method = 'get' + name
o[k] = {
header... | javascript | function getObject(section) {
var o = {}
, i
, k
, name
, method
, sections = section ? [section] : keys
, rusage = proc.usage();
for(i = 0;i < sections.length;i++) {
k = sections[i];
name = k.charAt(0).toUpperCase() + k.substr(1);
method = 'get' + name
o[k] = {
header... | [
"function",
"getObject",
"(",
"section",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"i",
",",
"k",
",",
"name",
",",
"method",
",",
"sections",
"=",
"section",
"?",
"[",
"section",
"]",
":",
"keys",
",",
"rusage",
"=",
"proc",
".",
"usage",
"(",
... | Get an info object. | [
"Get",
"an",
"info",
"object",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/info.js#L174-L193 | train |
redisjs/jsr-server | lib/command/server/time.js | execute | function execute(req, res) {
var t = systime();
res.send(null, [t.s, t.m]);
} | javascript | function execute(req, res) {
var t = systime();
res.send(null, [t.s, t.m]);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"var",
"t",
"=",
"systime",
"(",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"[",
"t",
".",
"s",
",",
"t",
".",
"m",
"]",
")",
";",
"}"
] | Respond to the TIME command. | [
"Respond",
"to",
"the",
"TIME",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/time.js#L18-L21 | train |
Becklyn/becklyn-gulp | lib/path-helper.js | function (filePath)
{
if (0 === filePath.indexOf(process.cwd()))
{
filePath = path.relative(process.cwd(), filePath);
}
if (0 !== filePath.indexOf("./") && 0 !== filePath.indexOf("/"))
{
filePath = "./" + filePath;
}
return filePath;
... | javascript | function (filePath)
{
if (0 === filePath.indexOf(process.cwd()))
{
filePath = path.relative(process.cwd(), filePath);
}
if (0 !== filePath.indexOf("./") && 0 !== filePath.indexOf("/"))
{
filePath = "./" + filePath;
}
return filePath;
... | [
"function",
"(",
"filePath",
")",
"{",
"if",
"(",
"0",
"===",
"filePath",
".",
"indexOf",
"(",
"process",
".",
"cwd",
"(",
")",
")",
")",
"{",
"filePath",
"=",
"path",
".",
"relative",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"filePath",
")",
"... | Makes the file path relative
@param {string} filePath
@returns {string} | [
"Makes",
"the",
"file",
"path",
"relative"
] | 1c633378d561f07101f9db19ccd153617b8e0252 | https://github.com/Becklyn/becklyn-gulp/blob/1c633378d561f07101f9db19ccd153617b8e0252/lib/path-helper.js#L13-L26 | train | |
Chieze-Franklin/bolt-internal-utils | utils-cov.js | function(body, error, code, errorTraceId, errorUserTitle, errorUserMessage) {
_$jscmd("utils.js", "line", 104);
//TODO: support errorTraceId
//TODO: errorUserTitle and errorUserMessage should be change from strings to ints (==code) to support localization
var response = {... | javascript | function(body, error, code, errorTraceId, errorUserTitle, errorUserMessage) {
_$jscmd("utils.js", "line", 104);
//TODO: support errorTraceId
//TODO: errorUserTitle and errorUserMessage should be change from strings to ints (==code) to support localization
var response = {... | [
"function",
"(",
"body",
",",
"error",
",",
"code",
",",
"errorTraceId",
",",
"errorUserTitle",
",",
"errorUserMessage",
")",
"{",
"_$jscmd",
"(",
"\"utils.js\"",
",",
"\"line\"",
",",
"104",
")",
";",
"//TODO: support errorTraceId",
"//TODO: errorUserTitle and erro... | constructs an appropriate response object | [
"constructs",
"an",
"appropriate",
"response",
"object"
] | 4d250d2384f1a02ac0b9994e5341f0829bf4c683 | https://github.com/Chieze-Franklin/bolt-internal-utils/blob/4d250d2384f1a02ac0b9994e5341f0829bf4c683/utils-cov.js#L201-L237 | train | |
ottojs/otto-errors | lib/not_found.error.js | ErrorNotFound | function ErrorNotFound (message, data) {
Error.call(this);
// Add Information
this.name = 'ErrorNotFound';
this.type = 'client';
this.status = 404;
if (message) {
this.message = message;
}
if (data) {
this.data = {};
if (data.method) { this.data.method = data.method; }
if (dat... | javascript | function ErrorNotFound (message, data) {
Error.call(this);
// Add Information
this.name = 'ErrorNotFound';
this.type = 'client';
this.status = 404;
if (message) {
this.message = message;
}
if (data) {
this.data = {};
if (data.method) { this.data.method = data.method; }
if (dat... | [
"function",
"ErrorNotFound",
"(",
"message",
",",
"data",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"// Add Information",
"this",
".",
"name",
"=",
"'ErrorNotFound'",
";",
"this",
".",
"type",
"=",
"'client'",
";",
"this",
".",
"status",
"="... | Error - ErrorNotFound | [
"Error",
"-",
"ErrorNotFound"
] | a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9 | https://github.com/ottojs/otto-errors/blob/a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9/lib/not_found.error.js#L8-L27 | train |
andrewscwei/requiem | src/dom/hasChild.js | hasChild | function hasChild(child, element) {
assert(child !== undefined, 'Child is undefined');
assertType(element, Node, true, 'Parameter \'element\', if specified, must be a Node');
if (typeof child === 'string') {
return !noval(getChild(element, child, true));
}
else {
if (!element || element === window ||... | javascript | function hasChild(child, element) {
assert(child !== undefined, 'Child is undefined');
assertType(element, Node, true, 'Parameter \'element\', if specified, must be a Node');
if (typeof child === 'string') {
return !noval(getChild(element, child, true));
}
else {
if (!element || element === window ||... | [
"function",
"hasChild",
"(",
"child",
",",
"element",
")",
"{",
"assert",
"(",
"child",
"!==",
"undefined",
",",
"'Child is undefined'",
")",
";",
"assertType",
"(",
"element",
",",
"Node",
",",
"true",
",",
"'Parameter \\'element\\', if specified, must be a Node'",... | Determines if an element contains the specified child.
@param {Node|string} child - A child is a Node. It can also be a string of
child name(s) separated by '.'.
@param {Node} [element] - Specifies the parent Node to fetch the child from.
@return {boolean} True if this element has the specified child, false
otherwise... | [
"Determines",
"if",
"an",
"element",
"contains",
"the",
"specified",
"child",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/hasChild.js#L22-L40 | train |
9fv/node-is-port-reachable | .gulp/tasks/lint.js | lint | function lint(p) {
return () => {
gulp.src(p).pipe(g.eslint())
.pipe(g.eslint.format())
.pipe(g.eslint.failOnError());
};
} | javascript | function lint(p) {
return () => {
gulp.src(p).pipe(g.eslint())
.pipe(g.eslint.format())
.pipe(g.eslint.failOnError());
};
} | [
"function",
"lint",
"(",
"p",
")",
"{",
"return",
"(",
")",
"=>",
"{",
"gulp",
".",
"src",
"(",
"p",
")",
".",
"pipe",
"(",
"g",
".",
"eslint",
"(",
")",
")",
".",
"pipe",
"(",
"g",
".",
"eslint",
".",
"format",
"(",
")",
")",
".",
"pipe",
... | Lint source.
@param p {string} - Path and pattern.
@returns {void|*} | [
"Lint",
"source",
"."
] | 5c0c325b2f10255616603ee85900faa83bfb7834 | https://github.com/9fv/node-is-port-reachable/blob/5c0c325b2f10255616603ee85900faa83bfb7834/.gulp/tasks/lint.js#L13-L19 | train |
rkamradt/meta-app-mongo | index.js | function(data, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var key = data[this._key];
var self = this;
this._getCollection(function(err) {
if(err) {
done(err);
}
var kobj = {};
kobj[self._key.getName()] = k... | javascript | function(data, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var key = data[this._key];
var self = this;
this._getCollection(function(err) {
if(err) {
done(err);
}
var kobj = {};
kobj[self._key.getName()] = k... | [
"function",
"(",
"data",
",",
"done",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_key",
")",
"{",
"done",
"(",
"'no key found for metadata'",
")",
";",
"return",
";",
"}",
"var",
"key",
"=",
"data",
"[",
"this",
".",
"_key",
"]",
";",
"var",
"self",
... | update an item by id
@param {String} data The new data
@param {Function} done The callback when done | [
"update",
"an",
"item",
"by",
"id"
] | 330cc805e1547b59e228e179ef0962def7d9f32c | https://github.com/rkamradt/meta-app-mongo/blob/330cc805e1547b59e228e179ef0962def7d9f32c/index.js#L135-L158 | train | |
rkamradt/meta-app-mongo | index.js | function(key, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var self = this;
this._getCollection(function(err) {
if(err) {
done(err);
}
var kobj = {};
kobj[self._key.getName()] = key;
self._collection.find(... | javascript | function(key, done) {
if(!this._key) {
done('no key found for metadata');
return;
}
var self = this;
this._getCollection(function(err) {
if(err) {
done(err);
}
var kobj = {};
kobj[self._key.getName()] = key;
self._collection.find(... | [
"function",
"(",
"key",
",",
"done",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_key",
")",
"{",
"done",
"(",
"'no key found for metadata'",
")",
";",
"return",
";",
"}",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_getCollection",
"(",
"function",
"... | Remove an item by key
@param {String} key The key value
@param {Function} done The callback when done | [
"Remove",
"an",
"item",
"by",
"key"
] | 330cc805e1547b59e228e179ef0962def7d9f32c | https://github.com/rkamradt/meta-app-mongo/blob/330cc805e1547b59e228e179ef0962def7d9f32c/index.js#L164-L187 | train | |
tx4x/git-module | lib/modules.js | addRepository | function addRepository(name, rep, directory, gitOptions, options) {
var userConfig = options || {};
REPOSITORIES.push(_.extend({
name: name,
options: _.extend({
repository: rep,
directory: directory || name
}, gitOptions || {})
... | javascript | function addRepository(name, rep, directory, gitOptions, options) {
var userConfig = options || {};
REPOSITORIES.push(_.extend({
name: name,
options: _.extend({
repository: rep,
directory: directory || name
}, gitOptions || {})
... | [
"function",
"addRepository",
"(",
"name",
",",
"rep",
",",
"directory",
",",
"gitOptions",
",",
"options",
")",
"{",
"var",
"userConfig",
"=",
"options",
"||",
"{",
"}",
";",
"REPOSITORIES",
".",
"push",
"(",
"_",
".",
"extend",
"(",
"{",
"name",
":",
... | Helper function to add a new repo to our module list.
@param name {string} That is the unique name of the module.
@param rep {string} The repository url.
@param directory {null|string} The target directory to clone the module into.
@param gitOptions {null|object} A mixin to override default git options for the module a... | [
"Helper",
"function",
"to",
"add",
"a",
"new",
"repo",
"to",
"our",
"module",
"list",
"."
] | 93ff14eecb00c5c140f3e6413bd43404cc1dd021 | https://github.com/tx4x/git-module/blob/93ff14eecb00c5c140f3e6413bd43404cc1dd021/lib/modules.js#L44-L54 | train |
GregBee2/xassist-csv | src/csv.js | checkCRLF | function checkCRLF() {
/*function check if the current character is NEWLINE or RETURN
if RETURN it checks if the next is NEWLINE (CRLF)
afterwards it sets the charIndex after the NEWLINE, RETURN OR CRLF and currentCharacter to the character at index charIndex*/
//check if current character at charIndex ... | javascript | function checkCRLF() {
/*function check if the current character is NEWLINE or RETURN
if RETURN it checks if the next is NEWLINE (CRLF)
afterwards it sets the charIndex after the NEWLINE, RETURN OR CRLF and currentCharacter to the character at index charIndex*/
//check if current character at charIndex ... | [
"function",
"checkCRLF",
"(",
")",
"{",
"/*function check if the current character is NEWLINE or RETURN\n\t\t\t\tif RETURN it checks if the next is NEWLINE (CRLF)\n\t\t\t\tafterwards it sets the charIndex after the NEWLINE, RETURN OR CRLF and currentCharacter to the character at index charIndex*/",
"//c... | Unescape quotes. | [
"Unescape",
"quotes",
"."
] | a80619da9d0bff5af1cd503ad0b9697667548b5e | https://github.com/GregBee2/xassist-csv/blob/a80619da9d0bff5af1cd503ad0b9697667548b5e/src/csv.js#L270-L286 | train |
redisjs/jsr-server | lib/command/database/key/rename.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var source = '' + args[0]
, destination = '' + args[1];
if(!info.db.getKey(args[0], info)) {
throw NoSuchKey;
}else if(source === destination) {
throw SourceDestination;
}
args[0] = source;
args[1... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var source = '' + args[0]
, destination = '' + args[1];
if(!info.db.getKey(args[0], info)) {
throw NoSuchKey;
}else if(source === destination) {
throw SourceDestination;
}
args[0] = source;
args[1... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"source",
"=",
"''",
"+",
"args",
"[",
"0",
"]",
",",
"destina... | Validate the RENAME command. | [
"Validate",
"the",
"RENAME",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/key/rename.js#L20-L33 | train |
andrewscwei/requiem | src/utils/getIntersectRect.js | getIntersectRect | function getIntersectRect() {
let n = arguments.length;
if (!assert(n > 0, 'This method requires at least 1 argument specified.')) return null;
let rect = {};
let currRect, nextRect;
for (let i = 0; i < n; i++) {
if (!currRect) currRect = getRect(arguments[i]);
if (!assert(currRect, 'Invalid compu... | javascript | function getIntersectRect() {
let n = arguments.length;
if (!assert(n > 0, 'This method requires at least 1 argument specified.')) return null;
let rect = {};
let currRect, nextRect;
for (let i = 0; i < n; i++) {
if (!currRect) currRect = getRect(arguments[i]);
if (!assert(currRect, 'Invalid compu... | [
"function",
"getIntersectRect",
"(",
")",
"{",
"let",
"n",
"=",
"arguments",
".",
"length",
";",
"if",
"(",
"!",
"assert",
"(",
"n",
">",
"0",
",",
"'This method requires at least 1 argument specified.'",
")",
")",
"return",
"null",
";",
"let",
"rect",
"=",
... | Computes the intersecting rect of 2 given elements. If only 1 element is
specified, the other element will default to the current viewport.
@param {...Node}
@return {Object} Object containing width, height.
@alias module:requiem~utils.getIntersectRect | [
"Computes",
"the",
"intersecting",
"rect",
"of",
"2",
"given",
"elements",
".",
"If",
"only",
"1",
"element",
"is",
"specified",
"the",
"other",
"element",
"will",
"default",
"to",
"the",
"current",
"viewport",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/utils/getIntersectRect.js#L18-L63 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | executeInitiateBatchTask | function executeInitiateBatchTask(batch, cancellable, context) {
/**
* Defines the initiate batch task (and its sub-tasks) to be used to track the state of the initiating phase.
* @returns {InitiateBatchTaskDef} a new initiate batch task definition (with its sub-task definitions)
*/
function defineInitiate... | javascript | function executeInitiateBatchTask(batch, cancellable, context) {
/**
* Defines the initiate batch task (and its sub-tasks) to be used to track the state of the initiating phase.
* @returns {InitiateBatchTaskDef} a new initiate batch task definition (with its sub-task definitions)
*/
function defineInitiate... | [
"function",
"executeInitiateBatchTask",
"(",
"batch",
",",
"cancellable",
",",
"context",
")",
"{",
"/**\n * Defines the initiate batch task (and its sub-tasks) to be used to track the state of the initiating phase.\n * @returns {InitiateBatchTaskDef} a new initiate batch task definition (wi... | Creates and executes a new initiate batch task on the given batch.
@param {Batch} batch - the batch to be initiated
@param {Cancellable|Object|undefined} [cancellable] - a cancellable object onto which to install cancel functionality
@param {StreamConsumerContext} context - the context to use
@returns {Promise.<Batch>}... | [
"Creates",
"and",
"executes",
"a",
"new",
"initiate",
"batch",
"task",
"on",
"the",
"given",
"batch",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L191-L237 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | executeProcessBatchTask | function executeProcessBatchTask(batch, cancellable, context) {
/**
* Defines the process batch task (and its sub-tasks) to be used to track the state of the processing phase.
* @returns {ProcessBatchTaskDef} a new process batch task definition (with its sub-task definitions)
*/
function defineProcessBatch... | javascript | function executeProcessBatchTask(batch, cancellable, context) {
/**
* Defines the process batch task (and its sub-tasks) to be used to track the state of the processing phase.
* @returns {ProcessBatchTaskDef} a new process batch task definition (with its sub-task definitions)
*/
function defineProcessBatch... | [
"function",
"executeProcessBatchTask",
"(",
"batch",
",",
"cancellable",
",",
"context",
")",
"{",
"/**\n * Defines the process batch task (and its sub-tasks) to be used to track the state of the processing phase.\n * @returns {ProcessBatchTaskDef} a new process batch task definition (with i... | Creates and executes a new process batch task on the given batch.
@param {Batch} batch - the batch to be processed
@param {Cancellable|Object|undefined} [cancellable] - a cancellable object onto which to install cancel functionality
@param {StreamConsumerContext} context - the context to use
@returns {Promise.<Outcomes... | [
"Creates",
"and",
"executes",
"a",
"new",
"process",
"batch",
"task",
"on",
"the",
"given",
"batch",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L246-L288 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | createProcessBatchTask | function createProcessBatchTask(batch, context) {
// Define a new process task definition for the batch & updates the batch with it
batch.taskDefs.processTaskDef = defineProcessBatchTask();
const task = context.taskFactory.createTask(batch.taskDefs.processTaskDef, processTaskOpts);
// Cache it on the ... | javascript | function createProcessBatchTask(batch, context) {
// Define a new process task definition for the batch & updates the batch with it
batch.taskDefs.processTaskDef = defineProcessBatchTask();
const task = context.taskFactory.createTask(batch.taskDefs.processTaskDef, processTaskOpts);
// Cache it on the ... | [
"function",
"createProcessBatchTask",
"(",
"batch",
",",
"context",
")",
"{",
"// Define a new process task definition for the batch & updates the batch with it",
"batch",
".",
"taskDefs",
".",
"processTaskDef",
"=",
"defineProcessBatchTask",
"(",
")",
";",
"const",
"task",
... | Creates a new process batch task to be used to process the batch and to strack the state of the processing phase.
@param {Batch} batch - the batch to be processed
@param {StreamConsumerContext} context - the context to use
@returns {ProcessBatchTask} a new process batch task (with sub-tasks) | [
"Creates",
"a",
"new",
"process",
"batch",
"task",
"to",
"be",
"used",
"to",
"process",
"the",
"batch",
"and",
"to",
"strack",
"the",
"state",
"of",
"the",
"processing",
"phase",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L266-L277 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | executeFinaliseBatchTask | function executeFinaliseBatchTask(batch, processOutcomes, cancellable, context) {
/**
* Defines the finalise batch task (and its sub-tasks) to be used to track the state of the finalising phase.
* @returns {FinaliseBatchTaskDef} a new finalise batch task definition (with its sub-task definitions)
*/
functi... | javascript | function executeFinaliseBatchTask(batch, processOutcomes, cancellable, context) {
/**
* Defines the finalise batch task (and its sub-tasks) to be used to track the state of the finalising phase.
* @returns {FinaliseBatchTaskDef} a new finalise batch task definition (with its sub-task definitions)
*/
functi... | [
"function",
"executeFinaliseBatchTask",
"(",
"batch",
",",
"processOutcomes",
",",
"cancellable",
",",
"context",
")",
"{",
"/**\n * Defines the finalise batch task (and its sub-tasks) to be used to track the state of the finalising phase.\n * @returns {FinaliseBatchTaskDef} a new finali... | Creates and executes a new finalise batch task on the given batch.
@param {Batch} batch - the batch to be finalised
@param {Outcomes} processOutcomes - all of the outcomes of the preceding process stage
@param {Cancellable|Object|undefined} [cancellable] - a cancellable object onto which to install cancel functionality... | [
"Creates",
"and",
"executes",
"a",
"new",
"finalise",
"batch",
"task",
"on",
"the",
"given",
"batch",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L298-L337 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | createFinaliseBatchTask | function createFinaliseBatchTask(batch, context) {
// Define a new finalise task definition for the batch & updates the batch with it
batch.taskDefs.finaliseTaskDef = defineFinaliseBatchTask();
const task = context.taskFactory.createTask(batch.taskDefs.finaliseTaskDef, finaliseTaskOpts);
// Cache it o... | javascript | function createFinaliseBatchTask(batch, context) {
// Define a new finalise task definition for the batch & updates the batch with it
batch.taskDefs.finaliseTaskDef = defineFinaliseBatchTask();
const task = context.taskFactory.createTask(batch.taskDefs.finaliseTaskDef, finaliseTaskOpts);
// Cache it o... | [
"function",
"createFinaliseBatchTask",
"(",
"batch",
",",
"context",
")",
"{",
"// Define a new finalise task definition for the batch & updates the batch with it",
"batch",
".",
"taskDefs",
".",
"finaliseTaskDef",
"=",
"defineFinaliseBatchTask",
"(",
")",
";",
"const",
"task... | Creates a new finalise batch task to be used to finalise the batch and to track the state of the finalising phase.
@param {Batch} batch - the batch to be processed
@param {StreamConsumerContext} context - the context to use
@returns {FinaliseBatchTask} a new finalise batch task (with sub-tasks) | [
"Creates",
"a",
"new",
"finalise",
"batch",
"task",
"to",
"be",
"used",
"to",
"finalise",
"the",
"batch",
"and",
"to",
"track",
"the",
"state",
"of",
"the",
"finalising",
"phase",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L317-L328 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | preProcessBatch | function preProcessBatch(batch, context) {
const task = this;
// const initiatingTask = task.parent;
// Look up the actual function to be used to do the load of the previous tracked state (if any) of the current batch
const preProcessBatchFn = Settings.getPreProcessBatchFunction(context);
if (!preProcessBat... | javascript | function preProcessBatch(batch, context) {
const task = this;
// const initiatingTask = task.parent;
// Look up the actual function to be used to do the load of the previous tracked state (if any) of the current batch
const preProcessBatchFn = Settings.getPreProcessBatchFunction(context);
if (!preProcessBat... | [
"function",
"preProcessBatch",
"(",
"batch",
",",
"context",
")",
"{",
"const",
"task",
"=",
"this",
";",
"// const initiatingTask = task.parent;",
"// Look up the actual function to be used to do the load of the previous tracked state (if any) of the current batch",
"const",
"prePro... | Provides a hook for an optional pre-process batch function to be invoked after the batch has been successfully
initiated and before the batch is processed.
@param {Batch} batch
@param {StreamConsumerContext} context
@param {PreFinaliseBatch} [context.preProcessBatch] - an optional pre-process batch function to execute
... | [
"Provides",
"a",
"hook",
"for",
"an",
"optional",
"pre",
"-",
"process",
"batch",
"function",
"to",
"be",
"invoked",
"after",
"the",
"batch",
"has",
"been",
"successfully",
"initiated",
"and",
"before",
"the",
"batch",
"is",
"processed",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L749-L777 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | executeAllProcessAllTasks | function executeAllProcessAllTasks(batch, cancellable, context) {
const messages = batch.messages;
const m = messages.length;
const ms = toCountString(m, 'message');
const t = batch.taskDefs.processAllTaskDefs.length;
const ts = toCountString(t, 'process all task');
if (m <= 0) {
if (context.debugEnab... | javascript | function executeAllProcessAllTasks(batch, cancellable, context) {
const messages = batch.messages;
const m = messages.length;
const ms = toCountString(m, 'message');
const t = batch.taskDefs.processAllTaskDefs.length;
const ts = toCountString(t, 'process all task');
if (m <= 0) {
if (context.debugEnab... | [
"function",
"executeAllProcessAllTasks",
"(",
"batch",
",",
"cancellable",
",",
"context",
")",
"{",
"const",
"messages",
"=",
"batch",
".",
"messages",
";",
"const",
"m",
"=",
"messages",
".",
"length",
";",
"const",
"ms",
"=",
"toCountString",
"(",
"m",
... | Executes all of the incomplete "process all" tasks on the batch and returns a promise of an array with a Success or
Failure execution outcome for each task.
For each "process all" task to be executed, also resolves and passes all of its incomplete messages, which are all
of the batch's messages that are not yet fully ... | [
"Executes",
"all",
"of",
"the",
"incomplete",
"process",
"all",
"tasks",
"on",
"the",
"batch",
"and",
"returns",
"a",
"promise",
"of",
"an",
"array",
"with",
"a",
"Success",
"or",
"Failure",
"execution",
"outcome",
"for",
"each",
"task",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L939-L985 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | calculateTimeoutMs | function calculateTimeoutMs(timeoutAtPercentageOfRemainingTime, context) {
const remainingTimeInMillis = context.awsContext.getRemainingTimeInMillis();
return Math.round(remainingTimeInMillis * timeoutAtPercentageOfRemainingTime);
} | javascript | function calculateTimeoutMs(timeoutAtPercentageOfRemainingTime, context) {
const remainingTimeInMillis = context.awsContext.getRemainingTimeInMillis();
return Math.round(remainingTimeInMillis * timeoutAtPercentageOfRemainingTime);
} | [
"function",
"calculateTimeoutMs",
"(",
"timeoutAtPercentageOfRemainingTime",
",",
"context",
")",
"{",
"const",
"remainingTimeInMillis",
"=",
"context",
".",
"awsContext",
".",
"getRemainingTimeInMillis",
"(",
")",
";",
"return",
"Math",
".",
"round",
"(",
"remainingT... | Calculates the number of milliseconds to wait before timing out using the given timeoutAtPercentageOfRemainingTime
and the Lambda's remaining time to execute.
@param {number} timeoutAtPercentageOfRemainingTime - the percentage of the remaining time at which to timeout
the given task (expressed as a number between 0.0 a... | [
"Calculates",
"the",
"number",
"of",
"milliseconds",
"to",
"wait",
"before",
"timing",
"out",
"using",
"the",
"given",
"timeoutAtPercentageOfRemainingTime",
"and",
"the",
"Lambda",
"s",
"remaining",
"time",
"to",
"execute",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L995-L998 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | createCompletedPromise | function createCompletedPromise(task, completingPromise, batch, timeoutCancellable, context) {
const mustResolve = false;
return completingPromise.then(
outcomes => {
// The completing promise has completed
// 1. Try to cancel the timeout with which the completing promise was racing
const tim... | javascript | function createCompletedPromise(task, completingPromise, batch, timeoutCancellable, context) {
const mustResolve = false;
return completingPromise.then(
outcomes => {
// The completing promise has completed
// 1. Try to cancel the timeout with which the completing promise was racing
const tim... | [
"function",
"createCompletedPromise",
"(",
"task",
",",
"completingPromise",
",",
"batch",
",",
"timeoutCancellable",
",",
"context",
")",
"{",
"const",
"mustResolve",
"=",
"false",
";",
"return",
"completingPromise",
".",
"then",
"(",
"outcomes",
"=>",
"{",
"//... | Build a completed promise that will only complete when the given completingPromise has completed.
@param {Task} task - a task to be completed or failed depending on the outcome of the promise and if the timeout has not triggered yet
@param {Promise} completingPromise - the promise that will complete when all processing... | [
"Build",
"a",
"completed",
"promise",
"that",
"will",
"only",
"complete",
"when",
"the",
"given",
"completingPromise",
"has",
"completed",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L1053-L1101 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | preFinaliseBatch | function preFinaliseBatch(batch, context) {
const task = this;
// Look up the actual function to be used to do the pre-finalise batch logic (if any)
const preFinaliseBatchFn = Settings.getPreFinaliseBatchFunction(context);
if (!preFinaliseBatchFn) {
if (context.traceEnabled) context.trace(`Skipping pre-fi... | javascript | function preFinaliseBatch(batch, context) {
const task = this;
// Look up the actual function to be used to do the pre-finalise batch logic (if any)
const preFinaliseBatchFn = Settings.getPreFinaliseBatchFunction(context);
if (!preFinaliseBatchFn) {
if (context.traceEnabled) context.trace(`Skipping pre-fi... | [
"function",
"preFinaliseBatch",
"(",
"batch",
",",
"context",
")",
"{",
"const",
"task",
"=",
"this",
";",
"// Look up the actual function to be used to do the pre-finalise batch logic (if any)",
"const",
"preFinaliseBatchFn",
"=",
"Settings",
".",
"getPreFinaliseBatchFunction"... | Provides a hook for an optional pre-finalise batch function to be invoked after the batch has been successfully
processed and before the batch is finalised.
@param {Batch} batch
@param {StreamConsumerContext} context
@param {PreFinaliseBatch} [context.preFinaliseBatch] - an optional pre-finalise batch function to execu... | [
"Provides",
"a",
"hook",
"for",
"an",
"optional",
"pre",
"-",
"finalise",
"batch",
"function",
"to",
"be",
"invoked",
"after",
"the",
"batch",
"has",
"been",
"successfully",
"processed",
"and",
"before",
"the",
"batch",
"is",
"finalised",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L1123-L1150 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | postFinaliseBatch | function postFinaliseBatch(batch, context) {
const task = this;
// const finalisingTask = task.parent;
// Look up the actual function to be used to do the post-finalise batch logic (if any)
const postFinaliseBatchFn = Settings.getPostFinaliseBatchFunction(context);
if (!postFinaliseBatchFn) {
if (contex... | javascript | function postFinaliseBatch(batch, context) {
const task = this;
// const finalisingTask = task.parent;
// Look up the actual function to be used to do the post-finalise batch logic (if any)
const postFinaliseBatchFn = Settings.getPostFinaliseBatchFunction(context);
if (!postFinaliseBatchFn) {
if (contex... | [
"function",
"postFinaliseBatch",
"(",
"batch",
",",
"context",
")",
"{",
"const",
"task",
"=",
"this",
";",
"// const finalisingTask = task.parent;",
"// Look up the actual function to be used to do the post-finalise batch logic (if any)",
"const",
"postFinaliseBatchFn",
"=",
"Se... | Provides a hook for an optional post-finalise batch function to be invoked after the batch has been successfully
finalised.
@param {Batch} batch
@param {StreamConsumerContext} context
@param {PostFinaliseBatch} [context.postFinaliseBatch] - an optional post-finalise batch function to execute
@returns {Promise.<Batch|un... | [
"Provides",
"a",
"hook",
"for",
"an",
"optional",
"post",
"-",
"finalise",
"batch",
"function",
"to",
"be",
"invoked",
"after",
"the",
"batch",
"has",
"been",
"successfully",
"finalised",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L1340-L1369 | train |
byron-dupreez/aws-stream-consumer-core | stream-consumer.js | logFinalResults | function logFinalResults(batch, finalError, context) {
const summary = batch ? batch.summarizeFinalResults(finalError) : undefined;
context.info(`Summarized final batch results: ${JSON.stringify(summary)}`);
} | javascript | function logFinalResults(batch, finalError, context) {
const summary = batch ? batch.summarizeFinalResults(finalError) : undefined;
context.info(`Summarized final batch results: ${JSON.stringify(summary)}`);
} | [
"function",
"logFinalResults",
"(",
"batch",
",",
"finalError",
",",
"context",
")",
"{",
"const",
"summary",
"=",
"batch",
"?",
"batch",
".",
"summarizeFinalResults",
"(",
"finalError",
")",
":",
"undefined",
";",
"context",
".",
"info",
"(",
"`",
"${",
"... | Summarizes and logs the final results of the given batch - converting lists of messages and records into counts.
@param {Batch} batch - the batch that was processed
@param {Error|undefined} [finalError] - the final error with which the batch was terminated (if unsuccessful)
@param {StreamConsumerContext} context - the ... | [
"Summarizes",
"and",
"logs",
"the",
"final",
"results",
"of",
"the",
"given",
"batch",
"-",
"converting",
"lists",
"of",
"messages",
"and",
"records",
"into",
"counts",
"."
] | 9b256084297f80d373bcf483aaf68a9da176b3d7 | https://github.com/byron-dupreez/aws-stream-consumer-core/blob/9b256084297f80d373bcf483aaf68a9da176b3d7/stream-consumer.js#L1423-L1426 | train |
origin1tech/chek | dist/modules/from.js | fromEpoch | function fromEpoch(val, def) {
if (!is_1.isValue(val) || !is_1.isNumber(val))
return to_1.toDefault(null, def);
return new Date(val);
} | javascript | function fromEpoch(val, def) {
if (!is_1.isValue(val) || !is_1.isNumber(val))
return to_1.toDefault(null, def);
return new Date(val);
} | [
"function",
"fromEpoch",
"(",
"val",
",",
"def",
")",
"{",
"if",
"(",
"!",
"is_1",
".",
"isValue",
"(",
"val",
")",
"||",
"!",
"is_1",
".",
"isNumber",
"(",
"val",
")",
")",
"return",
"to_1",
".",
"toDefault",
"(",
"null",
",",
"def",
")",
";",
... | From Epoch
Converts to a Date from an epoch.
@param val the epoch value to convert to date. | [
"From",
"Epoch",
"Converts",
"to",
"a",
"Date",
"from",
"an",
"epoch",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/from.js#L12-L16 | train |
feedhenry/fh-mbaas-middleware | lib/middleware/events.js | listEvents | function listEvents(req, res, next){
var logger = log.logger;
var EventModel = models.getModels().Event;
var listReq = RequestTranslator.parseListEventsRequest(req);
if(! listReq.uid || ! listReq.env || ! listReq.domain){
return next({"error":"invalid params missing uid env or domain","code":400});
}
Ev... | javascript | function listEvents(req, res, next){
var logger = log.logger;
var EventModel = models.getModels().Event;
var listReq = RequestTranslator.parseListEventsRequest(req);
if(! listReq.uid || ! listReq.env || ! listReq.domain){
return next({"error":"invalid params missing uid env or domain","code":400});
}
Ev... | [
"function",
"listEvents",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"logger",
"=",
"log",
".",
"logger",
";",
"var",
"EventModel",
"=",
"models",
".",
"getModels",
"(",
")",
".",
"Event",
";",
"var",
"listReq",
"=",
"RequestTranslator",
"."... | Return list of Events for domain, env and app id
@param req
@param res
@param next | [
"Return",
"list",
"of",
"Events",
"for",
"domain",
"env",
"and",
"app",
"id"
] | f906e98efbb4b0963bf5137b34b5e0589ba24e69 | https://github.com/feedhenry/fh-mbaas-middleware/blob/f906e98efbb4b0963bf5137b34b5e0589ba24e69/lib/middleware/events.js#L17-L33 | train |
mmacmillan/aws-sns-q | sns-q.js | function(arn, attributes) {
var params = {
PlatformApplicationArn: arn,
Attributes: attributes
};
return this.svc.setPlatformApplicationAttributes(params);
} | javascript | function(arn, attributes) {
var params = {
PlatformApplicationArn: arn,
Attributes: attributes
};
return this.svc.setPlatformApplicationAttributes(params);
} | [
"function",
"(",
"arn",
",",
"attributes",
")",
"{",
"var",
"params",
"=",
"{",
"PlatformApplicationArn",
":",
"arn",
",",
"Attributes",
":",
"attributes",
"}",
";",
"return",
"this",
".",
"svc",
".",
"setPlatformApplicationAttributes",
"(",
"params",
")",
"... | updates the attributes for the specified platformApplicationArn
@param {String} arn the PlatformApplicationArn of the target platform application
@param {Object} attributes the Attributes map; a collection of fields to update | [
"updates",
"the",
"attributes",
"for",
"the",
"specified",
"platformApplicationArn"
] | b1c7a03d5687864a6130a7d5b4891d80aec16cdf | https://github.com/mmacmillan/aws-sns-q/blob/b1c7a03d5687864a6130a7d5b4891d80aec16cdf/sns-q.js#L61-L68 | train | |
mmacmillan/aws-sns-q | sns-q.js | function(arn, token) {
var params = {
PlatformApplicationArn: arn,
NextToken: token
};
return this.svc.listEndpointsByPlatformApplication(params);
} | javascript | function(arn, token) {
var params = {
PlatformApplicationArn: arn,
NextToken: token
};
return this.svc.listEndpointsByPlatformApplication(params);
} | [
"function",
"(",
"arn",
",",
"token",
")",
"{",
"var",
"params",
"=",
"{",
"PlatformApplicationArn",
":",
"arn",
",",
"NextToken",
":",
"token",
"}",
";",
"return",
"this",
".",
"svc",
".",
"listEndpointsByPlatformApplication",
"(",
"params",
")",
";",
"}"... | returns a list of all endpoints for the specified platform application
@param {String} arn the PlatformApplicationArn of the application to list endpoints for
@param {String} token the token returned from the previous call, to access the next set of objects | [
"returns",
"a",
"list",
"of",
"all",
"endpoints",
"for",
"the",
"specified",
"platform",
"application"
] | b1c7a03d5687864a6130a7d5b4891d80aec16cdf | https://github.com/mmacmillan/aws-sns-q/blob/b1c7a03d5687864a6130a7d5b4891d80aec16cdf/sns-q.js#L85-L92 | train | |
mmacmillan/aws-sns-q | sns-q.js | function(arn, token, data, attributes) {
var params = {
PlatformApplicationArn: arn,
Token: token,
CustomUserData: data,
Attributes: attributes
};
return this.svc.createPlatformEndpoint(params);
} | javascript | function(arn, token, data, attributes) {
var params = {
PlatformApplicationArn: arn,
Token: token,
CustomUserData: data,
Attributes: attributes
};
return this.svc.createPlatformEndpoint(params);
} | [
"function",
"(",
"arn",
",",
"token",
",",
"data",
",",
"attributes",
")",
"{",
"var",
"params",
"=",
"{",
"PlatformApplicationArn",
":",
"arn",
",",
"Token",
":",
"token",
",",
"CustomUserData",
":",
"data",
",",
"Attributes",
":",
"attributes",
"}",
";... | creates an endpoint for a device, within the specified application
@param {String} name name of the platformApplication object
@param {String} platform the platform this application object targets (APNS, GCM, ADM)
@param {Object} attributes additional attributes provided
for more information regarding the additional ... | [
"creates",
"an",
"endpoint",
"for",
"a",
"device",
"within",
"the",
"specified",
"application"
] | b1c7a03d5687864a6130a7d5b4891d80aec16cdf | https://github.com/mmacmillan/aws-sns-q/blob/b1c7a03d5687864a6130a7d5b4891d80aec16cdf/sns-q.js#L118-L127 | train | |
mmacmillan/aws-sns-q | sns-q.js | function(arn, attributes) {
var params = {
EndpointArn: arn,
Attributes: attributes
};
return this.svc.setEndpointAttributes(params);
} | javascript | function(arn, attributes) {
var params = {
EndpointArn: arn,
Attributes: attributes
};
return this.svc.setEndpointAttributes(params);
} | [
"function",
"(",
"arn",
",",
"attributes",
")",
"{",
"var",
"params",
"=",
"{",
"EndpointArn",
":",
"arn",
",",
"Attributes",
":",
"attributes",
"}",
";",
"return",
"this",
".",
"svc",
".",
"setEndpointAttributes",
"(",
"params",
")",
";",
"}"
] | updates the attributes for the specified endpoint
@param {String} arn the EndpointArn of the target platform endpoint
@param {Object} attributes the Attributes map; a collection of fields to update | [
"updates",
"the",
"attributes",
"for",
"the",
"specified",
"endpoint"
] | b1c7a03d5687864a6130a7d5b4891d80aec16cdf | https://github.com/mmacmillan/aws-sns-q/blob/b1c7a03d5687864a6130a7d5b4891d80aec16cdf/sns-q.js#L146-L153 | train | |
mmacmillan/aws-sns-q | sns-q.js | function(topicArn, endpointArn) {
var params = {
TopicArn: topicArn,
Protocol: 'application',
Endpoint: endpointArn
};
return this.svc.subscribe(params);
} | javascript | function(topicArn, endpointArn) {
var params = {
TopicArn: topicArn,
Protocol: 'application',
Endpoint: endpointArn
};
return this.svc.subscribe(params);
} | [
"function",
"(",
"topicArn",
",",
"endpointArn",
")",
"{",
"var",
"params",
"=",
"{",
"TopicArn",
":",
"topicArn",
",",
"Protocol",
":",
"'application'",
",",
"Endpoint",
":",
"endpointArn",
"}",
";",
"return",
"this",
".",
"svc",
".",
"subscribe",
"(",
... | shorthand for device specific registrations, assumes the endpoint is an arn, and presets the protocol
to 'application', which is used for mobile devices | [
"shorthand",
"for",
"device",
"specific",
"registrations",
"assumes",
"the",
"endpoint",
"is",
"an",
"arn",
"and",
"presets",
"the",
"protocol",
"to",
"application",
"which",
"is",
"used",
"for",
"mobile",
"devices"
] | b1c7a03d5687864a6130a7d5b4891d80aec16cdf | https://github.com/mmacmillan/aws-sns-q/blob/b1c7a03d5687864a6130a7d5b4891d80aec16cdf/sns-q.js#L276-L284 | train | |
mmacmillan/aws-sns-q | sns-q.js | messageBuilder | function messageBuilder(msg, args) {
var message = msg,
supported = [],
badge = 0,
builders = {};
//** currently only APNS is supported
builders[platforms.APNS] = builders[platforms.APNSSandbox] = function() {
return {
aps: {
//** adds the custom... | javascript | function messageBuilder(msg, args) {
var message = msg,
supported = [],
badge = 0,
builders = {};
//** currently only APNS is supported
builders[platforms.APNS] = builders[platforms.APNSSandbox] = function() {
return {
aps: {
//** adds the custom... | [
"function",
"messageBuilder",
"(",
"msg",
",",
"args",
")",
"{",
"var",
"message",
"=",
"msg",
",",
"supported",
"=",
"[",
"]",
",",
"badge",
"=",
"0",
",",
"builders",
"=",
"{",
"}",
";",
"//** currently only APNS is supported",
"builders",
"[",
"platform... | a message builder to abstract the individual format for each platform; supports a message, badges, and custom payloads
@param {String} msg the message we are building platform specific representations of
@param {Object} args individual platform specific payload arguments (optional) | [
"a",
"message",
"builder",
"to",
"abstract",
"the",
"individual",
"format",
"for",
"each",
"platform",
";",
"supports",
"a",
"message",
"badges",
"and",
"custom",
"payloads"
] | b1c7a03d5687864a6130a7d5b4891d80aec16cdf | https://github.com/mmacmillan/aws-sns-q/blob/b1c7a03d5687864a6130a7d5b4891d80aec16cdf/sns-q.js#L310-L360 | train |
blond/rangem | lib/subtract.js | getBorders | function getBorders(ranges) {
var borders = [];
ranges.forEach(function(range) {
var leftBorder = { value: range.from, type: 'from' };
var rightBorder = { value: range.to, type: 'to' };
borders.push(leftBorder, rightBorder);
});
return borders;
} | javascript | function getBorders(ranges) {
var borders = [];
ranges.forEach(function(range) {
var leftBorder = { value: range.from, type: 'from' };
var rightBorder = { value: range.to, type: 'to' };
borders.push(leftBorder, rightBorder);
});
return borders;
} | [
"function",
"getBorders",
"(",
"ranges",
")",
"{",
"var",
"borders",
"=",
"[",
"]",
";",
"ranges",
".",
"forEach",
"(",
"function",
"(",
"range",
")",
"{",
"var",
"leftBorder",
"=",
"{",
"value",
":",
"range",
".",
"from",
",",
"type",
":",
"'from'",... | Returns borders of ranges.
@param {{from: number, to: number}} ranges — the source ranges.
@returns {{value: number, type: string}} | [
"Returns",
"borders",
"of",
"ranges",
"."
] | bd61375cbb3f2bfb5740cc9c59ea01aec208c90b | https://github.com/blond/rangem/blob/bd61375cbb3f2bfb5740cc9c59ea01aec208c90b/lib/subtract.js#L12-L23 | train |
blond/rangem | lib/subtract.js | isEqualRange | function isEqualRange(range1, range2) {
return range1.from === range2.from && range1.to === range2.to;
} | javascript | function isEqualRange(range1, range2) {
return range1.from === range2.from && range1.to === range2.to;
} | [
"function",
"isEqualRange",
"(",
"range1",
",",
"range2",
")",
"{",
"return",
"range1",
".",
"from",
"===",
"range2",
".",
"from",
"&&",
"range1",
".",
"to",
"===",
"range2",
".",
"to",
";",
"}"
] | Returns `true` if ranges are equal.
@param {{from: number, to: number}} range1 — the range to check.
@param {{from: number, to: number}} range2 — the range to check.
@returns {Boolean} | [
"Returns",
"true",
"if",
"ranges",
"are",
"equal",
"."
] | bd61375cbb3f2bfb5740cc9c59ea01aec208c90b | https://github.com/blond/rangem/blob/bd61375cbb3f2bfb5740cc9c59ea01aec208c90b/lib/subtract.js#L33-L35 | train |
vkiding/jud-vue-render | src/shared/console.js | generateLevelMap | function generateLevelMap () {
LEVELS.forEach(level => {
const levelIndex = LEVELS.indexOf(level)
levelMap[level] = {}
LEVELS.forEach(type => {
const typeIndex = LEVELS.indexOf(type)
if (typeIndex <= levelIndex) {
levelMap[level][type] = true
}
})
})
} | javascript | function generateLevelMap () {
LEVELS.forEach(level => {
const levelIndex = LEVELS.indexOf(level)
levelMap[level] = {}
LEVELS.forEach(type => {
const typeIndex = LEVELS.indexOf(type)
if (typeIndex <= levelIndex) {
levelMap[level][type] = true
}
})
})
} | [
"function",
"generateLevelMap",
"(",
")",
"{",
"LEVELS",
".",
"forEach",
"(",
"level",
"=>",
"{",
"const",
"levelIndex",
"=",
"LEVELS",
".",
"indexOf",
"(",
"level",
")",
"levelMap",
"[",
"level",
"]",
"=",
"{",
"}",
"LEVELS",
".",
"forEach",
"(",
"typ... | Generate map for which types of message will be sent in a certain message level
as the order of LEVELS. | [
"Generate",
"map",
"for",
"which",
"types",
"of",
"message",
"will",
"be",
"sent",
"in",
"a",
"certain",
"message",
"level",
"as",
"the",
"order",
"of",
"LEVELS",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/shared/console.js#L78-L89 | train |
vkiding/jud-vue-render | src/shared/console.js | checkLevel | function checkLevel (type) {
const logLevel = (global.JUDEnvironment && global.JUDEnvironment.logLevel) || 'log'
return levelMap[logLevel] && levelMap[logLevel][type]
} | javascript | function checkLevel (type) {
const logLevel = (global.JUDEnvironment && global.JUDEnvironment.logLevel) || 'log'
return levelMap[logLevel] && levelMap[logLevel][type]
} | [
"function",
"checkLevel",
"(",
"type",
")",
"{",
"const",
"logLevel",
"=",
"(",
"global",
".",
"JUDEnvironment",
"&&",
"global",
".",
"JUDEnvironment",
".",
"logLevel",
")",
"||",
"'log'",
"return",
"levelMap",
"[",
"logLevel",
"]",
"&&",
"levelMap",
"[",
... | Check if a certain type of message will be sent in current log level of env.
@param {string} type
@return {boolean} | [
"Check",
"if",
"a",
"certain",
"type",
"of",
"message",
"will",
"be",
"sent",
"in",
"current",
"log",
"level",
"of",
"env",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/shared/console.js#L96-L99 | train |
vkiding/jud-vue-render | src/shared/console.js | format | function format (args) {
return args.map((v) => {
const type = Object.prototype.toString.call(v)
if (type.toLowerCase() === '[object object]') {
v = JSON.stringify(v)
}
else {
v = String(v)
}
return v
})
} | javascript | function format (args) {
return args.map((v) => {
const type = Object.prototype.toString.call(v)
if (type.toLowerCase() === '[object object]') {
v = JSON.stringify(v)
}
else {
v = String(v)
}
return v
})
} | [
"function",
"format",
"(",
"args",
")",
"{",
"return",
"args",
".",
"map",
"(",
"(",
"v",
")",
"=>",
"{",
"const",
"type",
"=",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"v",
")",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
"... | Convert all log arguments into primitive values.
@param {array} args
@return {array}
/* istanbul ignore next | [
"Convert",
"all",
"log",
"arguments",
"into",
"primitive",
"values",
"."
] | 07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47 | https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/shared/console.js#L107-L118 | train |
NYPL-discovery/sierra-wrapper | index.js | function (url, requestItemsCb) {
// use the bearer auth token
request.get(url, {
'auth': {
'bearer': exports.authorizedToken
}
},
(error, response, body) => {
if (error) console.error(error)
if (response.statusCode && response.statusCode === 200) {... | javascript | function (url, requestItemsCb) {
// use the bearer auth token
request.get(url, {
'auth': {
'bearer': exports.authorizedToken
}
},
(error, response, body) => {
if (error) console.error(error)
if (response.statusCode && response.statusCode === 200) {... | [
"function",
"(",
"url",
",",
"requestItemsCb",
")",
"{",
"// use the bearer auth token",
"request",
".",
"get",
"(",
"url",
",",
"{",
"'auth'",
":",
"{",
"'bearer'",
":",
"exports",
".",
"authorizedToken",
"}",
"}",
",",
"(",
"error",
",",
"response",
",",... | this is the request function we will curry below | [
"this",
"is",
"the",
"request",
"function",
"we",
"will",
"curry",
"below"
] | 9fb0f82da0ccab129c6a349d39b355c1e176f658 | https://github.com/NYPL-discovery/sierra-wrapper/blob/9fb0f82da0ccab129c6a349d39b355c1e176f658/index.js#L257-L272 | train | |
freestyle21/grunt-2x2x | tasks/_2x2x.js | function() {
var _2x2x = this;
var guard_file = 0;
var guard_2x = 0;
grunt.file.recurse(this.imgsrcdir, function(file) {
guard_file += 1;
var srcextname = path.extname(file),
... | javascript | function() {
var _2x2x = this;
var guard_file = 0;
var guard_2x = 0;
grunt.file.recurse(this.imgsrcdir, function(file) {
guard_file += 1;
var srcextname = path.extname(file),
... | [
"function",
"(",
")",
"{",
"var",
"_2x2x",
"=",
"this",
";",
"var",
"guard_file",
"=",
"0",
";",
"var",
"guard_2x",
"=",
"0",
";",
"grunt",
".",
"file",
".",
"recurse",
"(",
"this",
".",
"imgsrcdir",
",",
"function",
"(",
"file",
")",
"{",
"guard_f... | ergodic the img in imgsrcdir | [
"ergodic",
"the",
"img",
"in",
"imgsrcdir"
] | 8466a623dfa03ce2067cbaf540fc00196925a67c | https://github.com/freestyle21/grunt-2x2x/blob/8466a623dfa03ce2067cbaf540fc00196925a67c/tasks/_2x2x.js#L42-L110 | train | |
mattmccray/blam.js | blam.js | function(){
var args= slice.call(arguments), block= args.pop();
return blam.compile(block, ctx).apply(tagset, args);
} | javascript | function(){
var args= slice.call(arguments), block= args.pop();
return blam.compile(block, ctx).apply(tagset, args);
} | [
"function",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"block",
"=",
"args",
".",
"pop",
"(",
")",
";",
"return",
"blam",
".",
"compile",
"(",
"block",
",",
"ctx",
")",
".",
"apply",
"(",
"tagset",
",",
... | Did throw exception... | [
"Did",
"throw",
"exception",
"..."
] | a535b6fe9679b687897ac0dc18b26585a5c3a114 | https://github.com/mattmccray/blam.js/blob/a535b6fe9679b687897ac0dc18b26585a5c3a114/blam.js#L58-L61 | train | |
eliOcs/node-envy | envy.js | deepCopy | function deepCopy(destination, source) {
Object.keys(source).forEach(function (property) {
if (destination[property] && isObject(destination[property])) {
deepCopy(destination[property], source[property]);
} else {
destination[property] = source[property];
}
});
} | javascript | function deepCopy(destination, source) {
Object.keys(source).forEach(function (property) {
if (destination[property] && isObject(destination[property])) {
deepCopy(destination[property], source[property]);
} else {
destination[property] = source[property];
}
});
} | [
"function",
"deepCopy",
"(",
"destination",
",",
"source",
")",
"{",
"Object",
".",
"keys",
"(",
"source",
")",
".",
"forEach",
"(",
"function",
"(",
"property",
")",
"{",
"if",
"(",
"destination",
"[",
"property",
"]",
"&&",
"isObject",
"(",
"destinatio... | Deep copies the properties of the source object into the destination
object. | [
"Deep",
"copies",
"the",
"properties",
"of",
"the",
"source",
"object",
"into",
"the",
"destination",
"object",
"."
] | ec1b59cc1ac4901ef5bca6acd8a7abb1f0de0e81 | https://github.com/eliOcs/node-envy/blob/ec1b59cc1ac4901ef5bca6acd8a7abb1f0de0e81/envy.js#L24-L32 | train |
jgnewman/brightsocket.io | bin/poolapi.js | runExtensions | function runExtensions(settings) {
var extensions = settings.extensions,
channels = settings.channels,
connection = settings.connection,
userPackage = settings.userPackage,
server = settings.server;
// For every extension the user listed...
extensions.forEach(function (extension) {
... | javascript | function runExtensions(settings) {
var extensions = settings.extensions,
channels = settings.channels,
connection = settings.connection,
userPackage = settings.userPackage,
server = settings.server;
// For every extension the user listed...
extensions.forEach(function (extension) {
... | [
"function",
"runExtensions",
"(",
"settings",
")",
"{",
"var",
"extensions",
"=",
"settings",
".",
"extensions",
",",
"channels",
"=",
"settings",
".",
"channels",
",",
"connection",
"=",
"settings",
".",
"connection",
",",
"userPackage",
"=",
"settings",
".",... | Runs a series of callbacks for a new connection.
@param {Object} settings - All the values we'll need to run the callbacks.
@return {undefined} | [
"Runs",
"a",
"series",
"of",
"callbacks",
"for",
"a",
"new",
"connection",
"."
] | 19ec67d69946ab09ca389143ebbdcb0a7f22f950 | https://github.com/jgnewman/brightsocket.io/blob/19ec67d69946ab09ca389143ebbdcb0a7f22f950/bin/poolapi.js#L44-L70 | train |
jgnewman/brightsocket.io | bin/poolapi.js | cleanIdentity | function cleanIdentity(identity) {
var userPackage = {};
Object.keys(identity).forEach(function (key) {
if (key.indexOf('BRIGHTSOCKET:') !== 0) {
userPackage[key] = identity[key];
}
});
return userPackage;
} | javascript | function cleanIdentity(identity) {
var userPackage = {};
Object.keys(identity).forEach(function (key) {
if (key.indexOf('BRIGHTSOCKET:') !== 0) {
userPackage[key] = identity[key];
}
});
return userPackage;
} | [
"function",
"cleanIdentity",
"(",
"identity",
")",
"{",
"var",
"userPackage",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"identity",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"key",
".",
"indexOf",
"(",
"'BRIGHTSOCKET:... | Takes an incoming identity package and strips out keys
that were inserted by Brightsocket.
@param {Object} identity - Came in from the IDENTIFY action.
@return {Object} The clean object. | [
"Takes",
"an",
"incoming",
"identity",
"package",
"and",
"strips",
"out",
"keys",
"that",
"were",
"inserted",
"by",
"Brightsocket",
"."
] | 19ec67d69946ab09ca389143ebbdcb0a7f22f950 | https://github.com/jgnewman/brightsocket.io/blob/19ec67d69946ab09ca389143ebbdcb0a7f22f950/bin/poolapi.js#L80-L88 | train |
jgnewman/brightsocket.io | bin/poolapi.js | PoolAPI | function PoolAPI(server) {
_classCallCheck(this, PoolAPI);
this.pool = (0, _socketpool2.default)(server);
this.server = server;
this.channels = {};
} | javascript | function PoolAPI(server) {
_classCallCheck(this, PoolAPI);
this.pool = (0, _socketpool2.default)(server);
this.server = server;
this.channels = {};
} | [
"function",
"PoolAPI",
"(",
"server",
")",
"{",
"_classCallCheck",
"(",
"this",
",",
"PoolAPI",
")",
";",
"this",
".",
"pool",
"=",
"(",
"0",
",",
"_socketpool2",
".",
"default",
")",
"(",
"server",
")",
";",
"this",
".",
"server",
"=",
"server",
";"... | Builds the class. | [
"Builds",
"the",
"class",
"."
] | 19ec67d69946ab09ca389143ebbdcb0a7f22f950 | https://github.com/jgnewman/brightsocket.io/blob/19ec67d69946ab09ca389143ebbdcb0a7f22f950/bin/poolapi.js#L95-L101 | train |
PeerioTechnologies/peerio-updater | fetch.js | get | function get(address, contentType, redirs = 0, tries = 0) {
return new Promise((fulfill, reject) => {
const { host, path } = url.parse(address);
const options = {
headers: { 'User-Agent': 'peerio-updater/1.0' },
timeout: REQUEST_TIMEOUT,
host,
path
... | javascript | function get(address, contentType, redirs = 0, tries = 0) {
return new Promise((fulfill, reject) => {
const { host, path } = url.parse(address);
const options = {
headers: { 'User-Agent': 'peerio-updater/1.0' },
timeout: REQUEST_TIMEOUT,
host,
path
... | [
"function",
"get",
"(",
"address",
",",
"contentType",
",",
"redirs",
"=",
"0",
",",
"tries",
"=",
"0",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"fulfill",
",",
"reject",
")",
"=>",
"{",
"const",
"{",
"host",
",",
"path",
"}",
"=",
"url",
... | Initiates get request and returns a promise resolving to response object.
Handles redirects up to MAX_REDIRECTS.
Repeats on errors (except for 404) up to MAX_RETRIES times.
On success, the response must be fully consumed by the caller to avoid
leaking memory.
@param {string} address - requested URL (must start with ... | [
"Initiates",
"get",
"request",
"and",
"returns",
"a",
"promise",
"resolving",
"to",
"response",
"object",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/fetch.js#L41-L113 | train |
PeerioTechnologies/peerio-updater | fetch.js | streamToText | function streamToText(stream) {
return new Promise((fulfill, reject) => {
let chunks = [];
let length = 0;
stream.setEncoding('utf8');
stream.on('data', chunk => {
length += chunk.length;
if (length > MAX_TEXT_LENGTH) {
reject(new Error('Respon... | javascript | function streamToText(stream) {
return new Promise((fulfill, reject) => {
let chunks = [];
let length = 0;
stream.setEncoding('utf8');
stream.on('data', chunk => {
length += chunk.length;
if (length > MAX_TEXT_LENGTH) {
reject(new Error('Respon... | [
"function",
"streamToText",
"(",
"stream",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"fulfill",
",",
"reject",
")",
"=>",
"{",
"let",
"chunks",
"=",
"[",
"]",
";",
"let",
"length",
"=",
"0",
";",
"stream",
".",
"setEncoding",
"(",
"'utf8'",
")"... | Reads the given stream and returns it as string.
Rejects if data is larger than MAX_TEXT_LENGTH.
@param {stream.Readable} stream
@returns {Promise<string>} received text | [
"Reads",
"the",
"given",
"stream",
"and",
"returns",
"it",
"as",
"string",
".",
"Rejects",
"if",
"data",
"is",
"larger",
"than",
"MAX_TEXT_LENGTH",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/fetch.js#L122-L142 | train |
PeerioTechnologies/peerio-updater | fetch.js | fetchText | function fetchText(address, contentType) {
return get(address, contentType)
.then(streamToText)
.catch(err => {
console.error(`Fetch error: ${err.message}`);
throw err; // re-throw
});
} | javascript | function fetchText(address, contentType) {
return get(address, contentType)
.then(streamToText)
.catch(err => {
console.error(`Fetch error: ${err.message}`);
throw err; // re-throw
});
} | [
"function",
"fetchText",
"(",
"address",
",",
"contentType",
")",
"{",
"return",
"get",
"(",
"address",
",",
"contentType",
")",
".",
"then",
"(",
"streamToText",
")",
".",
"catch",
"(",
"err",
"=>",
"{",
"console",
".",
"error",
"(",
"`",
"${",
"err",... | Fetches text from the given address.
Rejects if received text is larger than MAX_TEXT_LENGTH.
@param {string} address source URL
@param {string?} [contentType] expected content type or undefined if any
@returns {Promise<string>} resulting text | [
"Fetches",
"text",
"from",
"the",
"given",
"address",
".",
"Rejects",
"if",
"received",
"text",
"is",
"larger",
"than",
"MAX_TEXT_LENGTH",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/fetch.js#L152-L159 | train |
PeerioTechnologies/peerio-updater | fetch.js | fetchFile | function fetchFile(address, filepath) {
return get(address)
.then(res => new Promise((fulfill, reject) => {
const file = fs.createWriteStream(filepath);
res.on('error', err => {
// reading error
file.close();
fs.unlink(filepath, err => ... | javascript | function fetchFile(address, filepath) {
return get(address)
.then(res => new Promise((fulfill, reject) => {
const file = fs.createWriteStream(filepath);
res.on('error', err => {
// reading error
file.close();
fs.unlink(filepath, err => ... | [
"function",
"fetchFile",
"(",
"address",
",",
"filepath",
")",
"{",
"return",
"get",
"(",
"address",
")",
".",
"then",
"(",
"res",
"=>",
"new",
"Promise",
"(",
"(",
"fulfill",
",",
"reject",
")",
"=>",
"{",
"const",
"file",
"=",
"fs",
".",
"createWri... | Fetches file from the given address, creating a file
into the given file path.
@param {string} address source URL
@param {string} filepath destination file path
@returns {Promise<string>} promise resolving to the destination file path | [
"Fetches",
"file",
"from",
"the",
"given",
"address",
"creating",
"a",
"file",
"into",
"the",
"given",
"file",
"path",
"."
] | 9d6fedeec727f16a31653e4bbd4efe164e0957cb | https://github.com/PeerioTechnologies/peerio-updater/blob/9d6fedeec727f16a31653e4bbd4efe164e0957cb/fetch.js#L210-L234 | train |
HenriJ/careless | vendor/fbtransform/visitors.js | getVisitorsBySet | function getVisitorsBySet(sets) {
var visitorsToInclude = sets.reduce(function(visitors, set) {
if (!transformSets.hasOwnProperty(set)) {
throw new Error('Unknown visitor set: ' + set);
}
transformSets[set].forEach(function(visitor) {
visitors[visitor] = true;
});
return visitors;
},... | javascript | function getVisitorsBySet(sets) {
var visitorsToInclude = sets.reduce(function(visitors, set) {
if (!transformSets.hasOwnProperty(set)) {
throw new Error('Unknown visitor set: ' + set);
}
transformSets[set].forEach(function(visitor) {
visitors[visitor] = true;
});
return visitors;
},... | [
"function",
"getVisitorsBySet",
"(",
"sets",
")",
"{",
"var",
"visitorsToInclude",
"=",
"sets",
".",
"reduce",
"(",
"function",
"(",
"visitors",
",",
"set",
")",
"{",
"if",
"(",
"!",
"transformSets",
".",
"hasOwnProperty",
"(",
"set",
")",
")",
"{",
"thr... | Given a list of visitor set names, return the ordered list of visitors to be
passed to jstransform.
@param {array}
@return {array} | [
"Given",
"a",
"list",
"of",
"visitor",
"set",
"names",
"return",
"the",
"ordered",
"list",
"of",
"visitors",
"to",
"be",
"passed",
"to",
"jstransform",
"."
] | 7dea2384b412bf2a03e111dae22055dd9bdf95fe | https://github.com/HenriJ/careless/blob/7dea2384b412bf2a03e111dae22055dd9bdf95fe/vendor/fbtransform/visitors.js#L83-L102 | train |
StudioLE/sqwk | lib/index.js | function(user_opts) {
// Set options
this.options = _.defaults(user_opts, this.options)
// Set title
// this.options.title = chalk.bold(this.options.title)
// Without this, we would only get streams once enter is pressed
process.stdin.setRawMode(true)
// Resume stdin in the parent process... | javascript | function(user_opts) {
// Set options
this.options = _.defaults(user_opts, this.options)
// Set title
// this.options.title = chalk.bold(this.options.title)
// Without this, we would only get streams once enter is pressed
process.stdin.setRawMode(true)
// Resume stdin in the parent process... | [
"function",
"(",
"user_opts",
")",
"{",
"// Set options",
"this",
".",
"options",
"=",
"_",
".",
"defaults",
"(",
"user_opts",
",",
"this",
".",
"options",
")",
"// Set title",
"// this.options.title = chalk.bold(this.options.title)",
"// Without this, we would only get s... | Set options and capture user input
@method init
@param {Object} options Options | [
"Set",
"options",
"and",
"capture",
"user",
"input"
] | 8eabaf71a84e07f9870b80526ca5194197df454f | https://github.com/StudioLE/sqwk/blob/8eabaf71a84e07f9870b80526ca5194197df454f/lib/index.js#L27-L40 | train | |
StudioLE/sqwk | lib/index.js | function(message, options, callback) {
// If no callback given create one
if( ! callback) callback = function() {}
// If a previous terminal has been opened then close it
if(terminal) terminal.close()
terminal = t_menu(this.options.menu)
// Reset the terminal, clearing all contents
if(thi... | javascript | function(message, options, callback) {
// If no callback given create one
if( ! callback) callback = function() {}
// If a previous terminal has been opened then close it
if(terminal) terminal.close()
terminal = t_menu(this.options.menu)
// Reset the terminal, clearing all contents
if(thi... | [
"function",
"(",
"message",
",",
"options",
",",
"callback",
")",
"{",
"// If no callback given create one",
"if",
"(",
"!",
"callback",
")",
"callback",
"=",
"function",
"(",
")",
"{",
"}",
"// If a previous terminal has been opened then close it",
"if",
"(",
"term... | Write a message or menu to the terminal
@method write
@param {String|Array} message Message or messages
@param {Array} options Selectable menu options
@param {Function} callback
@return {Object} Terminal object | [
"Write",
"a",
"message",
"or",
"menu",
"to",
"the",
"terminal"
] | 8eabaf71a84e07f9870b80526ca5194197df454f | https://github.com/StudioLE/sqwk/blob/8eabaf71a84e07f9870b80526ca5194197df454f/lib/index.js#L51-L101 | train | |
StudioLE/sqwk | lib/index.js | function(err, exit) {
// Close the terminal
if(terminal) terminal.close()
// If there was an error throw it before exit
if(err) throw err
// process.stdin.resume() prevents node from exiting.
// process.exit() overrides in more cases than stdin.pause() or stdin.end()
// it also means we do... | javascript | function(err, exit) {
// Close the terminal
if(terminal) terminal.close()
// If there was an error throw it before exit
if(err) throw err
// process.stdin.resume() prevents node from exiting.
// process.exit() overrides in more cases than stdin.pause() or stdin.end()
// it also means we do... | [
"function",
"(",
"err",
",",
"exit",
")",
"{",
"// Close the terminal",
"if",
"(",
"terminal",
")",
"terminal",
".",
"close",
"(",
")",
"// If there was an error throw it before exit",
"if",
"(",
"err",
")",
"throw",
"err",
"// process.stdin.resume() prevents node fro... | Close terminal and exit process
@method end
@param {Object} err Error
@param {Boolean} exit Exit process? | [
"Close",
"terminal",
"and",
"exit",
"process"
] | 8eabaf71a84e07f9870b80526ca5194197df454f | https://github.com/StudioLE/sqwk/blob/8eabaf71a84e07f9870b80526ca5194197df454f/lib/index.js#L110-L127 | train | |
creationix/culvert | channel.js | put | function put(item) {
if (monitor) monitor("put", item);
if (readQueue.length) {
if (monitor) monitor("take", item);
readQueue.shift()(null, item);
}
else {
dataQueue.push(item);
}
return dataQueue.length <= bufferSize;
} | javascript | function put(item) {
if (monitor) monitor("put", item);
if (readQueue.length) {
if (monitor) monitor("take", item);
readQueue.shift()(null, item);
}
else {
dataQueue.push(item);
}
return dataQueue.length <= bufferSize;
} | [
"function",
"put",
"(",
"item",
")",
"{",
"if",
"(",
"monitor",
")",
"monitor",
"(",
"\"put\"",
",",
"item",
")",
";",
"if",
"(",
"readQueue",
".",
"length",
")",
"{",
"if",
"(",
"monitor",
")",
"monitor",
"(",
"\"take\"",
",",
"item",
")",
";",
... | Returns true when it's safe to continue without draining | [
"Returns",
"true",
"when",
"it",
"s",
"safe",
"to",
"continue",
"without",
"draining"
] | 42b83894041cd7f8ee3993af0df65c1afe17b2c5 | https://github.com/creationix/culvert/blob/42b83894041cd7f8ee3993af0df65c1afe17b2c5/channel.js#L30-L40 | train |
PanthR/panthrMath | panthrMath/distributions/lognormal.js | dlnorm | function dlnorm(meanlog, sdlog, logp) {
logp = logp === true;
if (utils.hasNaN(meanlog, sdlog) || sdlog < 0) {
return function() { return NaN; };
}
return function(x) {
var z;
if (utils.hasNaN(x)) { return NaN; }
if (sdlog === 0) {
return Math.l... | javascript | function dlnorm(meanlog, sdlog, logp) {
logp = logp === true;
if (utils.hasNaN(meanlog, sdlog) || sdlog < 0) {
return function() { return NaN; };
}
return function(x) {
var z;
if (utils.hasNaN(x)) { return NaN; }
if (sdlog === 0) {
return Math.l... | [
"function",
"dlnorm",
"(",
"meanlog",
",",
"sdlog",
",",
"logp",
")",
"{",
"logp",
"=",
"logp",
"===",
"true",
";",
"if",
"(",
"utils",
".",
"hasNaN",
"(",
"meanlog",
",",
"sdlog",
")",
"||",
"sdlog",
"<",
"0",
")",
"{",
"return",
"function",
"(",
... | Evaluates the lognormal distribution's density function at `x`.
Expects $x > 0$ and $\textrm{sdlog} > 0$.
@fullName dlnorm(meanlog, sdlog, logp)(x)
@memberof lognormal | [
"Evaluates",
"the",
"lognormal",
"distribution",
"s",
"density",
"function",
"at",
"x",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/lognormal.js#L41-L63 | train |
PanthR/panthrMath | panthrMath/distributions/lognormal.js | rlnorm | function rlnorm(meanlog, sdlog) {
var rnorm;
rnorm = normal.rnorm(meanlog, sdlog);
return function() {
return Math.exp(rnorm());
};
} | javascript | function rlnorm(meanlog, sdlog) {
var rnorm;
rnorm = normal.rnorm(meanlog, sdlog);
return function() {
return Math.exp(rnorm());
};
} | [
"function",
"rlnorm",
"(",
"meanlog",
",",
"sdlog",
")",
"{",
"var",
"rnorm",
";",
"rnorm",
"=",
"normal",
".",
"rnorm",
"(",
"meanlog",
",",
"sdlog",
")",
";",
"return",
"function",
"(",
")",
"{",
"return",
"Math",
".",
"exp",
"(",
"rnorm",
"(",
"... | Returns a random variate from the lognormal distribution.
Expects $\textrm{sdlog} > 0$.
Uses a rejection polar method.
@fullName rlnorm(meanlog, sdlog)()
@memberof lognormal | [
"Returns",
"a",
"random",
"variate",
"from",
"the",
"lognormal",
"distribution",
"."
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/lognormal.js#L144-L152 | train |
PanthR/panthrMath | panthrMath/distributions/t.js | ptlog | function ptlog(df, lowerTail) {
return function(x) {
var val;
if (utils.hasNaN(x, df) || df <= 0) { return NaN; }
val = df > x * x ?
bratio(0.5, df / 2, x * x / (df + x * x), false, true)
: bratio(df / 2, 0.5, 1 / (1 + x / df * x), true, true);
if ... | javascript | function ptlog(df, lowerTail) {
return function(x) {
var val;
if (utils.hasNaN(x, df) || df <= 0) { return NaN; }
val = df > x * x ?
bratio(0.5, df / 2, x * x / (df + x * x), false, true)
: bratio(df / 2, 0.5, 1 / (1 + x / df * x), true, true);
if ... | [
"function",
"ptlog",
"(",
"df",
",",
"lowerTail",
")",
"{",
"return",
"function",
"(",
"x",
")",
"{",
"var",
"val",
";",
"if",
"(",
"utils",
".",
"hasNaN",
"(",
"x",
",",
"df",
")",
"||",
"df",
"<=",
"0",
")",
"{",
"return",
"NaN",
";",
"}",
... | cumulative distribution function, log version based on pt.c from R implementation | [
"cumulative",
"distribution",
"function",
"log",
"version",
"based",
"on",
"pt",
".",
"c",
"from",
"R",
"implementation"
] | 54d249ca9903a9535f963da711bd3a87fb229c0b | https://github.com/PanthR/panthrMath/blob/54d249ca9903a9535f963da711bd3a87fb229c0b/panthrMath/distributions/t.js#L85-L99 | train |
jonschlinkert/verbalize | index.js | Verbalize | function Verbalize(options) {
if (!(this instanceof Verbalize)) {
return new Verbalize(options);
}
Logger.call(this);
this.options = options || {};
this.define('cache', {});
use(this);
this.initDefaults();
this.initPlugins();
} | javascript | function Verbalize(options) {
if (!(this instanceof Verbalize)) {
return new Verbalize(options);
}
Logger.call(this);
this.options = options || {};
this.define('cache', {});
use(this);
this.initDefaults();
this.initPlugins();
} | [
"function",
"Verbalize",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Verbalize",
")",
")",
"{",
"return",
"new",
"Verbalize",
"(",
"options",
")",
";",
"}",
"Logger",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"options... | Create an instance of `Verbalize` with the given `options`.
```js
var logger = new Verbalize({verbose: true});
```
@param {Object} `options`
@api public | [
"Create",
"an",
"instance",
"of",
"Verbalize",
"with",
"the",
"given",
"options",
"."
] | 3d590602fde6a13682d0eebc180c731ea386b64f | https://github.com/jonschlinkert/verbalize/blob/3d590602fde6a13682d0eebc180c731ea386b64f/index.js#L30-L40 | train |
el2iot2/grunt-hogan | Gruntfile.js | log | function log(err, stdout, stderr, cb) {
//And handle errors (if any)
if (err) {
grunt.log.errorlns(err);
}
else if (stderr) {
grunt.log.errorlns(stderr);
}
else {
//Otherwise load a lodash... | javascript | function log(err, stdout, stderr, cb) {
//And handle errors (if any)
if (err) {
grunt.log.errorlns(err);
}
else if (stderr) {
grunt.log.errorlns(stderr);
}
else {
//Otherwise load a lodash... | [
"function",
"log",
"(",
"err",
",",
"stdout",
",",
"stderr",
",",
"cb",
")",
"{",
"//And handle errors (if any)",
"if",
"(",
"err",
")",
"{",
"grunt",
".",
"log",
".",
"errorlns",
"(",
"err",
")",
";",
"}",
"else",
"if",
"(",
"stderr",
")",
"{",
"g... | But catch the output | [
"But",
"catch",
"the",
"output"
] | 47962b7f63593c61fa0e2b0158f10bc6f8d51ca8 | https://github.com/el2iot2/grunt-hogan/blob/47962b7f63593c61fa0e2b0158f10bc6f8d51ca8/Gruntfile.js#L30-L56 | train |
AndreasMadsen/blow | blow.js | generateIndex | function generateIndex(base, files) {
var document = base.copy();
var head = document.find().only().elem('head').toValue();
// set title
head.find()
.only().elem('title').toValue()
.setContent('Mocha Tests - all');
// bind testcases
Object.keys(files).forEach(function (relative) {
head.app... | javascript | function generateIndex(base, files) {
var document = base.copy();
var head = document.find().only().elem('head').toValue();
// set title
head.find()
.only().elem('title').toValue()
.setContent('Mocha Tests - all');
// bind testcases
Object.keys(files).forEach(function (relative) {
head.app... | [
"function",
"generateIndex",
"(",
"base",
",",
"files",
")",
"{",
"var",
"document",
"=",
"base",
".",
"copy",
"(",
")",
";",
"var",
"head",
"=",
"document",
".",
"find",
"(",
")",
".",
"only",
"(",
")",
".",
"elem",
"(",
"'head'",
")",
".",
"toV... | generate the master testsuite | [
"generate",
"the",
"master",
"testsuite"
] | 51f0e664228ce6bcfdda8a82665d783a7caabf1c | https://github.com/AndreasMadsen/blow/blob/51f0e664228ce6bcfdda8a82665d783a7caabf1c/blow.js#L163-L178 | train |
derdesign/protos | lib/driver.js | function(o, callback) {
var self = this;
// Model::insert > Get ID > Create Model
this.insert(o, function(err, id) {
if (err) {
callback.call(self, err, null);
} else {
self.get(id, function(err, model) {
if (err) {
callback.call(self, err, null);
... | javascript | function(o, callback) {
var self = this;
// Model::insert > Get ID > Create Model
this.insert(o, function(err, id) {
if (err) {
callback.call(self, err, null);
} else {
self.get(id, function(err, model) {
if (err) {
callback.call(self, err, null);
... | [
"function",
"(",
"o",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Model::insert > Get ID > Create Model",
"this",
".",
"insert",
"(",
"o",
",",
"function",
"(",
"err",
",",
"id",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"."... | Creates a new model object. Saves into the
database, then creates the model with the provided data.
Validation should be performed against the values in `o`,
throwing an Error if not satisfied.
Provides: [err, model]
@param {object} o
@param {function} callback | [
"Creates",
"a",
"new",
"model",
"object",
".",
"Saves",
"into",
"the",
"database",
"then",
"creates",
"the",
"model",
"with",
"the",
"provided",
"data",
"."
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/driver.js#L358-L376 | train | |
tolokoban/ToloFrameWork | ker/mod/tfw.view.cropped-image.js | cropHorizontally | function cropHorizontally( img ) {
var zoom = this.height / img.height;
var x = 0;
if( this.cropping == 'body' ) {
x = 0.5 * (this.width - img.width * zoom);
}
else if( this.cropping == 'tail' ) {
x = this.width - img.width * zoom;
}
draw.call( this, img, x, 0, zoom );
} | javascript | function cropHorizontally( img ) {
var zoom = this.height / img.height;
var x = 0;
if( this.cropping == 'body' ) {
x = 0.5 * (this.width - img.width * zoom);
}
else if( this.cropping == 'tail' ) {
x = this.width - img.width * zoom;
}
draw.call( this, img, x, 0, zoom );
} | [
"function",
"cropHorizontally",
"(",
"img",
")",
"{",
"var",
"zoom",
"=",
"this",
".",
"height",
"/",
"img",
".",
"height",
";",
"var",
"x",
"=",
"0",
";",
"if",
"(",
"this",
".",
"cropping",
"==",
"'body'",
")",
"{",
"x",
"=",
"0.5",
"*",
"(",
... | If img is set to have the same height as the view, it will overflow horizontally. | [
"If",
"img",
"is",
"set",
"to",
"have",
"the",
"same",
"height",
"as",
"the",
"view",
"it",
"will",
"overflow",
"horizontally",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.cropped-image.js#L57-L67 | train |
tolokoban/ToloFrameWork | ker/mod/tfw.view.cropped-image.js | cropVertically | function cropVertically( img ) {
var zoom = this.width / img.width;
var y = 0;
if( this.cropping == 'body' ) {
y = 0.5 * (this.height - img.height * zoom);
}
else if( this.cropping == 'tail' ) {
y = this.height - img.height * zoom;
}
draw.call( this, img, 0, y, zoom );
} | javascript | function cropVertically( img ) {
var zoom = this.width / img.width;
var y = 0;
if( this.cropping == 'body' ) {
y = 0.5 * (this.height - img.height * zoom);
}
else if( this.cropping == 'tail' ) {
y = this.height - img.height * zoom;
}
draw.call( this, img, 0, y, zoom );
} | [
"function",
"cropVertically",
"(",
"img",
")",
"{",
"var",
"zoom",
"=",
"this",
".",
"width",
"/",
"img",
".",
"width",
";",
"var",
"y",
"=",
"0",
";",
"if",
"(",
"this",
".",
"cropping",
"==",
"'body'",
")",
"{",
"y",
"=",
"0.5",
"*",
"(",
"th... | If img is set to have the same width as the view, it will overflow vertically. | [
"If",
"img",
"is",
"set",
"to",
"have",
"the",
"same",
"width",
"as",
"the",
"view",
"it",
"will",
"overflow",
"vertically",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/tfw.view.cropped-image.js#L73-L83 | train |
linyngfly/omelo-admin | lib/master/masterAgent.js | function(socket, reqId, moduleId, msg) {
doSend(socket, 'monitor', protocol.composeRequest(reqId, moduleId, msg));
} | javascript | function(socket, reqId, moduleId, msg) {
doSend(socket, 'monitor', protocol.composeRequest(reqId, moduleId, msg));
} | [
"function",
"(",
"socket",
",",
"reqId",
",",
"moduleId",
",",
"msg",
")",
"{",
"doSend",
"(",
"socket",
",",
"'monitor'",
",",
"protocol",
".",
"composeRequest",
"(",
"reqId",
",",
"moduleId",
",",
"msg",
")",
")",
";",
"}"
] | send msg to monitor
@param {Object} socket socket-io object
@param {Number} reqId request id
@param {String} moduleId module id/name
@param {Object} msg message
@api private | [
"send",
"msg",
"to",
"monitor"
] | 1cd692c16ab63b9c0d4009535f300f2ca584b691 | https://github.com/linyngfly/omelo-admin/blob/1cd692c16ab63b9c0d4009535f300f2ca584b691/lib/master/masterAgent.js#L479-L481 | train | |
bloody-ux/menreiki | lib/core/dva-loading.js | createLoading | function createLoading(opts = {}) {
const namespace = opts.namespace || NAMESPACE;
const {
only = [], except = []
} = opts;
if (only.length > 0 && except.length > 0) {
throw Error('It is ambiguous to configurate `only` and `except` items at the same time.');
}
const initialState = {
global: fa... | javascript | function createLoading(opts = {}) {
const namespace = opts.namespace || NAMESPACE;
const {
only = [], except = []
} = opts;
if (only.length > 0 && except.length > 0) {
throw Error('It is ambiguous to configurate `only` and `except` items at the same time.');
}
const initialState = {
global: fa... | [
"function",
"createLoading",
"(",
"opts",
"=",
"{",
"}",
")",
"{",
"const",
"namespace",
"=",
"opts",
".",
"namespace",
"||",
"NAMESPACE",
";",
"const",
"{",
"only",
"=",
"[",
"]",
",",
"except",
"=",
"[",
"]",
"}",
"=",
"opts",
";",
"if",
"(",
"... | added loading state when distaching an action
@param {{ namespace?: string, only?: Array, except?: Array }} opts plugin options | [
"added",
"loading",
"state",
"when",
"distaching",
"an",
"action"
] | 66079c13a37ce96d261dfd6ab9e926856f107ba8 | https://github.com/bloody-ux/menreiki/blob/66079c13a37ce96d261dfd6ab9e926856f107ba8/lib/core/dva-loading.js#L10-L116 | train |
epeios-q37/xdhelcq | js/mktree/mktree.js | addEvent | function addEvent(o,e,f){
if (o.addEventListener){ o.addEventListener(e,f,false); return true; }
else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
else { return false; }
} | javascript | function addEvent(o,e,f){
if (o.addEventListener){ o.addEventListener(e,f,false); return true; }
else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
else { return false; }
} | [
"function",
"addEvent",
"(",
"o",
",",
"e",
",",
"f",
")",
"{",
"if",
"(",
"o",
".",
"addEventListener",
")",
"{",
"o",
".",
"addEventListener",
"(",
"e",
",",
"f",
",",
"false",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"o",
"."... | Utility function to add an event listener | [
"Utility",
"function",
"to",
"add",
"an",
"event",
"listener"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/mktree/mktree.js#L26-L30 | train |
epeios-q37/xdhelcq | js/mktree/mktree.js | setDefault | function setDefault(name,val) {
if (typeof(window[name])=="undefined" || window[name]==null) {
window[name]=val;
}
} | javascript | function setDefault(name,val) {
if (typeof(window[name])=="undefined" || window[name]==null) {
window[name]=val;
}
} | [
"function",
"setDefault",
"(",
"name",
",",
"val",
")",
"{",
"if",
"(",
"typeof",
"(",
"window",
"[",
"name",
"]",
")",
"==",
"\"undefined\"",
"||",
"window",
"[",
"name",
"]",
"==",
"null",
")",
"{",
"window",
"[",
"name",
"]",
"=",
"val",
";",
... | utility function to set a global variable if it is not already set | [
"utility",
"function",
"to",
"set",
"a",
"global",
"variable",
"if",
"it",
"is",
"not",
"already",
"set"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/mktree/mktree.js#L33-L37 | train |
epeios-q37/xdhelcq | js/mktree/mktree.js | expandTree | function expandTree(treeId) {
var ul = document.getElementById(treeId);
if (ul == null) { return false; }
expandCollapseList(ul,nodeOpenClass);
} | javascript | function expandTree(treeId) {
var ul = document.getElementById(treeId);
if (ul == null) { return false; }
expandCollapseList(ul,nodeOpenClass);
} | [
"function",
"expandTree",
"(",
"treeId",
")",
"{",
"var",
"ul",
"=",
"document",
".",
"getElementById",
"(",
"treeId",
")",
";",
"if",
"(",
"ul",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"expandCollapseList",
"(",
"ul",
",",
"nodeOpenClass",
... | Full expands a tree with a given ID | [
"Full",
"expands",
"a",
"tree",
"with",
"a",
"given",
"ID"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/mktree/mktree.js#L40-L44 | train |
epeios-q37/xdhelcq | js/mktree/mktree.js | collapseTree | function collapseTree(treeId) {
var ul = document.getElementById(treeId);
if (ul == null) { return false; }
expandCollapseList(ul,nodeClosedClass);
} | javascript | function collapseTree(treeId) {
var ul = document.getElementById(treeId);
if (ul == null) { return false; }
expandCollapseList(ul,nodeClosedClass);
} | [
"function",
"collapseTree",
"(",
"treeId",
")",
"{",
"var",
"ul",
"=",
"document",
".",
"getElementById",
"(",
"treeId",
")",
";",
"if",
"(",
"ul",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"expandCollapseList",
"(",
"ul",
",",
"nodeClosedClas... | Fully collapses a tree with a given ID | [
"Fully",
"collapses",
"a",
"tree",
"with",
"a",
"given",
"ID"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/mktree/mktree.js#L47-L51 | train |
epeios-q37/xdhelcq | js/mktree/mktree.js | expandToItem | function expandToItem(treeId,itemId) {
var ul = document.getElementById(treeId);
if (ul == null) { return false; }
var ret = expandCollapseList(ul,nodeOpenClass,itemId);
if (ret) {
var o = document.getElementById(itemId);
if (o.scrollIntoView) {
o.scrollIntoView(false);
}
}
} | javascript | function expandToItem(treeId,itemId) {
var ul = document.getElementById(treeId);
if (ul == null) { return false; }
var ret = expandCollapseList(ul,nodeOpenClass,itemId);
if (ret) {
var o = document.getElementById(itemId);
if (o.scrollIntoView) {
o.scrollIntoView(false);
}
}
} | [
"function",
"expandToItem",
"(",
"treeId",
",",
"itemId",
")",
"{",
"var",
"ul",
"=",
"document",
".",
"getElementById",
"(",
"treeId",
")",
";",
"if",
"(",
"ul",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"var",
"ret",
"=",
"expandCollapseLi... | Expands enough nodes to expose an LI with a given ID | [
"Expands",
"enough",
"nodes",
"to",
"expose",
"an",
"LI",
"with",
"a",
"given",
"ID"
] | 8cffac0650297c313779c9fba545096be24e52a5 | https://github.com/epeios-q37/xdhelcq/blob/8cffac0650297c313779c9fba545096be24e52a5/js/mktree/mktree.js#L54-L64 | 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.