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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cloudkick/whiskey | lib/common.js | function(callback) {
var errName;
try {
if (self._covered) {
// If coverage is request, we want the testModule to reference the
// code instrumented by istanbul in lib-cov/ instead of any local code in lib/.
// This passage looks for variables assigned to by require('li... | javascript | function(callback) {
var errName;
try {
if (self._covered) {
// If coverage is request, we want the testModule to reference the
// code instrumented by istanbul in lib-cov/ instead of any local code in lib/.
// This passage looks for variables assigned to by require('li... | [
"function",
"(",
"callback",
")",
"{",
"var",
"errName",
";",
"try",
"{",
"if",
"(",
"self",
".",
"_covered",
")",
"{",
"// If coverage is request, we want the testModule to reference the",
"// code instrumented by istanbul in lib-cov/ instead of any local code in lib/.",
"// T... | Require the test file | [
"Require",
"the",
"test",
"file"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/common.js#L357-L417 | train | |
cloudkick/whiskey | lib/common.js | function(callback) {
var queue;
if (exportedFunctionsNames.length === 0) {
callback();
return;
}
function taskFunc(task, callback) {
var setUpFunc = task.setUpFunc, tearDownFunc = task.tearDownFunc;
async.waterfall([
function runSetUp(callback) {
... | javascript | function(callback) {
var queue;
if (exportedFunctionsNames.length === 0) {
callback();
return;
}
function taskFunc(task, callback) {
var setUpFunc = task.setUpFunc, tearDownFunc = task.tearDownFunc;
async.waterfall([
function runSetUp(callback) {
... | [
"function",
"(",
"callback",
")",
"{",
"var",
"queue",
";",
"if",
"(",
"exportedFunctionsNames",
".",
"length",
"===",
"0",
")",
"{",
"callback",
"(",
")",
";",
"return",
";",
"}",
"function",
"taskFunc",
"(",
"task",
",",
"callback",
")",
"{",
"var",
... | Run the tests | [
"Run",
"the",
"tests"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/common.js#L432-L497 | train | |
cloudkick/whiskey | lib/common.js | function (actualArgs, expectedArgs) {
var i;
if (actualArgs.length !== expectedArgs.length) {
return false;
}
for (i = 0; i < expectedArgs.length; i++) {
if (actualArgs[i] !== expectedArgs[i]) {
return false;
}
}
return true;
} | javascript | function (actualArgs, expectedArgs) {
var i;
if (actualArgs.length !== expectedArgs.length) {
return false;
}
for (i = 0; i < expectedArgs.length; i++) {
if (actualArgs[i] !== expectedArgs[i]) {
return false;
}
}
return true;
} | [
"function",
"(",
"actualArgs",
",",
"expectedArgs",
")",
"{",
"var",
"i",
";",
"if",
"(",
"actualArgs",
".",
"length",
"!==",
"expectedArgs",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"expectedArg... | checks the actual args match the expected args | [
"checks",
"the",
"actual",
"args",
"match",
"the",
"expected",
"args"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/common.js#L714-L725 | train | |
basisjs/basisjs-tools-build | lib/build/js/makePackages.js | buildDep | function buildDep(file, pkg){
var files = [];
if (file.processed || file.package != pkg)
return files;
file.processed = true;
for (var i = 0, depFile; depFile = file.deps[i++];)
files.push.apply(files, buildDep(depFile, file.package));
files.push(file);
return files;
} | javascript | function buildDep(file, pkg){
var files = [];
if (file.processed || file.package != pkg)
return files;
file.processed = true;
for (var i = 0, depFile; depFile = file.deps[i++];)
files.push.apply(files, buildDep(depFile, file.package));
files.push(file);
return files;
} | [
"function",
"buildDep",
"(",
"file",
",",
"pkg",
")",
"{",
"var",
"files",
"=",
"[",
"]",
";",
"if",
"(",
"file",
".",
"processed",
"||",
"file",
".",
"package",
"!=",
"pkg",
")",
"return",
"files",
";",
"file",
".",
"processed",
"=",
"true",
";",
... | make require file list | [
"make",
"require",
"file",
"list"
] | 177018ab31b225cddb6a184693fe4746512e7af1 | https://github.com/basisjs/basisjs-tools-build/blob/177018ab31b225cddb6a184693fe4746512e7af1/lib/build/js/makePackages.js#L41-L55 | train |
somesocks/vet | dist/utils/assert.js | assert | function assert (validator, message) {
message = messageBuilder(message || 'vet/utils/assert error!');
if (isFunction(validator)) {
return function() {
var args = arguments;
if (validator.apply(this, args)) {
return true;
} else {
throw new Error(message.apply(this, args));
}
};
} else if (!... | javascript | function assert (validator, message) {
message = messageBuilder(message || 'vet/utils/assert error!');
if (isFunction(validator)) {
return function() {
var args = arguments;
if (validator.apply(this, args)) {
return true;
} else {
throw new Error(message.apply(this, args));
}
};
} else if (!... | [
"function",
"assert",
"(",
"validator",
",",
"message",
")",
"{",
"message",
"=",
"messageBuilder",
"(",
"message",
"||",
"'vet/utils/assert error!'",
")",
";",
"if",
"(",
"isFunction",
"(",
"validator",
")",
")",
"{",
"return",
"function",
"(",
")",
"{",
... | Wraps a validator, and throws an error if it returns false.
This is useful for some code that expects assertion-style validation.
@param validator - the validator to wrap
@param message - an optional message string to pass into the error
@returns a function that returns null if the arguments pass validation, or throws... | [
"Wraps",
"a",
"validator",
"and",
"throws",
"an",
"error",
"if",
"it",
"returns",
"false",
"."
] | 4557abeb6a8b470cb4a5823a2cc802c825ef29ef | https://github.com/somesocks/vet/blob/4557abeb6a8b470cb4a5823a2cc802c825ef29ef/dist/utils/assert.js#L20-L38 | train |
cloudkick/whiskey | lib/coverage.js | coverage | function coverage(data, type) {
var comparisionFunc;
var n = 0;
function isCovered(val) {
return (val > 0);
}
function isMissed(val) {
return !isCovered(val);
}
if (type === 'covered') {
comparisionFunc = isCovered;
}
else if (type === 'missed') {
comparisionFunc = isMissed;
}
e... | javascript | function coverage(data, type) {
var comparisionFunc;
var n = 0;
function isCovered(val) {
return (val > 0);
}
function isMissed(val) {
return !isCovered(val);
}
if (type === 'covered') {
comparisionFunc = isCovered;
}
else if (type === 'missed') {
comparisionFunc = isMissed;
}
e... | [
"function",
"coverage",
"(",
"data",
",",
"type",
")",
"{",
"var",
"comparisionFunc",
";",
"var",
"n",
"=",
"0",
";",
"function",
"isCovered",
"(",
"val",
")",
"{",
"return",
"(",
"val",
">",
"0",
")",
";",
"}",
"function",
"isMissed",
"(",
"val",
... | Total coverage for the given file data.
@param {Array} data
@return {Type} | [
"Total",
"coverage",
"for",
"the",
"given",
"file",
"data",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/coverage.js#L90-L121 | train |
cloudkick/whiskey | lib/coverage.js | aggregateCoverage | function aggregateCoverage(files) {
var i, len, file, content, results;
var resultsObj = getEmptyResultObject();
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
content = JSON.parse(fs.readFileSync(file).toString());
resultsObj = populateCoverage(resultsObj, content);
}
return r... | javascript | function aggregateCoverage(files) {
var i, len, file, content, results;
var resultsObj = getEmptyResultObject();
for (i = 0, len = files.length; i < len; i++) {
file = files[i];
content = JSON.parse(fs.readFileSync(file).toString());
resultsObj = populateCoverage(resultsObj, content);
}
return r... | [
"function",
"aggregateCoverage",
"(",
"files",
")",
"{",
"var",
"i",
",",
"len",
",",
"file",
",",
"content",
",",
"results",
";",
"var",
"resultsObj",
"=",
"getEmptyResultObject",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"files",
"... | Read multiple coverage files and return aggregated coverage. | [
"Read",
"multiple",
"coverage",
"files",
"and",
"return",
"aggregated",
"coverage",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/coverage.js#L218-L229 | train |
GMOD/bgzf-filehandle | src/unzip.js | pakoUnzip | async function pakoUnzip(inputData) {
let strm
let pos = 0
let i = 0
const chunks = []
let inflator
do {
const remainingInput = inputData.slice(pos)
inflator = new Inflate()
strm = inflator.strm
inflator.push(remainingInput, Z_SYNC_FLUSH)
if (inflator.err) throw new Error(inflator.msg)
... | javascript | async function pakoUnzip(inputData) {
let strm
let pos = 0
let i = 0
const chunks = []
let inflator
do {
const remainingInput = inputData.slice(pos)
inflator = new Inflate()
strm = inflator.strm
inflator.push(remainingInput, Z_SYNC_FLUSH)
if (inflator.err) throw new Error(inflator.msg)
... | [
"async",
"function",
"pakoUnzip",
"(",
"inputData",
")",
"{",
"let",
"strm",
"let",
"pos",
"=",
"0",
"let",
"i",
"=",
"0",
"const",
"chunks",
"=",
"[",
"]",
"let",
"inflator",
"do",
"{",
"const",
"remainingInput",
"=",
"inputData",
".",
"slice",
"(",
... | browserify-zlib, which is the zlib shim used by default in webpacked code, does not properly uncompress bgzf chunks that contain more than one bgzf block, so export an unzip function that uses pako directly if we are running in a browser. | [
"browserify",
"-",
"zlib",
"which",
"is",
"the",
"zlib",
"shim",
"used",
"by",
"default",
"in",
"webpacked",
"code",
"does",
"not",
"properly",
"uncompress",
"bgzf",
"chunks",
"that",
"contain",
"more",
"than",
"one",
"bgzf",
"block",
"so",
"export",
"an",
... | a43ddc0bc00b5610472de6ac5214ae50602be12e | https://github.com/GMOD/bgzf-filehandle/blob/a43ddc0bc00b5610472de6ac5214ae50602be12e/src/unzip.js#L12-L32 | train |
cloudkick/whiskey | lib/process_runner/runner.js | sink | function sink(modulename, level, message, obj) {
term.puts(sprintf('[green]%s[/green]: %s', modulename, message));
} | javascript | function sink(modulename, level, message, obj) {
term.puts(sprintf('[green]%s[/green]: %s', modulename, message));
} | [
"function",
"sink",
"(",
"modulename",
",",
"level",
",",
"message",
",",
"obj",
")",
"{",
"term",
".",
"puts",
"(",
"sprintf",
"(",
"'[green]%s[/green]: %s'",
",",
"modulename",
",",
"message",
")",
")",
";",
"}"
] | Set up logging | [
"Set",
"up",
"logging"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/process_runner/runner.js#L34-L36 | train |
Ivshti/name-to-imdb | providers/cinemeta.js | indexEntry | function indexEntry(entry) {
if (entry.year) entry.year = parseInt(entry.year.toString().split("-")[0]); // first year for series
var n = helpers.simplifyName(entry);
if (!meta[n]) meta[n] = [];
meta[n].push(entry);
byImdb[entry.imdb_id] = entry;
} | javascript | function indexEntry(entry) {
if (entry.year) entry.year = parseInt(entry.year.toString().split("-")[0]); // first year for series
var n = helpers.simplifyName(entry);
if (!meta[n]) meta[n] = [];
meta[n].push(entry);
byImdb[entry.imdb_id] = entry;
} | [
"function",
"indexEntry",
"(",
"entry",
")",
"{",
"if",
"(",
"entry",
".",
"year",
")",
"entry",
".",
"year",
"=",
"parseInt",
"(",
"entry",
".",
"year",
".",
"toString",
"(",
")",
".",
"split",
"(",
"\"-\"",
")",
"[",
"0",
"]",
")",
";",
"// fir... | Index entry in our in-mem index | [
"Index",
"entry",
"in",
"our",
"in",
"-",
"mem",
"index"
] | 529bcdf7ac034915991f4d2bac677f01f12cb647 | https://github.com/Ivshti/name-to-imdb/blob/529bcdf7ac034915991f4d2bac677f01f12cb647/providers/cinemeta.js#L11-L17 | train |
warehouseai/cdnup | file.js | File | function File(retries, cdn, options) {
options = options || {};
this.backoff = new Backoff({ min: 100, max: 20000 });
this.mime = options.mime || {};
this.retries = retries || 5;
this.client = cdn.client;
this.cdn = cdn;
} | javascript | function File(retries, cdn, options) {
options = options || {};
this.backoff = new Backoff({ min: 100, max: 20000 });
this.mime = options.mime || {};
this.retries = retries || 5;
this.client = cdn.client;
this.cdn = cdn;
} | [
"function",
"File",
"(",
"retries",
",",
"cdn",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"backoff",
"=",
"new",
"Backoff",
"(",
"{",
"min",
":",
"100",
",",
"max",
":",
"20000",
"}",
")",
";",
"this",... | Representation of a single file operation for the CDN.
@constructor
@param {Number} retries Amount of retries.
@param {CDNUp} cdn CDN reference.
@param {Object} options Additional configuration.
@api private | [
"Representation",
"of",
"a",
"single",
"file",
"operation",
"for",
"the",
"CDN",
"."
] | 208e90b8236fdd52d8f90685522ef56047a30fc4 | https://github.com/warehouseai/cdnup/blob/208e90b8236fdd52d8f90685522ef56047a30fc4/file.js#L21-L29 | train |
jonschlinkert/map-schema | lib/field.js | Field | function Field(type, config) {
if (utils.typeOf(type) === 'object') {
config = type;
type = null;
}
if (!utils.isObject(config)) {
throw new TypeError('expected config to be an object');
}
this.types = type || config.type || config.types || [];
this.types = typeof this.types === 'string'
?... | javascript | function Field(type, config) {
if (utils.typeOf(type) === 'object') {
config = type;
type = null;
}
if (!utils.isObject(config)) {
throw new TypeError('expected config to be an object');
}
this.types = type || config.type || config.types || [];
this.types = typeof this.types === 'string'
?... | [
"function",
"Field",
"(",
"type",
",",
"config",
")",
"{",
"if",
"(",
"utils",
".",
"typeOf",
"(",
"type",
")",
"===",
"'object'",
")",
"{",
"config",
"=",
"type",
";",
"type",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"utils",
".",
"isObject",
"(",... | Create a new `Field` of the given `type` to validate against,
and optional `config` object.
```js
var field = new Field('string', {
normalize: function(val) {
// do stuff to `val`
return val;
}
});
```
@param {String|Array} `type` One more JavaScript native types to use for validation.
@param {Object} `config`
@api pu... | [
"Create",
"a",
"new",
"Field",
"of",
"the",
"given",
"type",
"to",
"validate",
"against",
"and",
"optional",
"config",
"object",
"."
] | 08e11847e83ab91aa7460f6ee2249a64967a5d29 | https://github.com/jonschlinkert/map-schema/blob/08e11847e83ab91aa7460f6ee2249a64967a5d29/lib/field.js#L28-L63 | train |
rrharvey/grunt-file-blocks | lib/block.js | function (obj, other) {
var notIn = {};
for (var key in obj) {
if (other[key] === undefined) {
notIn[key] = true;
}
}
return _.keys(notIn);
} | javascript | function (obj, other) {
var notIn = {};
for (var key in obj) {
if (other[key] === undefined) {
notIn[key] = true;
}
}
return _.keys(notIn);
} | [
"function",
"(",
"obj",
",",
"other",
")",
"{",
"var",
"notIn",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"other",
"[",
"key",
"]",
"===",
"undefined",
")",
"{",
"notIn",
"[",
"key",
"]",
"=",
"true",
";"... | Find keys that exist in the specified object that don't exist
in the other object. | [
"Find",
"keys",
"that",
"exist",
"in",
"the",
"specified",
"object",
"that",
"don",
"t",
"exist",
"in",
"the",
"other",
"object",
"."
] | c1e3bfcb33df76ca820de580da3864085bfaed44 | https://github.com/rrharvey/grunt-file-blocks/blob/c1e3bfcb33df76ca820de580da3864085bfaed44/lib/block.js#L8-L16 | train | |
somesocks/vet | dist/numbers/isBetween.js | isBetween | function isBetween(lower, upper) {
return function (val) {
return isNumber(val) && val > lower && val < upper;
}
} | javascript | function isBetween(lower, upper) {
return function (val) {
return isNumber(val) && val > lower && val < upper;
}
} | [
"function",
"isBetween",
"(",
"lower",
",",
"upper",
")",
"{",
"return",
"function",
"(",
"val",
")",
"{",
"return",
"isNumber",
"(",
"val",
")",
"&&",
"val",
">",
"lower",
"&&",
"val",
"<",
"upper",
";",
"}",
"}"
] | Checks to see if a value is a negative number
@param {number} lower - the lower boundary value to check against
@param {number} upper - the upper boundary value to check against
@returns {function} - a validator function
@memberof vet.numbers | [
"Checks",
"to",
"see",
"if",
"a",
"value",
"is",
"a",
"negative",
"number"
] | 4557abeb6a8b470cb4a5823a2cc802c825ef29ef | https://github.com/somesocks/vet/blob/4557abeb6a8b470cb4a5823a2cc802c825ef29ef/dist/numbers/isBetween.js#L11-L15 | train |
taskcluster/dockerode-process | docker_process.js | DockerProc | function DockerProc(docker, config) {
EventEmitter.call(this);
this.docker = docker;
this._createConfig = config.create;
this._startConfig = config.start;
this.stdout = new streams.PassThrough();
this.stderr = new streams.PassThrough();
} | javascript | function DockerProc(docker, config) {
EventEmitter.call(this);
this.docker = docker;
this._createConfig = config.create;
this._startConfig = config.start;
this.stdout = new streams.PassThrough();
this.stderr = new streams.PassThrough();
} | [
"function",
"DockerProc",
"(",
"docker",
",",
"config",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"docker",
"=",
"docker",
";",
"this",
".",
"_createConfig",
"=",
"config",
".",
"create",
";",
"this",
".",
"_startConfig",... | Loosely modeled on node's own child_process object thought the interface to get
the child process is different. | [
"Loosely",
"modeled",
"on",
"node",
"s",
"own",
"child_process",
"object",
"thought",
"the",
"interface",
"to",
"get",
"the",
"child",
"process",
"is",
"different",
"."
] | f0ac2d8215f7c3ac513425a92a8f1d9edacc4f4e | https://github.com/taskcluster/dockerode-process/blob/f0ac2d8215f7c3ac513425a92a8f1d9edacc4f4e/docker_process.js#L27-L36 | train |
taskcluster/dockerode-process | docker_process.js | function(options) {
options = options || {};
if (!('pull' in options)) options.pull = true;
// no pull means no extra stream processing...
if (!options.pull) return this._run();
return new Promise(function(accept, reject) {
// pull the image (or use on in the cache and output status in stdou... | javascript | function(options) {
options = options || {};
if (!('pull' in options)) options.pull = true;
// no pull means no extra stream processing...
if (!options.pull) return this._run();
return new Promise(function(accept, reject) {
// pull the image (or use on in the cache and output status in stdou... | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"(",
"'pull'",
"in",
"options",
")",
")",
"options",
".",
"pull",
"=",
"true",
";",
"// no pull means no extra stream processing...",
"if",
"(",
"!",
"o... | Run the docker process and resolve the promise on complete.
@param {Object} options for running the container.
@param {Boolean} [options.pull=true] when true pull the image and prepend the
download details to stdout. | [
"Run",
"the",
"docker",
"process",
"and",
"resolve",
"the",
"promise",
"on",
"complete",
"."
] | f0ac2d8215f7c3ac513425a92a8f1d9edacc4f4e | https://github.com/taskcluster/dockerode-process/blob/f0ac2d8215f7c3ac513425a92a8f1d9edacc4f4e/docker_process.js#L130-L151 | train | |
taskcluster/dockerode-process | docker_process.js | function() {
var that = this;
this.killed = true;
if (this.started) {
this.container.kill();
} else {
this.once('container start', function() {
that.container.kill();
});
}
} | javascript | function() {
var that = this;
this.killed = true;
if (this.started) {
this.container.kill();
} else {
this.once('container start', function() {
that.container.kill();
});
}
} | [
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
";",
"this",
".",
"killed",
"=",
"true",
";",
"if",
"(",
"this",
".",
"started",
")",
"{",
"this",
".",
"container",
".",
"kill",
"(",
")",
";",
"}",
"else",
"{",
"this",
".",
"once",
"(",
... | Kill docker container | [
"Kill",
"docker",
"container"
] | f0ac2d8215f7c3ac513425a92a8f1d9edacc4f4e | https://github.com/taskcluster/dockerode-process/blob/f0ac2d8215f7c3ac513425a92a8f1d9edacc4f4e/docker_process.js#L154-L164 | train | |
somesocks/vet | dist/utils/returns.js | returns | function returns(func, validator, message) {
message = messageBuilder(message || 'vet/utils/returns error!');
return function _returnsInstance() {
var args = arguments;
var result = func.apply(this, arguments);
if (validator(result)) {
return result;
} else {
throw new Error(message.call(this, result)... | javascript | function returns(func, validator, message) {
message = messageBuilder(message || 'vet/utils/returns error!');
return function _returnsInstance() {
var args = arguments;
var result = func.apply(this, arguments);
if (validator(result)) {
return result;
} else {
throw new Error(message.call(this, result)... | [
"function",
"returns",
"(",
"func",
",",
"validator",
",",
"message",
")",
"{",
"message",
"=",
"messageBuilder",
"(",
"message",
"||",
"'vet/utils/returns error!'",
")",
";",
"return",
"function",
"_returnsInstance",
"(",
")",
"{",
"var",
"args",
"=",
"argume... | Wraps a function in a validator which checks its return value, and throws an error if the return value is bad.
@param func - the function to wrap
@param validator - the validator function. This gets passed the return value
@param message - an optional message string to pass into the error thrown
@returns a wrapped fu... | [
"Wraps",
"a",
"function",
"in",
"a",
"validator",
"which",
"checks",
"its",
"return",
"value",
"and",
"throws",
"an",
"error",
"if",
"the",
"return",
"value",
"is",
"bad",
"."
] | 4557abeb6a8b470cb4a5823a2cc802c825ef29ef | https://github.com/somesocks/vet/blob/4557abeb6a8b470cb4a5823a2cc802c825ef29ef/dist/utils/returns.js#L18-L31 | train |
feedhenry/fh-amqp-js | lib/amqpjs.js | setupConn | function setupConn(connectCfg, options) {
var conn = amqp.createConnection(connectCfg, options);
conn.on('ready', function() {
debug('received ready event from node-amqp');
var eventName = 'connection';
//Ready event will be emitted when re-connected.
//To keep backward compatible, only ... | javascript | function setupConn(connectCfg, options) {
var conn = amqp.createConnection(connectCfg, options);
conn.on('ready', function() {
debug('received ready event from node-amqp');
var eventName = 'connection';
//Ready event will be emitted when re-connected.
//To keep backward compatible, only ... | [
"function",
"setupConn",
"(",
"connectCfg",
",",
"options",
")",
"{",
"var",
"conn",
"=",
"amqp",
".",
"createConnection",
"(",
"connectCfg",
",",
"options",
")",
";",
"conn",
".",
"on",
"(",
"'ready'",
",",
"function",
"(",
")",
"{",
"debug",
"(",
"'r... | Private functions
Setup the connection
@param {Object} connectCfg AMQP connection configurations.
@param {Object} options AMQP connection options.
See https://github.com/postwait/node-amqp#connection-options-and-url for the format of the connectCfg and options | [
"Private",
"functions",
"Setup",
"the",
"connection"
] | 611adf62f661e4d42066f1c4d5a39dd8692ec720 | https://github.com/feedhenry/fh-amqp-js/blob/611adf62f661e4d42066f1c4d5a39dd8692ec720/lib/amqpjs.js#L323-L364 | train |
feedhenry/fh-amqp-js | lib/amqpjs.js | autoSubscribe | function autoSubscribe() {
//re-add pending subscribers
if (_pendingSubscribers.length > 0) {
async.each(_pendingSubscribers, function(sub, callback) {
debug('Add pending subscriber', sub);
self.subscribeToTopic(sub.exchange, sub.queue, sub.filter, sub.subscriber, sub.opts, function(err) {... | javascript | function autoSubscribe() {
//re-add pending subscribers
if (_pendingSubscribers.length > 0) {
async.each(_pendingSubscribers, function(sub, callback) {
debug('Add pending subscriber', sub);
self.subscribeToTopic(sub.exchange, sub.queue, sub.filter, sub.subscriber, sub.opts, function(err) {... | [
"function",
"autoSubscribe",
"(",
")",
"{",
"//re-add pending subscribers",
"if",
"(",
"_pendingSubscribers",
".",
"length",
">",
"0",
")",
"{",
"async",
".",
"each",
"(",
"_pendingSubscribers",
",",
"function",
"(",
"sub",
",",
"callback",
")",
"{",
"debug",
... | Re-add subscriber functions that are created when there is no connection | [
"Re",
"-",
"add",
"subscriber",
"functions",
"that",
"are",
"created",
"when",
"there",
"is",
"no",
"connection"
] | 611adf62f661e4d42066f1c4d5a39dd8692ec720 | https://github.com/feedhenry/fh-amqp-js/blob/611adf62f661e4d42066f1c4d5a39dd8692ec720/lib/amqpjs.js#L369-L389 | train |
feedhenry/fh-amqp-js | lib/amqpjs.js | publishCachedMessages | function publishCachedMessages() {
if (_cachedPublishMessages.length > 0) {
async.each(_cachedPublishMessages, function(message, callback) {
debug('republish message', message);
self.publishTopic(message.exchange, message.topic, message.message, message.options, function(err) {
if (e... | javascript | function publishCachedMessages() {
if (_cachedPublishMessages.length > 0) {
async.each(_cachedPublishMessages, function(message, callback) {
debug('republish message', message);
self.publishTopic(message.exchange, message.topic, message.message, message.options, function(err) {
if (e... | [
"function",
"publishCachedMessages",
"(",
")",
"{",
"if",
"(",
"_cachedPublishMessages",
".",
"length",
">",
"0",
")",
"{",
"async",
".",
"each",
"(",
"_cachedPublishMessages",
",",
"function",
"(",
"message",
",",
"callback",
")",
"{",
"debug",
"(",
"'repub... | Re-publish messages that received when there is no connection | [
"Re",
"-",
"publish",
"messages",
"that",
"received",
"when",
"there",
"is",
"no",
"connection"
] | 611adf62f661e4d42066f1c4d5a39dd8692ec720 | https://github.com/feedhenry/fh-amqp-js/blob/611adf62f661e4d42066f1c4d5a39dd8692ec720/lib/amqpjs.js#L394-L412 | train |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | filter_email | function filter_email(value) {
var m = EMAIL_RE.exec(value);
if(m == null) throw OptError('Excpeted an email address.');
return m[1];
} | javascript | function filter_email(value) {
var m = EMAIL_RE.exec(value);
if(m == null) throw OptError('Excpeted an email address.');
return m[1];
} | [
"function",
"filter_email",
"(",
"value",
")",
"{",
"var",
"m",
"=",
"EMAIL_RE",
".",
"exec",
"(",
"value",
")",
";",
"if",
"(",
"m",
"==",
"null",
")",
"throw",
"OptError",
"(",
"'Excpeted an email address.'",
")",
";",
"return",
"m",
"[",
"1",
"]",
... | Switch argument filter that expects an email address. An exception is throwed if the criteria doesn`t match. | [
"Switch",
"argument",
"filter",
"that",
"expects",
"an",
"email",
"address",
".",
"An",
"exception",
"is",
"throwed",
"if",
"the",
"criteria",
"doesn",
"t",
"match",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L56-L60 | train |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | build_rules | function build_rules(filters, arr) {
var rules = [];
for(var i=0; i<arr.length; i++) {
var r = arr[i], rule
if(!contains_expr(r)) throw OptError('Rule MUST contain an option.');
switch(r.length) {
case 1:
rule = build_rule(filters, r[0]);
break... | javascript | function build_rules(filters, arr) {
var rules = [];
for(var i=0; i<arr.length; i++) {
var r = arr[i], rule
if(!contains_expr(r)) throw OptError('Rule MUST contain an option.');
switch(r.length) {
case 1:
rule = build_rule(filters, r[0]);
break... | [
"function",
"build_rules",
"(",
"filters",
",",
"arr",
")",
"{",
"var",
"rules",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"r",
"=",
"arr",
"[",
"i",
"]",
","... | Buildes rules from a switches collection. The switches collection is defined when constructing a new OptionParser object. | [
"Buildes",
"rules",
"from",
"a",
"switches",
"collection",
".",
"The",
"switches",
"collection",
"is",
"defined",
"when",
"constructing",
"a",
"new",
"OptionParser",
"object",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L73-L98 | train |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | extend | function extend(dest, src) {
var result = dest;
for(var n in src) {
result[n] = src[n];
}
return result;
} | javascript | function extend(dest, src) {
var result = dest;
for(var n in src) {
result[n] = src[n];
}
return result;
} | [
"function",
"extend",
"(",
"dest",
",",
"src",
")",
"{",
"var",
"result",
"=",
"dest",
";",
"for",
"(",
"var",
"n",
"in",
"src",
")",
"{",
"result",
"[",
"n",
"]",
"=",
"src",
"[",
"n",
"]",
";",
"}",
"return",
"result",
";",
"}"
] | Extends destination object with members of source object | [
"Extends",
"destination",
"object",
"with",
"members",
"of",
"source",
"object"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L149-L155 | train |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | spaces | function spaces(arg1, arg2) {
var l, builder = [];
if(arg1.constructor === Number) {
l = arg1;
} else {
if(arg1.length == arg2) return arg1;
l = arg2 - arg1.length;
builder.push(arg1);
}
while(l-- > 0) builder.push(' ');
return builder.join('');
} | javascript | function spaces(arg1, arg2) {
var l, builder = [];
if(arg1.constructor === Number) {
l = arg1;
} else {
if(arg1.length == arg2) return arg1;
l = arg2 - arg1.length;
builder.push(arg1);
}
while(l-- > 0) builder.push(' ');
return builder.join('');
} | [
"function",
"spaces",
"(",
"arg1",
",",
"arg2",
")",
"{",
"var",
"l",
",",
"builder",
"=",
"[",
"]",
";",
"if",
"(",
"arg1",
".",
"constructor",
"===",
"Number",
")",
"{",
"l",
"=",
"arg1",
";",
"}",
"else",
"{",
"if",
"(",
"arg1",
".",
"length... | Appends spaces to match specified number of chars | [
"Appends",
"spaces",
"to",
"match",
"specified",
"number",
"of",
"chars"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L158-L169 | train |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | function(value, fn) {
if(value.constructor === Function ) {
this.default_handler = value;
} else if(value.constructor === Number) {
this.on_args[value] = fn;
} else {
this.on_switches[value] = fn;
}
} | javascript | function(value, fn) {
if(value.constructor === Function ) {
this.default_handler = value;
} else if(value.constructor === Number) {
this.on_args[value] = fn;
} else {
this.on_switches[value] = fn;
}
} | [
"function",
"(",
"value",
",",
"fn",
")",
"{",
"if",
"(",
"value",
".",
"constructor",
"===",
"Function",
")",
"{",
"this",
".",
"default_handler",
"=",
"value",
";",
"}",
"else",
"if",
"(",
"value",
".",
"constructor",
"===",
"Number",
")",
"{",
"th... | Adds args and switchs handler. | [
"Adds",
"args",
"and",
"switchs",
"handler",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L203-L211 | train | |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | function(args) {
var result = [], callback;
var rules = build_rules(this.filters, this._rules);
var tokens = args.concat([]);
var token;
while(this._halt == false && (token = tokens.shift())) {
if(LONG_SWITCH_RE.test(token) || SHORT_SWITCH_RE.test(token)) {
... | javascript | function(args) {
var result = [], callback;
var rules = build_rules(this.filters, this._rules);
var tokens = args.concat([]);
var token;
while(this._halt == false && (token = tokens.shift())) {
if(LONG_SWITCH_RE.test(token) || SHORT_SWITCH_RE.test(token)) {
... | [
"function",
"(",
"args",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"callback",
";",
"var",
"rules",
"=",
"build_rules",
"(",
"this",
".",
"filters",
",",
"this",
".",
"_rules",
")",
";",
"var",
"tokens",
"=",
"args",
".",
"concat",
"(",
"[",
... | Parses specified args. Returns remaining arguments. | [
"Parses",
"specified",
"args",
".",
"Returns",
"remaining",
"arguments",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L222-L266 | train | |
cloudkick/whiskey | lib/extern/optparse/lib/optparse.js | function() {
var builder = [this.banner, '', this.options_title],
shorts = false, longest = 0, rule;
var rules = build_rules(this.filters, this._rules);
for(var i = 0; i < rules.length; i++) {
rule = rules[i];
// Quick-analyze the options.
if(rule.... | javascript | function() {
var builder = [this.banner, '', this.options_title],
shorts = false, longest = 0, rule;
var rules = build_rules(this.filters, this._rules);
for(var i = 0; i < rules.length; i++) {
rule = rules[i];
// Quick-analyze the options.
if(rule.... | [
"function",
"(",
")",
"{",
"var",
"builder",
"=",
"[",
"this",
".",
"banner",
",",
"''",
",",
"this",
".",
"options_title",
"]",
",",
"shorts",
"=",
"false",
",",
"longest",
"=",
"0",
",",
"rule",
";",
"var",
"rules",
"=",
"build_rules",
"(",
"this... | Returns a string representation of this OptionParser instance. | [
"Returns",
"a",
"string",
"representation",
"of",
"this",
"OptionParser",
"instance",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/extern/optparse/lib/optparse.js#L282-L303 | train | |
somesocks/vet | dist/strings/matches.js | matches | function matches(regex) {
return function(val) {
regex.lastIndex = 0;
return isString(val) && regex.test(val);
};
} | javascript | function matches(regex) {
return function(val) {
regex.lastIndex = 0;
return isString(val) && regex.test(val);
};
} | [
"function",
"matches",
"(",
"regex",
")",
"{",
"return",
"function",
"(",
"val",
")",
"{",
"regex",
".",
"lastIndex",
"=",
"0",
";",
"return",
"isString",
"(",
"val",
")",
"&&",
"regex",
".",
"test",
"(",
"val",
")",
";",
"}",
";",
"}"
] | Builds a function that checks to see if a value matches a regular expression
@param regex - the regular expression to check against
@returns a function that takes in a value val, and returns true if it is a string that matches regex
@memberof vet.strings | [
"Builds",
"a",
"function",
"that",
"checks",
"to",
"see",
"if",
"a",
"value",
"matches",
"a",
"regular",
"expression"
] | 4557abeb6a8b470cb4a5823a2cc802c825ef29ef | https://github.com/somesocks/vet/blob/4557abeb6a8b470cb4a5823a2cc802c825ef29ef/dist/strings/matches.js#L10-L15 | train |
cheminfo-js/netcdf-gcms | src/index.js | netcdfGcms | function netcdfGcms(data, options = {}) {
let reader = new NetCDFReader(data);
const globalAttributes = reader.globalAttributes;
let instrument_mfr = reader.getDataVariableAsString('instrument_mfr');
let dataset_origin = reader.attributeExists('dataset_origin');
let mass_values = reader.dataVariableExists('m... | javascript | function netcdfGcms(data, options = {}) {
let reader = new NetCDFReader(data);
const globalAttributes = reader.globalAttributes;
let instrument_mfr = reader.getDataVariableAsString('instrument_mfr');
let dataset_origin = reader.attributeExists('dataset_origin');
let mass_values = reader.dataVariableExists('m... | [
"function",
"netcdfGcms",
"(",
"data",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"reader",
"=",
"new",
"NetCDFReader",
"(",
"data",
")",
";",
"const",
"globalAttributes",
"=",
"reader",
".",
"globalAttributes",
";",
"let",
"instrument_mfr",
"=",
"rea... | Reads a NetCDF file and returns a formatted JSON with the data from it
@param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data
@param {object} [options={}]
@param {boolean} [options.meta] - add meta information
@param {boolean} [options.variables] -add variables info... | [
"Reads",
"a",
"NetCDF",
"file",
"and",
"returns",
"a",
"formatted",
"JSON",
"with",
"the",
"data",
"from",
"it"
] | f2d2207d1af02528b5fb4c392122a8461cb5d7f1 | https://github.com/cheminfo-js/netcdf-gcms/blob/f2d2207d1af02528b5fb4c392122a8461cb5d7f1/src/index.js#L20-L67 | train |
yodaiken/dolphinsr | dist/bundle.js | getCardId | function getCardId(o) {
return o.master + '#' + o.combination.front.join(',') + '@' + o.combination.back.join(',');
} | javascript | function getCardId(o) {
return o.master + '#' + o.combination.front.join(',') + '@' + o.combination.back.join(',');
} | [
"function",
"getCardId",
"(",
"o",
")",
"{",
"return",
"o",
".",
"master",
"+",
"'#'",
"+",
"o",
".",
"combination",
".",
"front",
".",
"join",
"(",
"','",
")",
"+",
"'@'",
"+",
"o",
".",
"combination",
".",
"back",
".",
"join",
"(",
"','",
")",
... | numbers are indexes on master.fields | [
"numbers",
"are",
"indexes",
"on",
"master",
".",
"fields"
] | 5a833fdb1d9d6b87ed48a9599ebb1ee17cc67ca8 | https://github.com/yodaiken/dolphinsr/blob/5a833fdb1d9d6b87ed48a9599ebb1ee17cc67ca8/dist/bundle.js#L19-L21 | train |
yodaiken/dolphinsr | dist/bundle.js | addReview | function addReview(reviews, review) {
if (!reviews.length) {
return [review];
}
var i = reviews.length - 1;
for (; i >= 0; i -= 1) {
if (reviews[i].ts <= review.ts) {
break;
}
}
var newReviews = reviews.slice(0);
newReviews.splice(i + 1, 0, review);
return newReviews;
} | javascript | function addReview(reviews, review) {
if (!reviews.length) {
return [review];
}
var i = reviews.length - 1;
for (; i >= 0; i -= 1) {
if (reviews[i].ts <= review.ts) {
break;
}
}
var newReviews = reviews.slice(0);
newReviews.splice(i + 1, 0, review);
return newReviews;
} | [
"function",
"addReview",
"(",
"reviews",
",",
"review",
")",
"{",
"if",
"(",
"!",
"reviews",
".",
"length",
")",
"{",
"return",
"[",
"review",
"]",
";",
"}",
"var",
"i",
"=",
"reviews",
".",
"length",
"-",
"1",
";",
"for",
"(",
";",
"i",
">=",
... | This function only works if reviews is always sorted by timestamp | [
"This",
"function",
"only",
"works",
"if",
"reviews",
"is",
"always",
"sorted",
"by",
"timestamp"
] | 5a833fdb1d9d6b87ed48a9599ebb1ee17cc67ca8 | https://github.com/yodaiken/dolphinsr/blob/5a833fdb1d9d6b87ed48a9599ebb1ee17cc67ca8/dist/bundle.js#L43-L59 | train |
appcelerator/appc-logger | lib/logger.js | searchForArrowCloudLogDir | function searchForArrowCloudLogDir() {
if (isWritable('/ctlog')) {
return '/ctlog';
}
if (process.env.HOME && isWritable(path.join(process.env.HOME, 'ctlog'))) {
return path.join(process.env.HOME, 'ctlog');
}
if (process.env.USERPROFILE && isWritable(path.join(process.env.USERPROFILE, 'ctlog'))) {
return pat... | javascript | function searchForArrowCloudLogDir() {
if (isWritable('/ctlog')) {
return '/ctlog';
}
if (process.env.HOME && isWritable(path.join(process.env.HOME, 'ctlog'))) {
return path.join(process.env.HOME, 'ctlog');
}
if (process.env.USERPROFILE && isWritable(path.join(process.env.USERPROFILE, 'ctlog'))) {
return pat... | [
"function",
"searchForArrowCloudLogDir",
"(",
")",
"{",
"if",
"(",
"isWritable",
"(",
"'/ctlog'",
")",
")",
"{",
"return",
"'/ctlog'",
";",
"}",
"if",
"(",
"process",
".",
"env",
".",
"HOME",
"&&",
"isWritable",
"(",
"path",
".",
"join",
"(",
"process",
... | istanbul ignore next
Looks through the filesystem for a writable spot to which we can write the logs.
@returns {string} | [
"istanbul",
"ignore",
"next",
"Looks",
"through",
"the",
"filesystem",
"for",
"a",
"writable",
"spot",
"to",
"which",
"we",
"can",
"write",
"the",
"logs",
"."
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/logger.js#L17-L31 | train |
appcelerator/appc-logger | lib/logger.js | isWritable | function isWritable(dir) {
debug('checking if ' + dir + ' is writable');
try {
if (!fs.existsSync(dir)) {
debug(' - it does not exist yet, attempting to create it');
fs.mkdirSync(dir);
}
if (fs.accessSync) {
fs.accessSync(dir, fs.W_OK);
} else {
debug(' - fs.accessSync is not available, falling ba... | javascript | function isWritable(dir) {
debug('checking if ' + dir + ' is writable');
try {
if (!fs.existsSync(dir)) {
debug(' - it does not exist yet, attempting to create it');
fs.mkdirSync(dir);
}
if (fs.accessSync) {
fs.accessSync(dir, fs.W_OK);
} else {
debug(' - fs.accessSync is not available, falling ba... | [
"function",
"isWritable",
"(",
"dir",
")",
"{",
"debug",
"(",
"'checking if '",
"+",
"dir",
"+",
"' is writable'",
")",
";",
"try",
"{",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"dir",
")",
")",
"{",
"debug",
"(",
"' - it does not exist yet, attemptin... | istanbul ignore next
Checks if a directory is writable, returning a boolean or throwing an exception, depending on the arguments.
@param {string} dir The directory to check.
@returns {boolean} Whether or not the directory is writable. | [
"istanbul",
"ignore",
"next",
"Checks",
"if",
"a",
"directory",
"is",
"writable",
"returning",
"a",
"boolean",
"or",
"throwing",
"an",
"exception",
"depending",
"on",
"the",
"arguments",
"."
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/logger.js#L39-L60 | train |
appcelerator/appc-logger | lib/logger.js | getPort | function getPort(req) {
if (req.connection && req.connection.localPort) {
return req.connection.localPort.toString();
}
const host = req.headers && req.headers.host;
let protocolSrc = 80;
if (host && ((host.match(/:/g) || []).length) === 1) {
const possiblePort = host.split(':')[1];
protocolSrc = isN... | javascript | function getPort(req) {
if (req.connection && req.connection.localPort) {
return req.connection.localPort.toString();
}
const host = req.headers && req.headers.host;
let protocolSrc = 80;
if (host && ((host.match(/:/g) || []).length) === 1) {
const possiblePort = host.split(':')[1];
protocolSrc = isN... | [
"function",
"getPort",
"(",
"req",
")",
"{",
"if",
"(",
"req",
".",
"connection",
"&&",
"req",
".",
"connection",
".",
"localPort",
")",
"{",
"return",
"req",
".",
"connection",
".",
"localPort",
".",
"toString",
"(",
")",
";",
"}",
"const",
"host",
... | derive the port if its in the host string.
@param {Object} req a express req object
@return {string} string representation of port | [
"derive",
"the",
"port",
"if",
"its",
"in",
"the",
"host",
"string",
"."
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/logger.js#L217-L228 | train |
appcelerator/appc-logger | lib/logger.js | getStatus | function getStatus (res) {
let status;
const statusCode = res.statusCode;
if (statusCode) {
status = Math.floor(statusCode / 100) * 100;
}
switch (status) {
case 100:
case 200:
case 300:
return 'success';
default:
return 'failure';
}
} | javascript | function getStatus (res) {
let status;
const statusCode = res.statusCode;
if (statusCode) {
status = Math.floor(statusCode / 100) * 100;
}
switch (status) {
case 100:
case 200:
case 300:
return 'success';
default:
return 'failure';
}
} | [
"function",
"getStatus",
"(",
"res",
")",
"{",
"let",
"status",
";",
"const",
"statusCode",
"=",
"res",
".",
"statusCode",
";",
"if",
"(",
"statusCode",
")",
"{",
"status",
"=",
"Math",
".",
"floor",
"(",
"statusCode",
"/",
"100",
")",
"*",
"100",
";... | derive the status string from the status code
@param {Object} res express res object
@return {string} success or error string | [
"derive",
"the",
"status",
"string",
"from",
"the",
"status",
"code"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/logger.js#L234-L248 | train |
appcelerator/appc-logger | lib/logger.js | isWhitelisted | function isWhitelisted(url) {
return options.adiPathFilter.some(function (route) {
return url.substr(0, route.length) === route;
});
} | javascript | function isWhitelisted(url) {
return options.adiPathFilter.some(function (route) {
return url.substr(0, route.length) === route;
});
} | [
"function",
"isWhitelisted",
"(",
"url",
")",
"{",
"return",
"options",
".",
"adiPathFilter",
".",
"some",
"(",
"function",
"(",
"route",
")",
"{",
"return",
"url",
".",
"substr",
"(",
"0",
",",
"route",
".",
"length",
")",
"===",
"route",
";",
"}",
... | Determine whether a certain URL is whitelisted based off the prefix
@param {string} url URL to check
@return {boolean} Is the URL in the whitelist | [
"Determine",
"whether",
"a",
"certain",
"URL",
"is",
"whitelisted",
"based",
"off",
"the",
"prefix"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/logger.js#L263-L267 | train |
appcelerator/appc-logger | lib/logger.js | createDefaultLogger | function createDefaultLogger(options) {
const ConsoleLogger = require('./console'),
consoleLogger = new ConsoleLogger(options),
config = _.mergeWith({
name: 'logger',
streams: [
{
level: options && options.level || 'trace',
type: 'raw',
stream: consoleLogger
}
]
}, options, functi... | javascript | function createDefaultLogger(options) {
const ConsoleLogger = require('./console'),
consoleLogger = new ConsoleLogger(options),
config = _.mergeWith({
name: 'logger',
streams: [
{
level: options && options.level || 'trace',
type: 'raw',
stream: consoleLogger
}
]
}, options, functi... | [
"function",
"createDefaultLogger",
"(",
"options",
")",
"{",
"const",
"ConsoleLogger",
"=",
"require",
"(",
"'./console'",
")",
",",
"consoleLogger",
"=",
"new",
"ConsoleLogger",
"(",
"options",
")",
",",
"config",
"=",
"_",
".",
"mergeWith",
"(",
"{",
"name... | Create a default logger
@param {Object} options - options
@returns {Object} | [
"Create",
"a",
"default",
"logger"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/logger.js#L447-L491 | train |
Metatavu/kunta-api-spec | javascript-generated/src/api/CodesApi.js | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds a code
* Finds a code
* @param {String} codeId Id of the code
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Code}
*/
this.findCode = funct... | javascript | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds a code
* Finds a code
* @param {String} codeId Id of the code
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Code}
*/
this.findCode = funct... | [
"function",
"(",
"apiClient",
")",
"{",
"this",
".",
"apiClient",
"=",
"apiClient",
"||",
"ApiClient",
".",
"instance",
";",
"/**\n * Finds a code\n * Finds a code\n * @param {String} codeId Id of the code\n * @return {Promise} a {@link https://www.promisejs.org/|Promis... | Codes service.
@module api/CodesApi
@version 0.0.139
Constructs a new CodesApi.
@alias module:api/CodesApi
@class
@param {module:ApiClient} apiClient Optional API client implementation to use,
default to {@link module:ApiClient#instance} if unspecified. | [
"Codes",
"service",
"."
] | 4daa78ccd8c50736c2af2cc625b6237539f3b43a | https://github.com/Metatavu/kunta-api-spec/blob/4daa78ccd8c50736c2af2cc625b6237539f3b43a/javascript-generated/src/api/CodesApi.js#L55-L141 | train | |
appcelerator/appc-logger | lib/console.js | ConsoleLogger | function ConsoleLogger(options) {
EventEmitter.call(this);
this.options = options || {};
// allow use to customize if they want the label or not
this.prefix = this.options.prefix === undefined ? true : this.options.prefix;
this.showcr = this.options.showcr === undefined ? true : this.options.showcr;
this.showtab ... | javascript | function ConsoleLogger(options) {
EventEmitter.call(this);
this.options = options || {};
// allow use to customize if they want the label or not
this.prefix = this.options.prefix === undefined ? true : this.options.prefix;
this.showcr = this.options.showcr === undefined ? true : this.options.showcr;
this.showtab ... | [
"function",
"ConsoleLogger",
"(",
"options",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// allow use to customize if they want the label or not",
"this",
".",
"prefix",
"=",
"this",... | Console logging functionality
@param {Object} options - options | [
"Console",
"logging",
"functionality"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/console.js#L25-L46 | train |
mWater/mwater-forms | lib/ResponseAnswersComponent.js | isLoadNeeded | function isLoadNeeded(newProps, oldProps) {
return !_.isEqual(newProps.formDesign, oldProps.formDesign) || !_.isEqual(newProps.data, oldProps.data);
} | javascript | function isLoadNeeded(newProps, oldProps) {
return !_.isEqual(newProps.formDesign, oldProps.formDesign) || !_.isEqual(newProps.data, oldProps.data);
} | [
"function",
"isLoadNeeded",
"(",
"newProps",
",",
"oldProps",
")",
"{",
"return",
"!",
"_",
".",
"isEqual",
"(",
"newProps",
".",
"formDesign",
",",
"oldProps",
".",
"formDesign",
")",
"||",
"!",
"_",
".",
"isEqual",
"(",
"newProps",
".",
"data",
",",
... | Check if form design or data are different | [
"Check",
"if",
"form",
"design",
"or",
"data",
"are",
"different"
] | 8c707c285ae0e6fa9aaa065471fa8a0e9e43d40c | https://github.com/mWater/mwater-forms/blob/8c707c285ae0e6fa9aaa065471fa8a0e9e43d40c/lib/ResponseAnswersComponent.js#L47-L49 | train |
Metatavu/kunta-api-spec | javascript-generated/src/api/OrganizationsApi.js | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Find organization
* Find organization
* @param {String} organizationId organization id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Organization}
*... | javascript | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Find organization
* Find organization
* @param {String} organizationId organization id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/Organization}
*... | [
"function",
"(",
"apiClient",
")",
"{",
"this",
".",
"apiClient",
"=",
"apiClient",
"||",
"ApiClient",
".",
"instance",
";",
"/**\n * Find organization\n * Find organization\n * @param {String} organizationId organization id\n * @return {Promise} a {@link https://www.pr... | Organizations service.
@module api/OrganizationsApi
@version 0.0.139
Constructs a new OrganizationsApi.
@alias module:api/OrganizationsApi
@class
@param {module:ApiClient} apiClient Optional API client implementation to use,
default to {@link module:ApiClient#instance} if unspecified. | [
"Organizations",
"service",
"."
] | 4daa78ccd8c50736c2af2cc625b6237539f3b43a | https://github.com/Metatavu/kunta-api-spec/blob/4daa78ccd8c50736c2af2cc625b6237539f3b43a/javascript-generated/src/api/OrganizationsApi.js#L55-L143 | train | |
appcelerator/appc-logger | lib/index.js | createLogger | function createLogger(fn) {
return function () {
var args = [],
self = this,
c;
for (c = 0; c < arguments.length; c++) {
args[c] = logger.specialObjectClone(arguments[c]);
}
return fn.apply(self, args);
};
} | javascript | function createLogger(fn) {
return function () {
var args = [],
self = this,
c;
for (c = 0; c < arguments.length; c++) {
args[c] = logger.specialObjectClone(arguments[c]);
}
return fn.apply(self, args);
};
} | [
"function",
"createLogger",
"(",
"fn",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"[",
"]",
",",
"self",
"=",
"this",
",",
"c",
";",
"for",
"(",
"c",
"=",
"0",
";",
"c",
"<",
"arguments",
".",
"length",
";",
"c",
"++",
... | create a log adapter that will handle masking
@param {Function} fn [description]
@return {Function} [description] | [
"create",
"a",
"log",
"adapter",
"that",
"will",
"handle",
"masking"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/index.js#L20-L30 | train |
Metatavu/kunta-api-spec | javascript-generated/src/api/FragmentsApi.js | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds organizations page fragment
* Finds single organization page fragment
* @param {String} organizationId Organization id
* @param {String} fragmentId fragment id
* @return {Promise} a {@link https://ww... | javascript | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds organizations page fragment
* Finds single organization page fragment
* @param {String} organizationId Organization id
* @param {String} fragmentId fragment id
* @return {Promise} a {@link https://ww... | [
"function",
"(",
"apiClient",
")",
"{",
"this",
".",
"apiClient",
"=",
"apiClient",
"||",
"ApiClient",
".",
"instance",
";",
"/**\n * Finds organizations page fragment\n * Finds single organization page fragment \n * @param {String} organizationId Organization id\n * @p... | Fragments service.
@module api/FragmentsApi
@version 0.0.139
Constructs a new FragmentsApi.
@alias module:api/FragmentsApi
@class
@param {module:ApiClient} apiClient Optional API client implementation to use,
default to {@link module:ApiClient#instance} if unspecified. | [
"Fragments",
"service",
"."
] | 4daa78ccd8c50736c2af2cc625b6237539f3b43a | https://github.com/Metatavu/kunta-api-spec/blob/4daa78ccd8c50736c2af2cc625b6237539f3b43a/javascript-generated/src/api/FragmentsApi.js#L55-L145 | train | |
canjs/can-compute | proto-compute.js | function() {
canReflect.onValue( observation, updater,"notify");
if (observation.hasOwnProperty("_value")) {// can-observation 4.1+
compute.value = observation._value;
} else {// can-observation < 4.1
compute.value = observation.value;
}
} | javascript | function() {
canReflect.onValue( observation, updater,"notify");
if (observation.hasOwnProperty("_value")) {// can-observation 4.1+
compute.value = observation._value;
} else {// can-observation < 4.1
compute.value = observation.value;
}
} | [
"function",
"(",
")",
"{",
"canReflect",
".",
"onValue",
"(",
"observation",
",",
"updater",
",",
"\"notify\"",
")",
";",
"if",
"(",
"observation",
".",
"hasOwnProperty",
"(",
"\"_value\"",
")",
")",
"{",
"// can-observation 4.1+",
"compute",
".",
"value",
"... | Call `onchanged` when any source observables change. | [
"Call",
"onchanged",
"when",
"any",
"source",
"observables",
"change",
"."
] | ac271cf6a68ec936e2f7992df2bb9bc1f5a7cf36 | https://github.com/canjs/can-compute/blob/ac271cf6a68ec936e2f7992df2bb9bc1f5a7cf36/proto-compute.js#L147-L154 | train | |
Metatavu/kunta-api-spec | javascript-generated/src/api/PhoneServiceChannelsApi.js | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds a phone service channel by id
* Finds a phone service channel by id
* @param {String} phoneServiceChannelId Phone service channel id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with d... | javascript | function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
/**
* Finds a phone service channel by id
* Finds a phone service channel by id
* @param {String} phoneServiceChannelId Phone service channel id
* @return {Promise} a {@link https://www.promisejs.org/|Promise}, with d... | [
"function",
"(",
"apiClient",
")",
"{",
"this",
".",
"apiClient",
"=",
"apiClient",
"||",
"ApiClient",
".",
"instance",
";",
"/**\n * Finds a phone service channel by id\n * Finds a phone service channel by id\n * @param {String} phoneServiceChannelId Phone service channel ... | PhoneServiceChannels service.
@module api/PhoneServiceChannelsApi
@version 0.0.139
Constructs a new PhoneServiceChannelsApi.
@alias module:api/PhoneServiceChannelsApi
@class
@param {module:ApiClient} apiClient Optional API client implementation to use,
default to {@link module:ApiClient#instance} if unspecified. | [
"PhoneServiceChannels",
"service",
"."
] | 4daa78ccd8c50736c2af2cc625b6237539f3b43a | https://github.com/Metatavu/kunta-api-spec/blob/4daa78ccd8c50736c2af2cc625b6237539f3b43a/javascript-generated/src/api/PhoneServiceChannelsApi.js#L55-L185 | train | |
appcelerator/appc-logger | lib/problem.js | ProblemLogger | function ProblemLogger(options) {
options = options || {};
ConsoleLogger.call(this);
const tmpdir = require('os').tmpdir();
this.filename = path.join(tmpdir, 'logger-' + (+new Date()) + '.log');
this.name = options.problemLogName || ((options.name || 'problem') + '.log');
this.stream = fs.createWriteStream(this.f... | javascript | function ProblemLogger(options) {
options = options || {};
ConsoleLogger.call(this);
const tmpdir = require('os').tmpdir();
this.filename = path.join(tmpdir, 'logger-' + (+new Date()) + '.log');
this.name = options.problemLogName || ((options.name || 'problem') + '.log');
this.stream = fs.createWriteStream(this.f... | [
"function",
"ProblemLogger",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"ConsoleLogger",
".",
"call",
"(",
"this",
")",
";",
"const",
"tmpdir",
"=",
"require",
"(",
"'os'",
")",
".",
"tmpdir",
"(",
")",
";",
"this",
"."... | Logger stream that will only write out a log file
if the process exits non-zero in the current directory
@param {Object} options - options
@constructor | [
"Logger",
"stream",
"that",
"will",
"only",
"write",
"out",
"a",
"log",
"file",
"if",
"the",
"process",
"exits",
"non",
"-",
"zero",
"in",
"the",
"current",
"directory"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/problem.js#L19-L28 | train |
appcelerator/appc-logger | lib/problem.js | closeStreams | function closeStreams(exitCode) {
// default is 0 if not specified
exitCode = exitCode === undefined ? 0 : exitCode;
if (streams.length) {
streams.forEach(function (logger) {
logger.write({ level: bunyan.TRACE, msg: util.format('exited with code %d', exitCode) });
logger.stream.end();
// jscs:disable jsD... | javascript | function closeStreams(exitCode) {
// default is 0 if not specified
exitCode = exitCode === undefined ? 0 : exitCode;
if (streams.length) {
streams.forEach(function (logger) {
logger.write({ level: bunyan.TRACE, msg: util.format('exited with code %d', exitCode) });
logger.stream.end();
// jscs:disable jsD... | [
"function",
"closeStreams",
"(",
"exitCode",
")",
"{",
"// default is 0 if not specified",
"exitCode",
"=",
"exitCode",
"===",
"undefined",
"?",
"0",
":",
"exitCode",
";",
"if",
"(",
"streams",
".",
"length",
")",
"{",
"streams",
".",
"forEach",
"(",
"function... | Close the stream
@param {number} exitCode - numeric entry code | [
"Close",
"the",
"stream"
] | 7ded47e93f7c59de4dbd83e61cff5be890ae17fa | https://github.com/appcelerator/appc-logger/blob/7ded47e93f7c59de4dbd83e61cff5be890ae17fa/lib/problem.js#L59-L71 | train |
noodlefrenzy/node-amqp10 | lib/session.js | function(l) {
debug('Attaching link ' + l.name + ':' + l.handle + ' after begin received');
if (l.state() !== 'attached' && l.state() !== 'attaching') l.attach();
} | javascript | function(l) {
debug('Attaching link ' + l.name + ':' + l.handle + ' after begin received');
if (l.state() !== 'attached' && l.state() !== 'attaching') l.attach();
} | [
"function",
"(",
"l",
")",
"{",
"debug",
"(",
"'Attaching link '",
"+",
"l",
".",
"name",
"+",
"':'",
"+",
"l",
".",
"handle",
"+",
"' after begin received'",
")",
";",
"if",
"(",
"l",
".",
"state",
"(",
")",
"!==",
"'attached'",
"&&",
"l",
".",
"s... | attach all links | [
"attach",
"all",
"links"
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/session.js#L441-L444 | train | |
noodlefrenzy/node-amqp10 | lib/frames.js | role | function role(value) {
if (typeof value === 'boolean')
return value;
if (value !== 'sender' && value !== 'receiver')
throw new errors.EncodingError(value, 'invalid role');
return (value === 'sender') ? false : true;
} | javascript | function role(value) {
if (typeof value === 'boolean')
return value;
if (value !== 'sender' && value !== 'receiver')
throw new errors.EncodingError(value, 'invalid role');
return (value === 'sender') ? false : true;
} | [
"function",
"role",
"(",
"value",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"'boolean'",
")",
"return",
"value",
";",
"if",
"(",
"value",
"!==",
"'sender'",
"&&",
"value",
"!==",
"'receiver'",
")",
"throw",
"new",
"errors",
".",
"EncodingError",
"("... | restricted type helpers | [
"restricted",
"type",
"helpers"
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/frames.js#L154-L161 | train |
noodlefrenzy/node-amqp10 | lib/types.js | listBuilder | function listBuilder(list, bufb, codec, width) {
if (!Array.isArray(list)) {
throw new errors.EncodingError(list, 'Unsure how to encode non-array as list');
}
if (!width && list.length === 0) {
bufb.appendUInt8(0x45);
return;
}
// Encode all elements into a temp buffer to allow us to front-load ... | javascript | function listBuilder(list, bufb, codec, width) {
if (!Array.isArray(list)) {
throw new errors.EncodingError(list, 'Unsure how to encode non-array as list');
}
if (!width && list.length === 0) {
bufb.appendUInt8(0x45);
return;
}
// Encode all elements into a temp buffer to allow us to front-load ... | [
"function",
"listBuilder",
"(",
"list",
",",
"bufb",
",",
"codec",
",",
"width",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"list",
")",
")",
"{",
"throw",
"new",
"errors",
".",
"EncodingError",
"(",
"list",
",",
"'Unsure how to encode non-a... | Decoder methods decode an incoming buffer into an appropriate concrete JS entity.
@function decoder
@param {Buffer} buf Buffer to decode, stripped of prefix code (e.g. 0xA1 0x03 'foo' would
have the 0xA1 stripped)
@param {Codec} [codec] If needed, the codec to decode sub-values for composite types.
@ret... | [
"Decoder",
"methods",
"decode",
"an",
"incoming",
"buffer",
"into",
"an",
"appropriate",
"concrete",
"JS",
"entity",
"."
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/types.js#L99-L129 | train |
noodlefrenzy/node-amqp10 | lib/types.js | mapBuilder | function mapBuilder(map, bufb, codec, width) {
if (typeof map !== 'object') {
throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
}
if (Array.isArray(map)) {
throw new errors.EncodingError(map, 'Unsure how to encode array as map');
}
var keys = Object.keys(map);
if (!wid... | javascript | function mapBuilder(map, bufb, codec, width) {
if (typeof map !== 'object') {
throw new errors.EncodingError(map, 'Unsure how to encode non-object as map');
}
if (Array.isArray(map)) {
throw new errors.EncodingError(map, 'Unsure how to encode array as map');
}
var keys = Object.keys(map);
if (!wid... | [
"function",
"mapBuilder",
"(",
"map",
",",
"bufb",
",",
"codec",
",",
"width",
")",
"{",
"if",
"(",
"typeof",
"map",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"errors",
".",
"EncodingError",
"(",
"map",
",",
"'Unsure how to encode non-object as map'",
")"... | A map is encoded as a compound value where the constituent elements form alternating key value pairs.
<pre>
item 0 item 1 item n-1 item n
+-------+-------+----+---------+---------+
| key 1 | val 1 | .. | key n/2 | val n/2 |
+-------+-------+----+---------+---------+
</pre>
Map encodings must contain an even... | [
"A",
"map",
"is",
"encoded",
"as",
"a",
"compound",
"value",
"where",
"the",
"constituent",
"elements",
"form",
"alternating",
"key",
"value",
"pairs",
"."
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/types.js#L270-L310 | train |
noodlefrenzy/node-amqp10 | lib/utilities.js | assertArguments | function assertArguments(options, argnames) {
if (!argnames) return;
if (!options) throw new TypeError('missing arguments: ' + argnames);
argnames.forEach(function (argname) {
if (!options.hasOwnProperty(argname)) {
throw new TypeError('missing argument: ' + argname);
}
});
} | javascript | function assertArguments(options, argnames) {
if (!argnames) return;
if (!options) throw new TypeError('missing arguments: ' + argnames);
argnames.forEach(function (argname) {
if (!options.hasOwnProperty(argname)) {
throw new TypeError('missing argument: ' + argname);
}
});
} | [
"function",
"assertArguments",
"(",
"options",
",",
"argnames",
")",
"{",
"if",
"(",
"!",
"argnames",
")",
"return",
";",
"if",
"(",
"!",
"options",
")",
"throw",
"new",
"TypeError",
"(",
"'missing arguments: '",
"+",
"argnames",
")",
";",
"argnames",
".",... | Convenience method to assert that a given options object contains the required arguments.
@param options
@param argnames | [
"Convenience",
"method",
"to",
"assert",
"that",
"a",
"given",
"options",
"object",
"contains",
"the",
"required",
"arguments",
"."
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/utilities.js#L87-L95 | train |
noodlefrenzy/node-amqp10 | lib/sasl/sasl.js | Sasl | function Sasl(mechanism, handler) {
if (!mechanism || !handler) {
throw new errors.NotImplementedError('Need both the mechanism and the handler');
}
this.mechanism = mechanism;
this.handler = handler;
this.receivedHeader = false;
} | javascript | function Sasl(mechanism, handler) {
if (!mechanism || !handler) {
throw new errors.NotImplementedError('Need both the mechanism and the handler');
}
this.mechanism = mechanism;
this.handler = handler;
this.receivedHeader = false;
} | [
"function",
"Sasl",
"(",
"mechanism",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"mechanism",
"||",
"!",
"handler",
")",
"{",
"throw",
"new",
"errors",
".",
"NotImplementedError",
"(",
"'Need both the mechanism and the handler'",
")",
";",
"}",
"this",
".",
"... | Currently, only supports SASL ANONYMOUS or PLAIN
@constructor | [
"Currently",
"only",
"supports",
"SASL",
"ANONYMOUS",
"or",
"PLAIN"
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/sasl/sasl.js#L21-L28 | train |
noodlefrenzy/node-amqp10 | lib/policies/policy.js | Policy | function Policy(overrides) {
if (!(this instanceof Policy))
return new Policy(overrides);
u.defaults(this, overrides, {
/**
* support subjects in link names with the following characteristics:
* receiver: "amq.topic/news", means a filter on the ReceiverLink will be made
* for messa... | javascript | function Policy(overrides) {
if (!(this instanceof Policy))
return new Policy(overrides);
u.defaults(this, overrides, {
/**
* support subjects in link names with the following characteristics:
* receiver: "amq.topic/news", means a filter on the ReceiverLink will be made
* for messa... | [
"function",
"Policy",
"(",
"overrides",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Policy",
")",
")",
"return",
"new",
"Policy",
"(",
"overrides",
")",
";",
"u",
".",
"defaults",
"(",
"this",
",",
"overrides",
",",
"{",
"/**\n * support su... | The default policy for amqp10 clients
@class
@param {object} overrides override values for the default policy | [
"The",
"default",
"policy",
"for",
"amqp10",
"clients"
] | f5c2aa570830a8dd454e89ed3f4222fc7953fcf7 | https://github.com/noodlefrenzy/node-amqp10/blob/f5c2aa570830a8dd454e89ed3f4222fc7953fcf7/lib/policies/policy.js#L25-L187 | train |
imonology/scalra | modules/reporting.js | function (onDone) {
// store what to do after connected
// NOTE: may be called repeatedly (if initial attempts fail or disconnect happens)
if (typeof onDone === 'function')
l_onConnect = onDone;
if (l_ip_port === undefined) {
LOG.warn('not init (or already disposed), cannot connect to server');
return;
}
... | javascript | function (onDone) {
// store what to do after connected
// NOTE: may be called repeatedly (if initial attempts fail or disconnect happens)
if (typeof onDone === 'function')
l_onConnect = onDone;
if (l_ip_port === undefined) {
LOG.warn('not init (or already disposed), cannot connect to server');
return;
}
... | [
"function",
"(",
"onDone",
")",
"{",
"// store what to do after connected",
"// NOTE: may be called repeatedly (if initial attempts fail or disconnect happens)",
"if",
"(",
"typeof",
"onDone",
"===",
"'function'",
")",
"l_onConnect",
"=",
"onDone",
";",
"if",
"(",
"l_ip_port"... | connect to remote server | [
"connect",
"to",
"remote",
"server"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/modules/reporting.js#L278-L309 | train | |
imonology/scalra | handlers/system.js | function (latest_log) {
if (latest_log !== null && latest_log.type !== "SYSTEM_DOWN") {
LOG.warn("server crashed last time", 'handlers.system');
LOG.event("SYSTEM_CRASHED", SR.Settings.SERVER_INFO);
}
LOG.event("SYSTEM_UP", SR.Settings.SERVER_INFO);
} | javascript | function (latest_log) {
if (latest_log !== null && latest_log.type !== "SYSTEM_DOWN") {
LOG.warn("server crashed last time", 'handlers.system');
LOG.event("SYSTEM_CRASHED", SR.Settings.SERVER_INFO);
}
LOG.event("SYSTEM_UP", SR.Settings.SERVER_INFO);
} | [
"function",
"(",
"latest_log",
")",
"{",
"if",
"(",
"latest_log",
"!==",
"null",
"&&",
"latest_log",
".",
"type",
"!==",
"\"SYSTEM_DOWN\"",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"server crashed last time\"",
",",
"'handlers.system'",
")",
";",
"LOG",
".",
"ev... | perform event log | [
"perform",
"event",
"log"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/handlers/system.js#L248-L255 | train | |
imonology/scalra | extension/socketio.js | function () {
if (queue.length > 0) {
if (queue.length % 500 === 0)
LOG.warn('socketio queue: ' + queue.length);
var item = queue.shift();
socket.busy = true;
socket.emit('SRR', item);
}
} | javascript | function () {
if (queue.length > 0) {
if (queue.length % 500 === 0)
LOG.warn('socketio queue: ' + queue.length);
var item = queue.shift();
socket.busy = true;
socket.emit('SRR', item);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"queue",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"queue",
".",
"length",
"%",
"500",
"===",
"0",
")",
"LOG",
".",
"warn",
"(",
"'socketio queue: '",
"+",
"queue",
".",
"length",
")",
";",
"var",
"item",... | check if message queue has something to send | [
"check",
"if",
"message",
"queue",
"has",
"something",
"to",
"send"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/socketio.js#L132-L141 | train | |
imonology/scalra | core/log_manager.js | function () {
SR.fs.close(l_logs[log_id].fd,
function () {
console.log(l_name + '::l_closeLog::' + SR.Tags.YELLOW + 'LogID=' + log_id + ' closed.' + SR.Tags.ERREND);
delete l_logs[log_id];
onDone(log_id);
}
);
} | javascript | function () {
SR.fs.close(l_logs[log_id].fd,
function () {
console.log(l_name + '::l_closeLog::' + SR.Tags.YELLOW + 'LogID=' + log_id + ' closed.' + SR.Tags.ERREND);
delete l_logs[log_id];
onDone(log_id);
}
);
} | [
"function",
"(",
")",
"{",
"SR",
".",
"fs",
".",
"close",
"(",
"l_logs",
"[",
"log_id",
"]",
".",
"fd",
",",
"function",
"(",
")",
"{",
"console",
".",
"log",
"(",
"l_name",
"+",
"'::l_closeLog::'",
"+",
"SR",
".",
"Tags",
".",
"YELLOW",
"+",
"'L... | perform actual file close | [
"perform",
"actual",
"file",
"close"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/log_manager.js#L243-L252 | train | |
imonology/scalra | extension/location.js | function (appID, locationID) {
// check if location exists
if (l_locations.hasOwnProperty(locationID) === false) {
LOG.error('locationID: ' + locationID + ' does not exist', 'addApp');
return;
}
// check if already exists, ignore action if already exists
if (l_apps.hasOwnProperty(a... | javascript | function (appID, locationID) {
// check if location exists
if (l_locations.hasOwnProperty(locationID) === false) {
LOG.error('locationID: ' + locationID + ' does not exist', 'addApp');
return;
}
// check if already exists, ignore action if already exists
if (l_apps.hasOwnProperty(a... | [
"function",
"(",
"appID",
",",
"locationID",
")",
"{",
"// check if location exists",
"if",
"(",
"l_locations",
".",
"hasOwnProperty",
"(",
"locationID",
")",
"===",
"false",
")",
"{",
"LOG",
".",
"error",
"(",
"'locationID: '",
"+",
"locationID",
"+",
"' does... | add a new app | [
"add",
"a",
"new",
"app"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/location.js#L113-L136 | train | |
imonology/scalra | modules/express.js | function (upload) {
if (!upload || !upload.path || !upload.name || !upload.size) {
LOG.error('upload object incomplete:', l_name);
return;
}
// record basic file info
var arr = upload.path.split('/');
var upload_name = arr[arr.length-1];
var filename = (preserve_name ... | javascript | function (upload) {
if (!upload || !upload.path || !upload.name || !upload.size) {
LOG.error('upload object incomplete:', l_name);
return;
}
// record basic file info
var arr = upload.path.split('/');
var upload_name = arr[arr.length-1];
var filename = (preserve_name ... | [
"function",
"(",
"upload",
")",
"{",
"if",
"(",
"!",
"upload",
"||",
"!",
"upload",
".",
"path",
"||",
"!",
"upload",
".",
"name",
"||",
"!",
"upload",
".",
"size",
")",
"{",
"LOG",
".",
"error",
"(",
"'upload object incomplete:'",
",",
"l_name",
")"... | modify uploaded file to have original filename | [
"modify",
"uploaded",
"file",
"to",
"have",
"original",
"filename"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/modules/express.js#L181-L208 | train | |
imonology/scalra | core/execute.js | function (id) {
LOG.warn('server started: ' + server_type, l_name);
// check if we should notify start server request
for (var i=0; i < l_pendingStart.length; i++) {
var task = l_pendingStart[i];
if (task.server_type !== server_type) {
continue;
}
LOG.warn('pending type matched: ' +... | javascript | function (id) {
LOG.warn('server started: ' + server_type, l_name);
// check if we should notify start server request
for (var i=0; i < l_pendingStart.length; i++) {
var task = l_pendingStart[i];
if (task.server_type !== server_type) {
continue;
}
LOG.warn('pending type matched: ' +... | [
"function",
"(",
"id",
")",
"{",
"LOG",
".",
"warn",
"(",
"'server started: '",
"+",
"server_type",
",",
"l_name",
")",
";",
"// check if we should notify start server request",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l_pendingStart",
".",
"length",
... | notify if a server process has started | [
"notify",
"if",
"a",
"server",
"process",
"has",
"started"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/execute.js#L107-L157 | train | |
imonology/scalra | core/execute.js | function (exec_path, onExec) {
var onFound = function () {
// if file found, execute directly
// store starting path
args.exec_path = exec_path;
LOG.warn('starting ' + size + ' [' + server_type + '] servers', l_name);
// store an entry for the callback when all servers are started as reque... | javascript | function (exec_path, onExec) {
var onFound = function () {
// if file found, execute directly
// store starting path
args.exec_path = exec_path;
LOG.warn('starting ' + size + ' [' + server_type + '] servers', l_name);
// store an entry for the callback when all servers are started as reque... | [
"function",
"(",
"exec_path",
",",
"onExec",
")",
"{",
"var",
"onFound",
"=",
"function",
"(",
")",
"{",
"// if file found, execute directly",
"// store starting path",
"args",
".",
"exec_path",
"=",
"exec_path",
";",
"LOG",
".",
"warn",
"(",
"'starting '",
"+",... | try to execute on a given path | [
"try",
"to",
"execute",
"on",
"a",
"given",
"path"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/execute.js#L175-L220 | train | |
particle-iot/particle-commands | src/cmd/api.js | convertApiError | function convertApiError(err) {
if (err.error && err.error.response && err.error.response.text) {
const obj = JSON.parse(err.error.response.text);
if (obj.errors && obj.errors.length) {
err = { message: obj.errors[0].message, error:err.error };
}
}
return err;
} | javascript | function convertApiError(err) {
if (err.error && err.error.response && err.error.response.text) {
const obj = JSON.parse(err.error.response.text);
if (obj.errors && obj.errors.length) {
err = { message: obj.errors[0].message, error:err.error };
}
}
return err;
} | [
"function",
"convertApiError",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"error",
"&&",
"err",
".",
"error",
".",
"response",
"&&",
"err",
".",
"error",
".",
"response",
".",
"text",
")",
"{",
"const",
"obj",
"=",
"JSON",
".",
"parse",
"(",
"err... | Converts an error thrown by the API to a simpler object containing
a `message` property.
@param {object} err The error raised by the API.
@returns {object} With message and error properties. | [
"Converts",
"an",
"error",
"thrown",
"by",
"the",
"API",
"to",
"a",
"simpler",
"object",
"containing",
"a",
"message",
"property",
"."
] | 012252e0faef5f4ee21aa3b36c58eace7296a633 | https://github.com/particle-iot/particle-commands/blob/012252e0faef5f4ee21aa3b36c58eace7296a633/src/cmd/api.js#L9-L17 | train |
imonology/scalra | core/comm.js | function (area, layer) {
// check if layer exists
if (l_layers.hasOwnProperty(layer) === false)
return [];
// get all current subscriptions at this layer
var subs = l_layers[layer];
// prepare list of connection of subscribers matching / covering the area
var connections = [];
// check each subscriptio... | javascript | function (area, layer) {
// check if layer exists
if (l_layers.hasOwnProperty(layer) === false)
return [];
// get all current subscriptions at this layer
var subs = l_layers[layer];
// prepare list of connection of subscribers matching / covering the area
var connections = [];
// check each subscriptio... | [
"function",
"(",
"area",
",",
"layer",
")",
"{",
"// check if layer exists",
"if",
"(",
"l_layers",
".",
"hasOwnProperty",
"(",
"layer",
")",
"===",
"false",
")",
"return",
"[",
"]",
";",
"// get all current subscriptions at this layer",
"var",
"subs",
"=",
"l_l... | find a list of subscribers covering a given point or area | [
"find",
"a",
"list",
"of",
"subscribers",
"covering",
"a",
"given",
"point",
"or",
"area"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/comm.js#L261-L283 | train | |
imonology/scalra | core/event_manager.js | function (event) {
// if event is not from socket, no need to queue
// TODO: remove connection-specific code from here
if (event.conn.type !== 'socket')
return true;
var socket = event.conn.connector;
// if no mechanism to store (such as from a bot), just ignore
// TODO: this is not clean
if (typeof socket.... | javascript | function (event) {
// if event is not from socket, no need to queue
// TODO: remove connection-specific code from here
if (event.conn.type !== 'socket')
return true;
var socket = event.conn.connector;
// if no mechanism to store (such as from a bot), just ignore
// TODO: this is not clean
if (typeof socket.... | [
"function",
"(",
"event",
")",
"{",
"// if event is not from socket, no need to queue",
"// TODO: remove connection-specific code from here",
"if",
"(",
"event",
".",
"conn",
".",
"type",
"!==",
"'socket'",
")",
"return",
"true",
";",
"var",
"socket",
"=",
"event",
".... | function to store a event pending to send | [
"function",
"to",
"store",
"a",
"event",
"pending",
"to",
"send"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/event_manager.js#L93-L123 | train | |
imonology/scalra | core/event_manager.js | function (event) {
// check if connection object exists
if (typeof event.conn === 'undefined') {
LOG.error('no connection records, cannot respond to request', l_name);
return false;
}
// if no mechanism to store (such as from a bot), just ignore
// TODO: cleaner approach?
if (event.conn.type !== 'socket' ||... | javascript | function (event) {
// check if connection object exists
if (typeof event.conn === 'undefined') {
LOG.error('no connection records, cannot respond to request', l_name);
return false;
}
// if no mechanism to store (such as from a bot), just ignore
// TODO: cleaner approach?
if (event.conn.type !== 'socket' ||... | [
"function",
"(",
"event",
")",
"{",
"// check if connection object exists",
"if",
"(",
"typeof",
"event",
".",
"conn",
"===",
"'undefined'",
")",
"{",
"LOG",
".",
"error",
"(",
"'no connection records, cannot respond to request'",
",",
"l_name",
")",
";",
"return",
... | opposite of queueEvent | [
"opposite",
"of",
"queueEvent"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/event_manager.js#L126-L154 | train | |
imonology/scalra | core/REST/server.js | function (req, res) {
LOG.warn('handle_request');
// attach custom res methods (borrowed from express)
res = UTIL.mixin(res, response);
LOG.sys('HTTP req received, header', 'SR.REST');
LOG.sys(req.headers, 'SR.REST');
var content_type = req.headers['content-type'];
// NOTE: multi-part needs to be ha... | javascript | function (req, res) {
LOG.warn('handle_request');
// attach custom res methods (borrowed from express)
res = UTIL.mixin(res, response);
LOG.sys('HTTP req received, header', 'SR.REST');
LOG.sys(req.headers, 'SR.REST');
var content_type = req.headers['content-type'];
// NOTE: multi-part needs to be ha... | [
"function",
"(",
"req",
",",
"res",
")",
"{",
"LOG",
".",
"warn",
"(",
"'handle_request'",
")",
";",
"// attach custom res methods (borrowed from express)",
"res",
"=",
"UTIL",
".",
"mixin",
"(",
"res",
",",
"response",
")",
";",
"LOG",
".",
"sys",
"(",
"'... | main place to receive HTTP-related requests | [
"main",
"place",
"to",
"receive",
"HTTP",
"-",
"related",
"requests"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/REST/server.js#L34-L93 | train | |
imonology/scalra | extension/user.js | function (account, data, conn) {
//if (l_logins.hasOwnProperty(account) === true)
//return false;
// check if user's unique data exists
if (typeof data.data !== 'object') {
LOG.error('data field does not exist, cannot add login data');
return false;
}
LOG.warn('account: ' + account + ' data:', 'addLogin... | javascript | function (account, data, conn) {
//if (l_logins.hasOwnProperty(account) === true)
//return false;
// check if user's unique data exists
if (typeof data.data !== 'object') {
LOG.error('data field does not exist, cannot add login data');
return false;
}
LOG.warn('account: ' + account + ' data:', 'addLogin... | [
"function",
"(",
"account",
",",
"data",
",",
"conn",
")",
"{",
"//if (l_logins.hasOwnProperty(account) === true)",
"//return false;",
"// check if user's unique data exists",
"if",
"(",
"typeof",
"data",
".",
"data",
"!==",
"'object'",
")",
"{",
"LOG",
".",
"error",
... | store & remove user data to cache | [
"store",
"&",
"remove",
"user",
"data",
"to",
"cache"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/user.js#L88-L132 | train | |
imonology/scalra | extension/user.js | function (error) {
if (error) {
var err = new Error("set custom data for account [" + account + "] fail");
err.name = "setUser Error";
LOG.error('set custom data for account [' + account + '] fail', 'user');
UTIL.safeCall(onDone, err);
}
else {
LOG.warn('set custom data for account [' + account + ... | javascript | function (error) {
if (error) {
var err = new Error("set custom data for account [" + account + "] fail");
err.name = "setUser Error";
LOG.error('set custom data for account [' + account + '] fail', 'user');
UTIL.safeCall(onDone, err);
}
else {
LOG.warn('set custom data for account [' + account + ... | [
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"\"set custom data for account [\"",
"+",
"account",
"+",
"\"] fail\"",
")",
";",
"err",
".",
"name",
"=",
"\"setUser Error\"",
";",
"LOG",
".",
"er... | perform DB write-back | [
"perform",
"DB",
"write",
"-",
"back"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/user.js#L526-L538 | train | |
imonology/scalra | extension/user.js | function (uid, token) {
// TODO: check if local account already exists, or replace existing one
// multiple accounts storable for one local server
// NOTE: field name is a variable
// ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findandmodify
... | javascript | function (uid, token) {
// TODO: check if local account already exists, or replace existing one
// multiple accounts storable for one local server
// NOTE: field name is a variable
// ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findandmodify
... | [
"function",
"(",
"uid",
",",
"token",
")",
"{",
"// TODO: check if local account already exists, or replace existing one",
"// multiple accounts storable for one local server",
"// NOTE: field name is a variable",
"// ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-fi... | build callback to store local account if it's verified | [
"build",
"callback",
"to",
"store",
"local",
"account",
"if",
"it",
"s",
"verified"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/user.js#L691-L712 | train | |
imonology/scalra | extension/user.js | function (error) {
if (error) {
var err = new Error(error.toString());
err.name = "l_createToken Error";
UTIL.safeCall(onDone, err);
}
else {
LOG.warn('pass_token [' + token + '] stored');
UTIL.safeCall(onDone, null, token);
}
} | javascript | function (error) {
if (error) {
var err = new Error(error.toString());
err.name = "l_createToken Error";
UTIL.safeCall(onDone, err);
}
else {
LOG.warn('pass_token [' + token + '] stored');
UTIL.safeCall(onDone, null, token);
}
} | [
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
")",
"{",
"var",
"err",
"=",
"new",
"Error",
"(",
"error",
".",
"toString",
"(",
")",
")",
";",
"err",
".",
"name",
"=",
"\"l_createToken Error\"",
";",
"UTIL",
".",
"safeCall",
"(",
"onDone",
... | store token back to DB | [
"store",
"token",
"back",
"to",
"DB"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/user.js#L750-L760 | train | |
imonology/scalra | core/handler.js | function (msgtype, event) {
// we only forward for non-SR user-defined events at lobby
if (SR.Settings.SERVER_INFO.type !== 'lobby' || msgtype.startsWith('SR'))
return false;
// check if we're lobby and same-name app servers are available
var list = SR.AppConn.queryAppServers();
LOG.sys('check forward... | javascript | function (msgtype, event) {
// we only forward for non-SR user-defined events at lobby
if (SR.Settings.SERVER_INFO.type !== 'lobby' || msgtype.startsWith('SR'))
return false;
// check if we're lobby and same-name app servers are available
var list = SR.AppConn.queryAppServers();
LOG.sys('check forward... | [
"function",
"(",
"msgtype",
",",
"event",
")",
"{",
"// we only forward for non-SR user-defined events at lobby",
"if",
"(",
"SR",
".",
"Settings",
".",
"SERVER_INFO",
".",
"type",
"!==",
"'lobby'",
"||",
"msgtype",
".",
"startsWith",
"(",
"'SR'",
")",
")",
"ret... | check if an event should be forwarded to another app server for execution | [
"check",
"if",
"an",
"event",
"should",
"be",
"forwarded",
"to",
"another",
"app",
"server",
"for",
"execution"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/handler.js#L287-L319 | train | |
imonology/scalra | core/handler.js | function (response_type, event) {
LOG.sys('handling event response [' + response_type + ']', l_name);
// go over each registered callback function and see which one responds
for (var i=0; i < l_responders[response_type].length; i++) {
// find the callback with matching client id
// call callback and s... | javascript | function (response_type, event) {
LOG.sys('handling event response [' + response_type + ']', l_name);
// go over each registered callback function and see which one responds
for (var i=0; i < l_responders[response_type].length; i++) {
// find the callback with matching client id
// call callback and s... | [
"function",
"(",
"response_type",
",",
"event",
")",
"{",
"LOG",
".",
"sys",
"(",
"'handling event response ['",
"+",
"response_type",
"+",
"']'",
",",
"l_name",
")",
";",
"// go over each registered callback function and see which one responds",
"for",
"(",
"var",
"i... | notify that a response to a particular event is received | [
"notify",
"that",
"a",
"response",
"to",
"a",
"particular",
"event",
"is",
"received"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/handler.js#L632-L652 | train | |
imonology/scalra | extension/proxy.js | function (e, req, res, host) {
LOG.error('proxy error for host: ' + host + '. remove from active proxy list:', 'SR.Proxy');
LOG.error(e, 'SR.Proxy');
// remove proxy info from list
delete l_proxies[host];
// notify for proxy failure
UTIL.safeCall(onProxyFail, host);
// send back to client about t... | javascript | function (e, req, res, host) {
LOG.error('proxy error for host: ' + host + '. remove from active proxy list:', 'SR.Proxy');
LOG.error(e, 'SR.Proxy');
// remove proxy info from list
delete l_proxies[host];
// notify for proxy failure
UTIL.safeCall(onProxyFail, host);
// send back to client about t... | [
"function",
"(",
"e",
",",
"req",
",",
"res",
",",
"host",
")",
"{",
"LOG",
".",
"error",
"(",
"'proxy error for host: '",
"+",
"host",
"+",
"'. remove from active proxy list:'",
",",
"'SR.Proxy'",
")",
";",
"LOG",
".",
"error",
"(",
"e",
",",
"'SR.Proxy'"... | same error handling for both HTTP or WebSocket proxies | [
"same",
"error",
"handling",
"for",
"both",
"HTTP",
"or",
"WebSocket",
"proxies"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/proxy.js#L223-L238 | train | |
imonology/scalra | core/job_queue.js | JobQueue | function JobQueue(para) {
this.queue = [];
this.curr = 0;
this.all_passed = true;
this.timeout = ((typeof para === 'object' && typeof para.timeout === 'number') ? para.timeout : 0);
} | javascript | function JobQueue(para) {
this.queue = [];
this.curr = 0;
this.all_passed = true;
this.timeout = ((typeof para === 'object' && typeof para.timeout === 'number') ? para.timeout : 0);
} | [
"function",
"JobQueue",
"(",
"para",
")",
"{",
"this",
".",
"queue",
"=",
"[",
"]",
";",
"this",
".",
"curr",
"=",
"0",
";",
"this",
".",
"all_passed",
"=",
"true",
";",
"this",
".",
"timeout",
"=",
"(",
"(",
"typeof",
"para",
"===",
"'object'",
... | object-based JobQueue functions | [
"object",
"-",
"based",
"JobQueue",
"functions"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/job_queue.js#L127-L132 | train |
imonology/scalra | core/job_queue.js | function () {
if (item.done === false) {
LOG.error('job timeout! please check if the job calls onDone eventually. ' + (item.name ? '[' + item.name + ']' : ''), l_name);
// force this job be done
onJobDone(false);
}
} | javascript | function () {
if (item.done === false) {
LOG.error('job timeout! please check if the job calls onDone eventually. ' + (item.name ? '[' + item.name + ']' : ''), l_name);
// force this job be done
onJobDone(false);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"item",
".",
"done",
"===",
"false",
")",
"{",
"LOG",
".",
"error",
"(",
"'job timeout! please check if the job calls onDone eventually. '",
"+",
"(",
"item",
".",
"name",
"?",
"'['",
"+",
"item",
".",
"name",
"+",
"']... | if the job does not finish in time | [
"if",
"the",
"job",
"does",
"not",
"finish",
"in",
"time"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/job_queue.js#L195-L202 | train | |
imonology/scalra | entry/handler.js | function (list) {
for (var i=0; i < list.length; i++) {
for (var j=0; j < l_entries.length; j++) {
if (list[i] === l_entries[j]) {
l_entries.splice(j, 1);
break;
}
}
}
} | javascript | function (list) {
for (var i=0; i < list.length; i++) {
for (var j=0; j < l_entries.length; j++) {
if (list[i] === l_entries[j]) {
l_entries.splice(j, 1);
break;
}
}
}
} | [
"function",
"(",
"list",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"l_entries",
".",
"length",
";",
"j",
"++",
")",
"{",
"i... | remove entry from list | [
"remove",
"entry",
"from",
"list"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/entry/handler.js#L29-L39 | train | |
imonology/scalra | demo/web/logic.js | getInput | function getInput() {
var account = document.getElementById('account').value;
var email = (document.getElementById('email') ? document.getElementById('email').value : '');
var password = document.getElementById('password').value;
return {account: account, email: email, password: password};
} | javascript | function getInput() {
var account = document.getElementById('account').value;
var email = (document.getElementById('email') ? document.getElementById('email').value : '');
var password = document.getElementById('password').value;
return {account: account, email: email, password: password};
} | [
"function",
"getInput",
"(",
")",
"{",
"var",
"account",
"=",
"document",
".",
"getElementById",
"(",
"'account'",
")",
".",
"value",
";",
"var",
"email",
"=",
"(",
"document",
".",
"getElementById",
"(",
"'email'",
")",
"?",
"document",
".",
"getElementBy... | retrieve account & password from HTML elements | [
"retrieve",
"account",
"&",
"password",
"from",
"HTML",
"elements"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/demo/web/logic.js#L44-L51 | train |
imonology/scalra | handlers/login.js | function (err, data) {
if (err) {
LOG.warn(err.toString());
}
else {
for (var server in data.accounts) {
LOG.warn('local server: ' + server);
var user_list = data.accounts[server];
for (var uid in user_list) {
var token = user_list[uid];
LOG.warn('local uid: ' + uid + ' token: ' + tok... | javascript | function (err, data) {
if (err) {
LOG.warn(err.toString());
}
else {
for (var server in data.accounts) {
LOG.warn('local server: ' + server);
var user_list = data.accounts[server];
for (var uid in user_list) {
var token = user_list[uid];
LOG.warn('local uid: ' + uid + ' token: ' + tok... | [
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"LOG",
".",
"warn",
"(",
"err",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"server",
"in",
"data",
".",
"accounts",
")",
"{",
"LOG",
"."... | get all local accounts & perform login | [
"get",
"all",
"local",
"accounts",
"&",
"perform",
"login"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/handlers/login.js#L29-L45 | train | |
imonology/scalra | handlers/login.js | function (server, uid, token) {
try {
// convert uid to number if not already
if (typeof uid === 'string')
uid = parseInt(uid);
}
catch (e) {
LOG.error('uid cannot be parsed as integer...', 'login.send_remote_login');
return false;
}
SR.User.loginLocal(server, uid, token, function (result) {
// NO... | javascript | function (server, uid, token) {
try {
// convert uid to number if not already
if (typeof uid === 'string')
uid = parseInt(uid);
}
catch (e) {
LOG.error('uid cannot be parsed as integer...', 'login.send_remote_login');
return false;
}
SR.User.loginLocal(server, uid, token, function (result) {
// NO... | [
"function",
"(",
"server",
",",
"uid",
",",
"token",
")",
"{",
"try",
"{",
"// convert uid to number if not already",
"if",
"(",
"typeof",
"uid",
"===",
"'string'",
")",
"uid",
"=",
"parseInt",
"(",
"uid",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"L... | send login info for local server | [
"send",
"login",
"info",
"for",
"local",
"server"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/handlers/login.js#L50-L73 | train | |
imonology/scalra | handlers/login.js | function (login_id, session, data) {
// acknowledge as 'logined'
l_loginID[login_id] = data.account;
// init session
session['_account'] = data.account;
// TODO: needs to fix this, should read "groups" from DB
session['_groups'] = data.groups;
session['_permissions'] = data.permissions;
session['lastStatu... | javascript | function (login_id, session, data) {
// acknowledge as 'logined'
l_loginID[login_id] = data.account;
// init session
session['_account'] = data.account;
// TODO: needs to fix this, should read "groups" from DB
session['_groups'] = data.groups;
session['_permissions'] = data.permissions;
session['lastStatu... | [
"function",
"(",
"login_id",
",",
"session",
",",
"data",
")",
"{",
"// acknowledge as 'logined'\t",
"l_loginID",
"[",
"login_id",
"]",
"=",
"data",
".",
"account",
";",
"// init session",
"session",
"[",
"'_account'",
"]",
"=",
"data",
".",
"account",
";",
... | initialize session content based on registered or logined user data | [
"initialize",
"session",
"content",
"based",
"on",
"registered",
"or",
"logined",
"user",
"data"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/handlers/login.js#L193-L208 | train | |
imonology/scalra | handlers/login.js | function (err, result) {
// if login is successful, we record the user's account in cache
if (err) {
LOG.warn(err.toString());
result = {code: err.code, msg: err.message};
}
else {
if (result.code === 0) {
LOG.warn('login success, result: ');
LOG.warn(result);
var data = {
account: u... | javascript | function (err, result) {
// if login is successful, we record the user's account in cache
if (err) {
LOG.warn(err.toString());
result = {code: err.code, msg: err.message};
}
else {
if (result.code === 0) {
LOG.warn('login success, result: ');
LOG.warn(result);
var data = {
account: u... | [
"function",
"(",
"err",
",",
"result",
")",
"{",
"// if login is successful, we record the user's account in cache",
"if",
"(",
"err",
")",
"{",
"LOG",
".",
"warn",
"(",
"err",
".",
"toString",
"(",
")",
")",
";",
"result",
"=",
"{",
"code",
":",
"err",
".... | otherwise perform local login | [
"otherwise",
"perform",
"local",
"login"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/handlers/login.js#L320-L379 | train | |
imonology/scalra | handlers/login.js | function (arg) {
if ( ! arg.allow ){
return;
}
var exist = false;
for (var i in data.allow) {
if (data.allow[i] === arg.allow) {
exist = true;
}
}
if ( exist === false ) {
data.allow[data.allow.length] = arg.allow;
}
} | javascript | function (arg) {
if ( ! arg.allow ){
return;
}
var exist = false;
for (var i in data.allow) {
if (data.allow[i] === arg.allow) {
exist = true;
}
}
if ( exist === false ) {
data.allow[data.allow.length] = arg.allow;
}
} | [
"function",
"(",
"arg",
")",
"{",
"if",
"(",
"!",
"arg",
".",
"allow",
")",
"{",
"return",
";",
"}",
"var",
"exist",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"in",
"data",
".",
"allow",
")",
"{",
"if",
"(",
"data",
".",
"allow",
"[",
"i",
... | level exists, to modify this level | [
"level",
"exists",
"to",
"modify",
"this",
"level"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/handlers/login.js#L694-L708 | train | |
imonology/scalra | core/conn.js | Connection | function Connection (type, sender, from) {
// provide default 'from' values
from = from || {};
// connection-specific UUID
this.connID = UTIL.createUUID();
// a project-specific / supplied name (can be account or app name)
this.name = '';
// sender function associated with this connection
this.connector ... | javascript | function Connection (type, sender, from) {
// provide default 'from' values
from = from || {};
// connection-specific UUID
this.connID = UTIL.createUUID();
// a project-specific / supplied name (can be account or app name)
this.name = '';
// sender function associated with this connection
this.connector ... | [
"function",
"Connection",
"(",
"type",
",",
"sender",
",",
"from",
")",
"{",
"// provide default 'from' values",
"from",
"=",
"from",
"||",
"{",
"}",
";",
"// connection-specific UUID",
"this",
".",
"connID",
"=",
"UTIL",
".",
"createUUID",
"(",
")",
";",
"/... | definition for a connection object | [
"definition",
"for",
"a",
"connection",
"object"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/conn.js#L168-L196 | train |
imonology/scalra | core/queue.js | function () {
// get a event from the front of queue
var tmdata = queue.dequeue();
// whether to keep processing (default is no)
busy = false;
// check if data exists
if (tmdata === undefined) {
return;
}
// handle the event if handler is a... | javascript | function () {
// get a event from the front of queue
var tmdata = queue.dequeue();
// whether to keep processing (default is no)
busy = false;
// check if data exists
if (tmdata === undefined) {
return;
}
// handle the event if handler is a... | [
"function",
"(",
")",
"{",
"// get a event from the front of queue",
"var",
"tmdata",
"=",
"queue",
".",
"dequeue",
"(",
")",
";",
"// whether to keep processing (default is no)",
"busy",
"=",
"false",
";",
"// check if data exists",
"if",
"(",
"tmdata",
"===",
"undef... | this is private method to process | [
"this",
"is",
"private",
"method",
"to",
"process"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/queue.js#L74-L131 | train | |
imonology/scalra | extension/sync.js | function (arr) {
// extract collection name
if (arr && typeof arr._name === 'string') {
var size = arr.length - arr._index;
if (size <= 0)
return false;
LOG.sys('try to store to array [' + arr._name + '], # of elements to store: ' + size, 'SR.Sync');
// TODO: wasteful of space?
// NOTE: only n... | javascript | function (arr) {
// extract collection name
if (arr && typeof arr._name === 'string') {
var size = arr.length - arr._index;
if (size <= 0)
return false;
LOG.sys('try to store to array [' + arr._name + '], # of elements to store: ' + size, 'SR.Sync');
// TODO: wasteful of space?
// NOTE: only n... | [
"function",
"(",
"arr",
")",
"{",
"// extract collection name",
"if",
"(",
"arr",
"&&",
"typeof",
"arr",
".",
"_name",
"===",
"'string'",
")",
"{",
"var",
"size",
"=",
"arr",
".",
"length",
"-",
"arr",
".",
"_index",
";",
"if",
"(",
"size",
"<=",
"0"... | store a particular record to DB | [
"store",
"a",
"particular",
"record",
"to",
"DB"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/sync.js#L62-L100 | train | |
imonology/scalra | extension/sync.js | function (arrays, config, onDone) {
var names = [];
// load array's content from DB, if any
SR.DB.getArray(SR.Settings.DB_NAME_SYNC,
function (result) {
// NOTE: if array does not exist it'll return success with an empty array
if (result === null || result.length === 0) {
LOG.warn('no a... | javascript | function (arrays, config, onDone) {
var names = [];
// load array's content from DB, if any
SR.DB.getArray(SR.Settings.DB_NAME_SYNC,
function (result) {
// NOTE: if array does not exist it'll return success with an empty array
if (result === null || result.length === 0) {
LOG.warn('no a... | [
"function",
"(",
"arrays",
",",
"config",
",",
"onDone",
")",
"{",
"var",
"names",
"=",
"[",
"]",
";",
"// load array's content from DB, if any\t",
"SR",
".",
"DB",
".",
"getArray",
"(",
"SR",
".",
"Settings",
".",
"DB_NAME_SYNC",
",",
"function",
"(",
"re... | load data from DB to an in-memory array returns a list of the names of arrays loaded | [
"load",
"data",
"from",
"DB",
"to",
"an",
"in",
"-",
"memory",
"array",
"returns",
"a",
"list",
"of",
"the",
"names",
"of",
"arrays",
"loaded"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/extension/sync.js#L212-L264 | train | |
imonology/scalra | core/API.js | function (args, result, func, extra) {
return new SR.promise(function (resolve, reject) {
UTIL.safeCall(func, args, result, function () {
UTIL.safeCall(resolve);
}, extra);
});
} | javascript | function (args, result, func, extra) {
return new SR.promise(function (resolve, reject) {
UTIL.safeCall(func, args, result, function () {
UTIL.safeCall(resolve);
}, extra);
});
} | [
"function",
"(",
"args",
",",
"result",
",",
"func",
",",
"extra",
")",
"{",
"return",
"new",
"SR",
".",
"promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"UTIL",
".",
"safeCall",
"(",
"func",
",",
"args",
",",
"result",
",",
"fu... | define post-event action | [
"define",
"post",
"-",
"event",
"action"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/API.js#L52-L58 | train | |
imonology/scalra | core/API.js | function (args, onDone, extra) {
// if args are not provided then we shift the parameters
if (typeof args === 'function') {
extra = onDone;
onDone = args;
args = {};
}
// TODO: perform argument type check (currently there's none, so internal API calls won't do type checks)
// TODO: move checker to h... | javascript | function (args, onDone, extra) {
// if args are not provided then we shift the parameters
if (typeof args === 'function') {
extra = onDone;
onDone = args;
args = {};
}
// TODO: perform argument type check (currently there's none, so internal API calls won't do type checks)
// TODO: move checker to h... | [
"function",
"(",
"args",
",",
"onDone",
",",
"extra",
")",
"{",
"// if args are not provided then we shift the parameters",
"if",
"(",
"typeof",
"args",
"===",
"'function'",
")",
"{",
"extra",
"=",
"onDone",
";",
"onDone",
"=",
"args",
";",
"args",
"=",
"{",
... | define wrapper function | [
"define",
"wrapper",
"function"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/API.js#L81-L150 | train | |
imonology/scalra | modules/account.js | function (account) {
// check if DB is initialized
if (typeof l_accounts === 'undefined') {
LOG.error('DB module is not loaded, please enable DB module', l_name);
return false;
}
if (l_accounts.hasOwnProperty(account) === false) {
LOG.error('[' + account + '] not found', l_name);
return false;
}
return ... | javascript | function (account) {
// check if DB is initialized
if (typeof l_accounts === 'undefined') {
LOG.error('DB module is not loaded, please enable DB module', l_name);
return false;
}
if (l_accounts.hasOwnProperty(account) === false) {
LOG.error('[' + account + '] not found', l_name);
return false;
}
return ... | [
"function",
"(",
"account",
")",
"{",
"// check if DB is initialized",
"if",
"(",
"typeof",
"l_accounts",
"===",
"'undefined'",
")",
"{",
"LOG",
".",
"error",
"(",
"'DB module is not loaded, please enable DB module'",
",",
"l_name",
")",
";",
"return",
"false",
";",... | helper functions check if an account is valid | [
"helper",
"functions",
"check",
"if",
"an",
"account",
"is",
"valid"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/modules/account.js#L42-L55 | train | |
imonology/scalra | modules/account.js | getUIDCallback | function getUIDCallback (err, uid) {
if (err) {
return onDone('UID_ERROR');
}
var ip = (extra) ? extra.conn.host : "server";
// NOTE: by default a user is a normal user, user 'groups' can later be customized
var reg = {
uid: uid,
account: args.account,
password: l_encryptPass(args.password),
... | javascript | function getUIDCallback (err, uid) {
if (err) {
return onDone('UID_ERROR');
}
var ip = (extra) ? extra.conn.host : "server";
// NOTE: by default a user is a normal user, user 'groups' can later be customized
var reg = {
uid: uid,
account: args.account,
password: l_encryptPass(args.password),
... | [
"function",
"getUIDCallback",
"(",
"err",
",",
"uid",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"onDone",
"(",
"'UID_ERROR'",
")",
";",
"}",
"var",
"ip",
"=",
"(",
"extra",
")",
"?",
"extra",
".",
"conn",
".",
"host",
":",
"\"server\"",
";",
... | generate unique user_id | [
"generate",
"unique",
"user_id"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/modules/account.js#L239-L272 | train |
imonology/scalra | core/app_connector.js | function (conn) {
LOG.error('AppManager disconnected', 'SR.AppConnector');
if (SR.Settings.APPSERVER_AUTOSHUT === true) {
// shutdown this frontier
l_dispose();
SR.Settings.FRONTIER.dispose();
}
else {
LOG.warn('auto-shutdown is false, attempt to re-connect AppManager in ' + l_timeout... | javascript | function (conn) {
LOG.error('AppManager disconnected', 'SR.AppConnector');
if (SR.Settings.APPSERVER_AUTOSHUT === true) {
// shutdown this frontier
l_dispose();
SR.Settings.FRONTIER.dispose();
}
else {
LOG.warn('auto-shutdown is false, attempt to re-connect AppManager in ' + l_timeout... | [
"function",
"(",
"conn",
")",
"{",
"LOG",
".",
"error",
"(",
"'AppManager disconnected'",
",",
"'SR.AppConnector'",
")",
";",
"if",
"(",
"SR",
".",
"Settings",
".",
"APPSERVER_AUTOSHUT",
"===",
"true",
")",
"{",
"// shutdown this frontier",
"l_dispose",
"(",
"... | custom handling for removing a connection | [
"custom",
"handling",
"for",
"removing",
"a",
"connection"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/app_connector.js#L36-L52 | train | |
imonology/scalra | core/app_connector.js | function () {
LOG.warn('appinfo sent to lobby:');
LOG.warn(l_appinfo);
// notify AppManager we're ready
l_notifyLobby('SR_APP_READY', l_appinfo, 'SR_APP_READY_RES',
function (event) {
if (event.data.op === true)
LOG.sys('SR_APP_READY returns ok', 'l_HandlerPool');
... | javascript | function () {
LOG.warn('appinfo sent to lobby:');
LOG.warn(l_appinfo);
// notify AppManager we're ready
l_notifyLobby('SR_APP_READY', l_appinfo, 'SR_APP_READY_RES',
function (event) {
if (event.data.op === true)
LOG.sys('SR_APP_READY returns ok', 'l_HandlerPool');
... | [
"function",
"(",
")",
"{",
"LOG",
".",
"warn",
"(",
"'appinfo sent to lobby:'",
")",
";",
"LOG",
".",
"warn",
"(",
"l_appinfo",
")",
";",
"// notify AppManager we're ready",
"l_notifyLobby",
"(",
"'SR_APP_READY'",
",",
"l_appinfo",
",",
"'SR_APP_READY_RES'",
",",
... | register myself as a app to app manager do it after connector init success | [
"register",
"myself",
"as",
"a",
"app",
"to",
"app",
"manager",
"do",
"it",
"after",
"connector",
"init",
"success"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/app_connector.js#L102-L123 | train | |
imonology/scalra | core/app_connector.js | function (ip_port, onDone) {
if (l_appConnector === undefined) {
LOG.warn('appConnector not init, cannot connect');
return;
}
// retrieve from previous connect attempt, also store for later connect attempt
// TODO: will need to change when lobby port becomes not fixed
ip_port = ip_port || l_ip_port;
l_ip_p... | javascript | function (ip_port, onDone) {
if (l_appConnector === undefined) {
LOG.warn('appConnector not init, cannot connect');
return;
}
// retrieve from previous connect attempt, also store for later connect attempt
// TODO: will need to change when lobby port becomes not fixed
ip_port = ip_port || l_ip_port;
l_ip_p... | [
"function",
"(",
"ip_port",
",",
"onDone",
")",
"{",
"if",
"(",
"l_appConnector",
"===",
"undefined",
")",
"{",
"LOG",
".",
"warn",
"(",
"'appConnector not init, cannot connect'",
")",
";",
"return",
";",
"}",
"// retrieve from previous connect attempt, also store for... | attempt to connect to manager | [
"attempt",
"to",
"connect",
"to",
"manager"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/core/app_connector.js#L126-L155 | train | |
imonology/scalra | demo/lobby/router.js | function (req) {
var session = l_getSession(req);
if (session.hasOwnProperty('_user')) {
var login = session._user;
login.admin = (session._user.account === 'admin');
return login;
}
LOG.warn('user not yet logined...');
return {control: {groups: [], permissions: []}};
} | javascript | function (req) {
var session = l_getSession(req);
if (session.hasOwnProperty('_user')) {
var login = session._user;
login.admin = (session._user.account === 'admin');
return login;
}
LOG.warn('user not yet logined...');
return {control: {groups: [], permissions: []}};
} | [
"function",
"(",
"req",
")",
"{",
"var",
"session",
"=",
"l_getSession",
"(",
"req",
")",
";",
"if",
"(",
"session",
".",
"hasOwnProperty",
"(",
"'_user'",
")",
")",
"{",
"var",
"login",
"=",
"session",
".",
"_user",
";",
"login",
".",
"admin",
"=",
... | pass in request object, returns session data if logined, otherwise returns null | [
"pass",
"in",
"request",
"object",
"returns",
"session",
"data",
"if",
"logined",
"otherwise",
"returns",
"null"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/demo/lobby/router.js#L31-L41 | train | |
gastonelhordoy/grunt-rpm | tasks/rpm.js | copyFilesToPack | function copyFilesToPack(grunt, buildPath, filesToPack) {
return function(callback) {
grunt.util.async.forEach(filesToPack, function(fileConfig, callback) {
try {
var filepathDest;
if (detectDestType(grunt, fileConfig.dest) === 'directory') {
var dest = (fileConfig.orig.expand) ? fileConfig.dest : pa... | javascript | function copyFilesToPack(grunt, buildPath, filesToPack) {
return function(callback) {
grunt.util.async.forEach(filesToPack, function(fileConfig, callback) {
try {
var filepathDest;
if (detectDestType(grunt, fileConfig.dest) === 'directory') {
var dest = (fileConfig.orig.expand) ? fileConfig.dest : pa... | [
"function",
"copyFilesToPack",
"(",
"grunt",
",",
"buildPath",
",",
"filesToPack",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"grunt",
".",
"util",
".",
"async",
".",
"forEach",
"(",
"filesToPack",
",",
"function",
"(",
"fileConfig",
",",
"... | Copy all the selected files to the tmp folder which wikll be the buildroot directory for rpmbuild | [
"Copy",
"all",
"the",
"selected",
"files",
"to",
"the",
"tmp",
"folder",
"which",
"wikll",
"be",
"the",
"buildroot",
"directory",
"for",
"rpmbuild"
] | 8c6761959f912aab7234b68ea40893612d6b9b3d | https://github.com/gastonelhordoy/grunt-rpm/blob/8c6761959f912aab7234b68ea40893612d6b9b3d/tasks/rpm.js#L93-L141 | train |
gastonelhordoy/grunt-rpm | tasks/rpm.js | writeSpecFile | function writeSpecFile(grunt, options, filesToPack) {
return function(callback) {
try {
var specPath = path.join(options.destination, specFolder);
options.files = filesToPack;
var pkg = grunt.file.readJSON('package.json');
grunt.util._.defaults(options, pkg);
options.specFilepath = path.join(specP... | javascript | function writeSpecFile(grunt, options, filesToPack) {
return function(callback) {
try {
var specPath = path.join(options.destination, specFolder);
options.files = filesToPack;
var pkg = grunt.file.readJSON('package.json');
grunt.util._.defaults(options, pkg);
options.specFilepath = path.join(specP... | [
"function",
"writeSpecFile",
"(",
"grunt",
",",
"options",
",",
"filesToPack",
")",
"{",
"return",
"function",
"(",
"callback",
")",
"{",
"try",
"{",
"var",
"specPath",
"=",
"path",
".",
"join",
"(",
"options",
".",
"destination",
",",
"specFolder",
")",
... | Write the spec file that rpmbuild will read for the rpm details | [
"Write",
"the",
"spec",
"file",
"that",
"rpmbuild",
"will",
"read",
"for",
"the",
"rpm",
"details"
] | 8c6761959f912aab7234b68ea40893612d6b9b3d | https://github.com/gastonelhordoy/grunt-rpm/blob/8c6761959f912aab7234b68ea40893612d6b9b3d/tasks/rpm.js#L146-L160 | train |
imonology/scalra | modules/cloud_connector.js | function () {
if (l_ip_port === undefined) {
LOG.warn('not init (or already disposed), cannot connect to server');
return;
}
if (l_connector === undefined)
l_connector = new SR.Connector(l_config);
// establish connection
LOG.warn('connecting to: ' + l_ip_port);
l_connector.connect(l_ip_port, func... | javascript | function () {
if (l_ip_port === undefined) {
LOG.warn('not init (or already disposed), cannot connect to server');
return;
}
if (l_connector === undefined)
l_connector = new SR.Connector(l_config);
// establish connection
LOG.warn('connecting to: ' + l_ip_port);
l_connector.connect(l_ip_port, func... | [
"function",
"(",
")",
"{",
"if",
"(",
"l_ip_port",
"===",
"undefined",
")",
"{",
"LOG",
".",
"warn",
"(",
"'not init (or already disposed), cannot connect to server'",
")",
";",
"return",
";",
"}",
"if",
"(",
"l_connector",
"===",
"undefined",
")",
"l_connector"... | connect to cloud server | [
"connect",
"to",
"cloud",
"server"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/modules/cloud_connector.js#L36-L62 | train | |
imonology/scalra | monitor/REST_handle.js | function (res, res_obj) {
// return response if exist, otherwise response might be returned
// AFTER some callback is done handling (i.e., response will be returned within the handler)
if (typeof res_obj === 'string') {
LOG.sys('replying a string: ' + res_obj);
res.writeHead(200, {'Content... | javascript | function (res, res_obj) {
// return response if exist, otherwise response might be returned
// AFTER some callback is done handling (i.e., response will be returned within the handler)
if (typeof res_obj === 'string') {
LOG.sys('replying a string: ' + res_obj);
res.writeHead(200, {'Content... | [
"function",
"(",
"res",
",",
"res_obj",
")",
"{",
"// return response if exist, otherwise response might be returned ",
"// AFTER some callback is done handling (i.e., response will be returned within the handler)",
"if",
"(",
"typeof",
"res_obj",
"===",
"'string'",
")",
"{",
"LOG"... | helper code send back response to client | [
"helper",
"code",
"send",
"back",
"response",
"to",
"client"
] | 0cf7377d02bf1e6beb90d6821c144eefb89feaa9 | https://github.com/imonology/scalra/blob/0cf7377d02bf1e6beb90d6821c144eefb89feaa9/monitor/REST_handle.js#L31-L45 | 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.