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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
nick-thompson/capp | index.js | init | function init (directory, callback) {
var source = path.join(__dirname, 'template');
ncp(source, directory, callback);
} | javascript | function init (directory, callback) {
var source = path.join(__dirname, 'template');
ncp(source, directory, callback);
} | [
"function",
"init",
"(",
"directory",
",",
"callback",
")",
"{",
"var",
"source",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'template'",
")",
";",
"ncp",
"(",
"source",
",",
"directory",
",",
"callback",
")",
";",
"}"
] | Initialize a boilerplate CouchApp in the specified directory.
@param {string} directory
@param {function} callback (err) | [
"Initialize",
"a",
"boilerplate",
"CouchApp",
"in",
"the",
"specified",
"directory",
"."
] | 3df2193d7b464b0440224f658128fded8bff8c88 | https://github.com/nick-thompson/capp/blob/3df2193d7b464b0440224f658128fded8bff8c88/index.js#L106-L109 | train |
queicherius/generic-checkmark-reporter | src/index.js | start | function start (outputFunction) {
startTime = new Date()
failures = []
count = 0
stats = {success: 0, failure: 0, skipped: 0}
log = outputFunction || log
} | javascript | function start (outputFunction) {
startTime = new Date()
failures = []
count = 0
stats = {success: 0, failure: 0, skipped: 0}
log = outputFunction || log
} | [
"function",
"start",
"(",
"outputFunction",
")",
"{",
"startTime",
"=",
"new",
"Date",
"(",
")",
"failures",
"=",
"[",
"]",
"count",
"=",
"0",
"stats",
"=",
"{",
"success",
":",
"0",
",",
"failure",
":",
"0",
",",
"skipped",
":",
"0",
"}",
"log",
... | Function to call at the start of the test run, resets all variables | [
"Function",
"to",
"call",
"at",
"the",
"start",
"of",
"the",
"test",
"run",
"resets",
"all",
"variables"
] | ded2db7a82e71ca4beb52e2599a73a5e5a0e9687 | https://github.com/queicherius/generic-checkmark-reporter/blob/ded2db7a82e71ca4beb52e2599a73a5e5a0e9687/src/index.js#L17-L23 | train |
queicherius/generic-checkmark-reporter | src/index.js | result | function result (type, error) {
if (count % 40 === 0) {
log('\n ')
}
count++
stats[type]++
log(SYMBOLS[type] + ' ')
if (type === 'failure') {
failures.push(error)
}
} | javascript | function result (type, error) {
if (count % 40 === 0) {
log('\n ')
}
count++
stats[type]++
log(SYMBOLS[type] + ' ')
if (type === 'failure') {
failures.push(error)
}
} | [
"function",
"result",
"(",
"type",
",",
"error",
")",
"{",
"if",
"(",
"count",
"%",
"40",
"===",
"0",
")",
"{",
"log",
"(",
"'\\n '",
")",
"}",
"count",
"++",
"stats",
"[",
"type",
"]",
"++",
"log",
"(",
"SYMBOLS",
"[",
"type",
"]",
"+",
"' '"... | Function to call to report a single spec result | [
"Function",
"to",
"call",
"to",
"report",
"a",
"single",
"spec",
"result"
] | ded2db7a82e71ca4beb52e2599a73a5e5a0e9687 | https://github.com/queicherius/generic-checkmark-reporter/blob/ded2db7a82e71ca4beb52e2599a73a5e5a0e9687/src/index.js#L26-L38 | train |
queicherius/generic-checkmark-reporter | src/index.js | end | function end () {
var diff = new Date() - startTime
log('\n\n')
log(' ' + SYMBOLS.success + ' ' + (stats.success + ' passing ').green)
log(('(' + diff + 'ms)').grey)
if (stats.skipped) {
log('\n ' + SYMBOLS.skipped + ' ' + (stats.skipped + ' pending').cyan)
}
if (stats.failure) {
log('\n ' +... | javascript | function end () {
var diff = new Date() - startTime
log('\n\n')
log(' ' + SYMBOLS.success + ' ' + (stats.success + ' passing ').green)
log(('(' + diff + 'ms)').grey)
if (stats.skipped) {
log('\n ' + SYMBOLS.skipped + ' ' + (stats.skipped + ' pending').cyan)
}
if (stats.failure) {
log('\n ' +... | [
"function",
"end",
"(",
")",
"{",
"var",
"diff",
"=",
"new",
"Date",
"(",
")",
"-",
"startTime",
"log",
"(",
"'\\n\\n'",
")",
"log",
"(",
"' '",
"+",
"SYMBOLS",
".",
"success",
"+",
"' '",
"+",
"(",
"stats",
".",
"success",
"+",
"' passing '",
")"... | Function to call to report end results | [
"Function",
"to",
"call",
"to",
"report",
"end",
"results"
] | ded2db7a82e71ca4beb52e2599a73a5e5a0e9687 | https://github.com/queicherius/generic-checkmark-reporter/blob/ded2db7a82e71ca4beb52e2599a73a5e5a0e9687/src/index.js#L41-L61 | train |
queicherius/generic-checkmark-reporter | src/index.js | logError | function logError (failure, index) {
index = index + 1
if (index > 1) {
log('\n\n')
}
log(' ' + index + ') ' + failure.description + ': ')
if (failure.environment) {
log(('(' + failure.environment + ')').grey)
}
log('\n\n')
// Log the actual error message / stack trace / diffs
var intend... | javascript | function logError (failure, index) {
index = index + 1
if (index > 1) {
log('\n\n')
}
log(' ' + index + ') ' + failure.description + ': ')
if (failure.environment) {
log(('(' + failure.environment + ')').grey)
}
log('\n\n')
// Log the actual error message / stack trace / diffs
var intend... | [
"function",
"logError",
"(",
"failure",
",",
"index",
")",
"{",
"index",
"=",
"index",
"+",
"1",
"if",
"(",
"index",
">",
"1",
")",
"{",
"log",
"(",
"'\\n\\n'",
")",
"}",
"log",
"(",
"' '",
"+",
"index",
"+",
"') '",
"+",
"failure",
".",
"descri... | Log a single error | [
"Log",
"a",
"single",
"error"
] | ded2db7a82e71ca4beb52e2599a73a5e5a0e9687 | https://github.com/queicherius/generic-checkmark-reporter/blob/ded2db7a82e71ca4beb52e2599a73a5e5a0e9687/src/index.js#L64-L90 | train |
queicherius/generic-checkmark-reporter | src/index.js | intendLines | function intendLines (string, trim, intend) {
var intendStr = new Array(intend + 1).join(' ')
return string
.split('\n')
.map(function (s) {
return trim ? s.trim() : s
})
.join('\n')
.replace(/^/gm, intendStr)
} | javascript | function intendLines (string, trim, intend) {
var intendStr = new Array(intend + 1).join(' ')
return string
.split('\n')
.map(function (s) {
return trim ? s.trim() : s
})
.join('\n')
.replace(/^/gm, intendStr)
} | [
"function",
"intendLines",
"(",
"string",
",",
"trim",
",",
"intend",
")",
"{",
"var",
"intendStr",
"=",
"new",
"Array",
"(",
"intend",
"+",
"1",
")",
".",
"join",
"(",
"' '",
")",
"return",
"string",
".",
"split",
"(",
"'\\n'",
")",
".",
"map",
"(... | Intend every line of a string | [
"Intend",
"every",
"line",
"of",
"a",
"string"
] | ded2db7a82e71ca4beb52e2599a73a5e5a0e9687 | https://github.com/queicherius/generic-checkmark-reporter/blob/ded2db7a82e71ca4beb52e2599a73a5e5a0e9687/src/index.js#L153-L163 | train |
vkiding/jud-vue-framework | index.js | registerComponents | function registerComponents (newComponents) {
var config = Vue$2.config;
var newConfig = {};
if (Array.isArray(newComponents)) {
newComponents.forEach(function (component) {
if (!component) {
return
}
if (typeof component === 'string') {
components[component] = true;
... | javascript | function registerComponents (newComponents) {
var config = Vue$2.config;
var newConfig = {};
if (Array.isArray(newComponents)) {
newComponents.forEach(function (component) {
if (!component) {
return
}
if (typeof component === 'string') {
components[component] = true;
... | [
"function",
"registerComponents",
"(",
"newComponents",
")",
"{",
"var",
"config",
"=",
"Vue$2",
".",
"config",
";",
"var",
"newConfig",
"=",
"{",
"}",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"newComponents",
")",
")",
"{",
"newComponents",
".",
"f... | Register native components information.
@param {array} newComponents | [
"Register",
"native",
"components",
"information",
"."
] | 1be5034f4cf3fc7dbba6beae78d92028efea52d0 | https://github.com/vkiding/jud-vue-framework/blob/1be5034f4cf3fc7dbba6beae78d92028efea52d0/index.js#L5018-L5039 | train |
travism/solid-logger-js | lib/adapters/file.js | ensureLogsRotated | function ensureLogsRotated(stats){
// TODO: other writes should wait until this is done
var today = new Date(),
modifiedDate = new Date(stats.mtime),
archivedFileName;
if(!_logDatesMatch(today, modifiedDate)){
archivedFileName = _createRotatedLogName(this.config.path, modifiedDate);... | javascript | function ensureLogsRotated(stats){
// TODO: other writes should wait until this is done
var today = new Date(),
modifiedDate = new Date(stats.mtime),
archivedFileName;
if(!_logDatesMatch(today, modifiedDate)){
archivedFileName = _createRotatedLogName(this.config.path, modifiedDate);... | [
"function",
"ensureLogsRotated",
"(",
"stats",
")",
"{",
"// TODO: other writes should wait until this is done",
"var",
"today",
"=",
"new",
"Date",
"(",
")",
",",
"modifiedDate",
"=",
"new",
"Date",
"(",
"stats",
".",
"mtime",
")",
",",
"archivedFileName",
";",
... | Method will look at the stats of a file and if it was modified on a date that was not today then it will
rename it to it's modfied date so we can start fresh daily.
@param stats Stats of a file
@returns {string} Status of rotation ('datematches' - do nothing, 'logrotated' - change detected rename file) | [
"Method",
"will",
"look",
"at",
"the",
"stats",
"of",
"a",
"file",
"and",
"if",
"it",
"was",
"modified",
"on",
"a",
"date",
"that",
"was",
"not",
"today",
"then",
"it",
"will",
"rename",
"it",
"to",
"it",
"s",
"modfied",
"date",
"so",
"we",
"can",
... | e5287dcfc680fcfa3eb449dd29bc8c92106184a9 | https://github.com/travism/solid-logger-js/blob/e5287dcfc680fcfa3eb449dd29bc8c92106184a9/lib/adapters/file.js#L139-L153 | train |
travism/solid-logger-js | lib/adapters/file.js | _logDatesMatch | function _logDatesMatch(d1, d2){
return ((d1.getFullYear()===d2.getFullYear())&&(d1.getMonth()===d2.getMonth())&&(d1.getDate()===d2.getDate()));
} | javascript | function _logDatesMatch(d1, d2){
return ((d1.getFullYear()===d2.getFullYear())&&(d1.getMonth()===d2.getMonth())&&(d1.getDate()===d2.getDate()));
} | [
"function",
"_logDatesMatch",
"(",
"d1",
",",
"d2",
")",
"{",
"return",
"(",
"(",
"d1",
".",
"getFullYear",
"(",
")",
"===",
"d2",
".",
"getFullYear",
"(",
")",
")",
"&&",
"(",
"d1",
".",
"getMonth",
"(",
")",
"===",
"d2",
".",
"getMonth",
"(",
"... | Internal utility method that will tell me if the date from the existing log file matches todays Date
@param d1 1st date to compare
@param d2 2nd date to compare
@returns {boolean} | [
"Internal",
"utility",
"method",
"that",
"will",
"tell",
"me",
"if",
"the",
"date",
"from",
"the",
"existing",
"log",
"file",
"matches",
"todays",
"Date"
] | e5287dcfc680fcfa3eb449dd29bc8c92106184a9 | https://github.com/travism/solid-logger-js/blob/e5287dcfc680fcfa3eb449dd29bc8c92106184a9/lib/adapters/file.js#L184-L186 | train |
travism/solid-logger-js | lib/adapters/file.js | _createRotatedLogName | function _createRotatedLogName(logPath, modifiedDate){
var logName = logPath,
suffixIdx = logPath.lastIndexOf('.'),
suffix = '';
if(suffixIdx > -1){
suffix = logName.substr(suffixIdx, logName.length);
logName = logName.replace(
suffix, ('.' +
modified... | javascript | function _createRotatedLogName(logPath, modifiedDate){
var logName = logPath,
suffixIdx = logPath.lastIndexOf('.'),
suffix = '';
if(suffixIdx > -1){
suffix = logName.substr(suffixIdx, logName.length);
logName = logName.replace(
suffix, ('.' +
modified... | [
"function",
"_createRotatedLogName",
"(",
"logPath",
",",
"modifiedDate",
")",
"{",
"var",
"logName",
"=",
"logPath",
",",
"suffixIdx",
"=",
"logPath",
".",
"lastIndexOf",
"(",
"'.'",
")",
",",
"suffix",
"=",
"''",
";",
"if",
"(",
"suffixIdx",
">",
"-",
... | Method that will take the passed in logPath and recreate the path with a modified file name. So if a file
was modified on a previous day and a new log is coming in on the current day, then we want to rename the
old log file with the date in the name.
@param logPath Path of current log file
@param modifiedDate Last file... | [
"Method",
"that",
"will",
"take",
"the",
"passed",
"in",
"logPath",
"and",
"recreate",
"the",
"path",
"with",
"a",
"modified",
"file",
"name",
".",
"So",
"if",
"a",
"file",
"was",
"modified",
"on",
"a",
"previous",
"day",
"and",
"a",
"new",
"log",
"is"... | e5287dcfc680fcfa3eb449dd29bc8c92106184a9 | https://github.com/travism/solid-logger-js/blob/e5287dcfc680fcfa3eb449dd29bc8c92106184a9/lib/adapters/file.js#L196-L217 | train |
DannyNemer/dantil | dantil.js | getStackTraceArray | function getStackTraceArray() {
var origStackTraceLimit = Error.stackTraceLimit
var origPrepareStackTrace = Error.prepareStackTrace
// Collect all stack frames.
Error.stackTraceLimit = Infinity
// Get a structured stack trace as an `Array` of `CallSite` objects, each of which represents a stack frame, with ... | javascript | function getStackTraceArray() {
var origStackTraceLimit = Error.stackTraceLimit
var origPrepareStackTrace = Error.prepareStackTrace
// Collect all stack frames.
Error.stackTraceLimit = Infinity
// Get a structured stack trace as an `Array` of `CallSite` objects, each of which represents a stack frame, with ... | [
"function",
"getStackTraceArray",
"(",
")",
"{",
"var",
"origStackTraceLimit",
"=",
"Error",
".",
"stackTraceLimit",
"var",
"origPrepareStackTrace",
"=",
"Error",
".",
"prepareStackTrace",
"// Collect all stack frames.",
"Error",
".",
"stackTraceLimit",
"=",
"Infinity",
... | Gets the structured stack trace as an array of `CallSite` objects, excluding the stack frames for this module and native Node functions.
@private
@static
@returns {CallSite[]} Returns the structured stack trace. | [
"Gets",
"the",
"structured",
"stack",
"trace",
"as",
"an",
"array",
"of",
"CallSite",
"objects",
"excluding",
"the",
"stack",
"frames",
"for",
"this",
"module",
"and",
"native",
"Node",
"functions",
"."
] | dbccccc61d59111b71e7333a60092a93b573fdac | https://github.com/DannyNemer/dantil/blob/dbccccc61d59111b71e7333a60092a93b573fdac/dantil.js#L322-L356 | train |
DannyNemer/dantil | dantil.js | writeToProcessStream | function writeToProcessStream(processStreamName, string) {
var writableStream = process[processStreamName]
if (writableStream) {
writableStream.write(string + '\n')
} else {
throw new Error('Unrecognized process stream: ' + exports.stylize(processStreamName))
}
} | javascript | function writeToProcessStream(processStreamName, string) {
var writableStream = process[processStreamName]
if (writableStream) {
writableStream.write(string + '\n')
} else {
throw new Error('Unrecognized process stream: ' + exports.stylize(processStreamName))
}
} | [
"function",
"writeToProcessStream",
"(",
"processStreamName",
",",
"string",
")",
"{",
"var",
"writableStream",
"=",
"process",
"[",
"processStreamName",
"]",
"if",
"(",
"writableStream",
")",
"{",
"writableStream",
".",
"write",
"(",
"string",
"+",
"'\\n'",
")"... | Writes `string` with a trailing newline to `processStreamName`.
@private
@static
@param {string} processStreamName The name of the writable process stream (e.g., `stout`, `stderr`).
@param {string} string The string to print. | [
"Writes",
"string",
"with",
"a",
"trailing",
"newline",
"to",
"processStreamName",
"."
] | dbccccc61d59111b71e7333a60092a93b573fdac | https://github.com/DannyNemer/dantil/blob/dbccccc61d59111b71e7333a60092a93b573fdac/dantil.js#L864-L871 | train |
DannyNemer/dantil | dantil.js | prettify | function prettify(args, options) {
if (!options) {
options = {}
}
var stylizeOptions = {
// Number of times to recurse while formatting; defaults to 2.
depth: options.depth,
// Format in color if the terminal supports color.
colors: exports.colors.supportsColor,
}
// Use `RegExp()` to ge... | javascript | function prettify(args, options) {
if (!options) {
options = {}
}
var stylizeOptions = {
// Number of times to recurse while formatting; defaults to 2.
depth: options.depth,
// Format in color if the terminal supports color.
colors: exports.colors.supportsColor,
}
// Use `RegExp()` to ge... | [
"function",
"prettify",
"(",
"args",
",",
"options",
")",
"{",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
"}",
"var",
"stylizeOptions",
"=",
"{",
"// Number of times to recurse while formatting; defaults to 2.",
"depth",
":",
"options",
".",
... | Formats the provided values and objects in color for pretty-printing, recursing `options.depth` times while formatting objects.
Formats plain `Object` and `Array` instances with multi-line string representations on separate lines. Concatenates and formats all other consecutive values on the same line.
If the first ar... | [
"Formats",
"the",
"provided",
"values",
"and",
"objects",
"in",
"color",
"for",
"pretty",
"-",
"printing",
"recursing",
"options",
".",
"depth",
"times",
"while",
"formatting",
"objects",
"."
] | dbccccc61d59111b71e7333a60092a93b573fdac | https://github.com/DannyNemer/dantil/blob/dbccccc61d59111b71e7333a60092a93b573fdac/dantil.js#L888-L979 | train |
DannyNemer/dantil | dantil.js | stringifyStackFrame | function stringifyStackFrame(stackFrame, label) {
var frameString = stackFrame.toString()
// Colorize function name (or `label`, if provided).
var lastSpaceIndex = frameString.lastIndexOf(' ')
if (lastSpaceIndex !== -1) {
return exports.colors.cyan(label || frameString.slice(0, lastSpaceIndex)) + frameStri... | javascript | function stringifyStackFrame(stackFrame, label) {
var frameString = stackFrame.toString()
// Colorize function name (or `label`, if provided).
var lastSpaceIndex = frameString.lastIndexOf(' ')
if (lastSpaceIndex !== -1) {
return exports.colors.cyan(label || frameString.slice(0, lastSpaceIndex)) + frameStri... | [
"function",
"stringifyStackFrame",
"(",
"stackFrame",
",",
"label",
")",
"{",
"var",
"frameString",
"=",
"stackFrame",
".",
"toString",
"(",
")",
"// Colorize function name (or `label`, if provided).",
"var",
"lastSpaceIndex",
"=",
"frameString",
".",
"lastIndexOf",
"("... | Stringifies and colorizes the function name in `stackFrame`. If provided, `label` substitutes the function name in the `stackFrame` string representation.
@private
@static
@param {CallSite} stackFrame The stack frame to stringify and stylize.
@param {string} [label] The label that substitutes the function name in the ... | [
"Stringifies",
"and",
"colorizes",
"the",
"function",
"name",
"in",
"stackFrame",
".",
"If",
"provided",
"label",
"substitutes",
"the",
"function",
"name",
"in",
"the",
"stackFrame",
"string",
"representation",
"."
] | dbccccc61d59111b71e7333a60092a93b573fdac | https://github.com/DannyNemer/dantil/blob/dbccccc61d59111b71e7333a60092a93b573fdac/dantil.js#L1431-L1446 | train |
AndreasMadsen/immortal | lib/helpers.js | ProcessWatcher | function ProcessWatcher(pid, parent) {
var self = this;
this.dead = false;
// check first if process is alive
if (exports.alive(pid) === false) {
process.nextTick(function () {
self.dead = true;
self.emit('dead');
});
return self;
}
// use disconnect to detec... | javascript | function ProcessWatcher(pid, parent) {
var self = this;
this.dead = false;
// check first if process is alive
if (exports.alive(pid) === false) {
process.nextTick(function () {
self.dead = true;
self.emit('dead');
});
return self;
}
// use disconnect to detec... | [
"function",
"ProcessWatcher",
"(",
"pid",
",",
"parent",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"dead",
"=",
"false",
";",
"// check first if process is alive",
"if",
"(",
"exports",
".",
"alive",
"(",
"pid",
")",
"===",
"false",
")",
"{... | continusely check if process alive and execute callback when the process is missing | [
"continusely",
"check",
"if",
"process",
"alive",
"and",
"execute",
"callback",
"when",
"the",
"process",
"is",
"missing"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/helpers.js#L90-L136 | train |
PsychoLlama/panic-manager | src/Manager.js | validate | function validate (config) {
/** Make sure the config object was passed. */
if (!config) {
throw new TypeError('Missing configuration object.');
}
/** Make sure the panic url is provided. */
if (typeof config.panic !== 'string') {
throw new TypeError('Panic server URL "config.panic" not provided.');
}
/**... | javascript | function validate (config) {
/** Make sure the config object was passed. */
if (!config) {
throw new TypeError('Missing configuration object.');
}
/** Make sure the panic url is provided. */
if (typeof config.panic !== 'string') {
throw new TypeError('Panic server URL "config.panic" not provided.');
}
/**... | [
"function",
"validate",
"(",
"config",
")",
"{",
"/** Make sure the config object was passed. */",
"if",
"(",
"!",
"config",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Missing configuration object.'",
")",
";",
"}",
"/** Make sure the panic url is provided. */",
"if",
... | Validate a config object.
@throws {TypeError} - Reports any missing inputs.
@param {Object} config - The configuration object.
@returns {undefined} | [
"Validate",
"a",
"config",
"object",
"."
] | d68c8c918994a5b93647bd7965e364d6ddc411de | https://github.com/PsychoLlama/panic-manager/blob/d68c8c918994a5b93647bd7965e364d6ddc411de/src/Manager.js#L14-L43 | train |
PsychoLlama/panic-manager | src/Manager.js | Manager | function Manager (remote) {
/** Allow usage without `new`. */
if (!(this instanceof Manager)) {
return new Manager(remote);
}
/**
* @property {Boolean} isRemote
* Whether the manager is remote.
*/
this.isRemote = false;
/**
* @property {Socket} socket
* A socket.io instance, or `null` if using loca... | javascript | function Manager (remote) {
/** Allow usage without `new`. */
if (!(this instanceof Manager)) {
return new Manager(remote);
}
/**
* @property {Boolean} isRemote
* Whether the manager is remote.
*/
this.isRemote = false;
/**
* @property {Socket} socket
* A socket.io instance, or `null` if using loca... | [
"function",
"Manager",
"(",
"remote",
")",
"{",
"/** Allow usage without `new`. */",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Manager",
")",
")",
"{",
"return",
"new",
"Manager",
"(",
"remote",
")",
";",
"}",
"/**\n\t * @property {Boolean} isRemote\n\t * Whether ... | Manage panic clients in bulk, either locally or remotely.
@class Manager
@param {Mixed} remote - Either an http.Server to attach to,
a URL to connect to, or `undefined` if there is no remote. | [
"Manage",
"panic",
"clients",
"in",
"bulk",
"either",
"locally",
"or",
"remotely",
"."
] | d68c8c918994a5b93647bd7965e364d6ddc411de | https://github.com/PsychoLlama/panic-manager/blob/d68c8c918994a5b93647bd7965e364d6ddc411de/src/Manager.js#L52-L104 | train |
doowb/recent | index.js | recent | function recent(views, options) {
options = options || {};
var prop = options.prop || 'data.date';
var limit = options.limit || 10;
var res = {};
for (var key in views) {
if (views.hasOwnProperty(key)) {
var date = createdDate(key, views[key], prop);
res[date] = res[date] || [];
res[da... | javascript | function recent(views, options) {
options = options || {};
var prop = options.prop || 'data.date';
var limit = options.limit || 10;
var res = {};
for (var key in views) {
if (views.hasOwnProperty(key)) {
var date = createdDate(key, views[key], prop);
res[date] = res[date] || [];
res[da... | [
"function",
"recent",
"(",
"views",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"prop",
"=",
"options",
".",
"prop",
"||",
"'data.date'",
";",
"var",
"limit",
"=",
"options",
".",
"limit",
"||",
"10",
";",
"var",
... | Return the most recent items on an object.
```
var top10 = recent(posts);
```
@param {Object} `views` Object hash of items.
@param {Object} `options` Options to determine limit and property to sort on.
@return {Object} Object of most recent items.
@api public | [
"Return",
"the",
"most",
"recent",
"items",
"on",
"an",
"object",
"."
] | 7858a521be1d8f78c3cf37f058aef1d8a5b6414a | https://github.com/doowb/recent/blob/7858a521be1d8f78c3cf37f058aef1d8a5b6414a/index.js#L25-L55 | train |
doowb/recent | index.js | createdDate | function createdDate(key, value, prop) {
var val = prop ? get(value, prop) : value;
var str = val || key;
var re = /^(\d{4})-(\d{2})-(\d{2})/;
var m = re.exec(str);
if (!m) return null;
return String(m[1]) + String(m[2]) + String(m[3]);
} | javascript | function createdDate(key, value, prop) {
var val = prop ? get(value, prop) : value;
var str = val || key;
var re = /^(\d{4})-(\d{2})-(\d{2})/;
var m = re.exec(str);
if (!m) return null;
return String(m[1]) + String(m[2]) + String(m[3]);
} | [
"function",
"createdDate",
"(",
"key",
",",
"value",
",",
"prop",
")",
"{",
"var",
"val",
"=",
"prop",
"?",
"get",
"(",
"value",
",",
"prop",
")",
":",
"value",
";",
"var",
"str",
"=",
"val",
"||",
"key",
";",
"var",
"re",
"=",
"/",
"^(\\d{4})-(\... | Get the date from a specified property or key.
@param {String} `key` Key used as the fallback when the property is not on the value.
@param {Object} `value` Object to use when finding the property.
@param {String} `prop` Property string to use to get the date.
@return {String} Date string in the format `YYYYMMDD` (... | [
"Get",
"the",
"date",
"from",
"a",
"specified",
"property",
"or",
"key",
"."
] | 7858a521be1d8f78c3cf37f058aef1d8a5b6414a | https://github.com/doowb/recent/blob/7858a521be1d8f78c3cf37f058aef1d8a5b6414a/index.js#L66-L74 | train |
AndreasMadsen/immortal | src/setup.js | printError | function printError(error) {
process.stderr.write(red);
console.error(error.trace);
process.stderr.write(yellow);
console.error('an error occurred, please file an issue');
process.stderr.write(reset);
process.exit(1);
} | javascript | function printError(error) {
process.stderr.write(red);
console.error(error.trace);
process.stderr.write(yellow);
console.error('an error occurred, please file an issue');
process.stderr.write(reset);
process.exit(1);
} | [
"function",
"printError",
"(",
"error",
")",
"{",
"process",
".",
"stderr",
".",
"write",
"(",
"red",
")",
";",
"console",
".",
"error",
"(",
"error",
".",
"trace",
")",
";",
"process",
".",
"stderr",
".",
"write",
"(",
"yellow",
")",
";",
"console",... | print error text | [
"print",
"error",
"text"
] | c1ab5a4287a543fdfd980604a9e9927d663a9ef2 | https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/src/setup.js#L61-L68 | train |
Nichejs/Seminarjs | private/lib/core/routes.js | routes | function routes(app) {
this.app = app;
var seminarjs = this;
app.get('/version', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({
'name': seminarjs.get('name'),
'seminarjsVersion': seminarjs.version
}));
});
return this;
} | javascript | function routes(app) {
this.app = app;
var seminarjs = this;
app.get('/version', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({
'name': seminarjs.get('name'),
'seminarjsVersion': seminarjs.version
}));
});
return this;
} | [
"function",
"routes",
"(",
"app",
")",
"{",
"this",
".",
"app",
"=",
"app",
";",
"var",
"seminarjs",
"=",
"this",
";",
"app",
".",
"get",
"(",
"'/version'",
",",
"function",
"(",
"req",
",",
"res",
")",
"{",
"res",
".",
"setHeader",
"(",
"'Content-... | Adds bindings for the seminarjs routes
####Example:
var app = express();
app.configure(...); // configuration settings
app.use(...); // middleware, routes, etc. should come before seminarjs is initialised
seminarjs.routes(app);
@param {Express()} app
@api public | [
"Adds",
"bindings",
"for",
"the",
"seminarjs",
"routes"
] | 53c4c1d5c33ffbf6320b10f25679bf181cbf853e | https://github.com/Nichejs/Seminarjs/blob/53c4c1d5c33ffbf6320b10f25679bf181cbf853e/private/lib/core/routes.js#L15-L30 | train |
sitegui/constant-equals | bench.js | getSimiliarString | function getSimiliarString(base, relation) {
var length = Math.round(base.length * relation),
r = '',
i, str
do {
str = getRandomString(base.length - length)
} while (str && str[0] === base[length])
for (i = 0; i < length; i++) {
r += base[i] // substr(...) seems to be optimized
}
return r + str
} | javascript | function getSimiliarString(base, relation) {
var length = Math.round(base.length * relation),
r = '',
i, str
do {
str = getRandomString(base.length - length)
} while (str && str[0] === base[length])
for (i = 0; i < length; i++) {
r += base[i] // substr(...) seems to be optimized
}
return r + str
} | [
"function",
"getSimiliarString",
"(",
"base",
",",
"relation",
")",
"{",
"var",
"length",
"=",
"Math",
".",
"round",
"(",
"base",
".",
"length",
"*",
"relation",
")",
",",
"r",
"=",
"''",
",",
"i",
",",
"str",
"do",
"{",
"str",
"=",
"getRandomString"... | Generate another string that has the same prefix and length as another one
@param {string} base
@param {number} relation A number from 0 (not equal at all) to 1 (equal strings)
@param {string} | [
"Generate",
"another",
"string",
"that",
"has",
"the",
"same",
"prefix",
"and",
"length",
"as",
"another",
"one"
] | c7e87815854250de3c76b5eea59dfd2586dd6a95 | https://github.com/sitegui/constant-equals/blob/c7e87815854250de3c76b5eea59dfd2586dd6a95/bench.js#L33-L44 | train |
sitegui/constant-equals | bench.js | compare | function compare(a, b, n) {
var n2 = n,
then = Date.now()
while (n2--) {
a === b
}
return (Date.now() - then) * 1e6 / n
} | javascript | function compare(a, b, n) {
var n2 = n,
then = Date.now()
while (n2--) {
a === b
}
return (Date.now() - then) * 1e6 / n
} | [
"function",
"compare",
"(",
"a",
",",
"b",
",",
"n",
")",
"{",
"var",
"n2",
"=",
"n",
",",
"then",
"=",
"Date",
".",
"now",
"(",
")",
"while",
"(",
"n2",
"--",
")",
"{",
"a",
"===",
"b",
"}",
"return",
"(",
"Date",
".",
"now",
"(",
")",
"... | Compute a==b n times
@param {string} a
@param {string} b
@param {number} n
@returns {number} The time per comparison (in ns) | [
"Compute",
"a",
"==",
"b",
"n",
"times"
] | c7e87815854250de3c76b5eea59dfd2586dd6a95 | https://github.com/sitegui/constant-equals/blob/c7e87815854250de3c76b5eea59dfd2586dd6a95/bench.js#L53-L60 | train |
sitegui/constant-equals | bench.js | constantCompare | function constantCompare(a, b, n) {
var n2 = n,
then = Date.now(),
eq = false,
len, i
while (n2--) {
len = Math.max(a.length, b.length)
for (i = 0; i < len; i++) {
if (a.length >= i && b.length >= i && a[i] !== b[i]) {
eq = false
}
}
}
return (Date.now() - then) * 1e6 / n
} | javascript | function constantCompare(a, b, n) {
var n2 = n,
then = Date.now(),
eq = false,
len, i
while (n2--) {
len = Math.max(a.length, b.length)
for (i = 0; i < len; i++) {
if (a.length >= i && b.length >= i && a[i] !== b[i]) {
eq = false
}
}
}
return (Date.now() - then) * 1e6 / n
} | [
"function",
"constantCompare",
"(",
"a",
",",
"b",
",",
"n",
")",
"{",
"var",
"n2",
"=",
"n",
",",
"then",
"=",
"Date",
".",
"now",
"(",
")",
",",
"eq",
"=",
"false",
",",
"len",
",",
"i",
"while",
"(",
"n2",
"--",
")",
"{",
"len",
"=",
"Ma... | Compute a==b n times with a constant algorithm
@param {string} a
@param {string} b
@param {number} n
@returns {number} The time per comparison (in ns) | [
"Compute",
"a",
"==",
"b",
"n",
"times",
"with",
"a",
"constant",
"algorithm"
] | c7e87815854250de3c76b5eea59dfd2586dd6a95 | https://github.com/sitegui/constant-equals/blob/c7e87815854250de3c76b5eea59dfd2586dd6a95/bench.js#L69-L83 | train |
sitegui/constant-equals | bench.js | stat | function stat(fn, n) {
var n2 = n,
times = [],
sum = 0,
t, avg, median
while (n2--) {
t = fn()
sum += t
times.push(t)
}
avg = sum / n
times.sort(function (a, b) {
return a - b
})
median = times[Math.floor(times.length / 2)]
if (times.length % 2 === 0) {
median = (median + times[times.length / 2 ... | javascript | function stat(fn, n) {
var n2 = n,
times = [],
sum = 0,
t, avg, median
while (n2--) {
t = fn()
sum += t
times.push(t)
}
avg = sum / n
times.sort(function (a, b) {
return a - b
})
median = times[Math.floor(times.length / 2)]
if (times.length % 2 === 0) {
median = (median + times[times.length / 2 ... | [
"function",
"stat",
"(",
"fn",
",",
"n",
")",
"{",
"var",
"n2",
"=",
"n",
",",
"times",
"=",
"[",
"]",
",",
"sum",
"=",
"0",
",",
"t",
",",
"avg",
",",
"median",
"while",
"(",
"n2",
"--",
")",
"{",
"t",
"=",
"fn",
"(",
")",
"sum",
"+=",
... | Make a statistical experiment on fn
@param {Function} fn A function that receives nothing and returns a number
@param {number} n Number of probes to takes
@returns {{avg: number, median: number}} | [
"Make",
"a",
"statistical",
"experiment",
"on",
"fn"
] | c7e87815854250de3c76b5eea59dfd2586dd6a95 | https://github.com/sitegui/constant-equals/blob/c7e87815854250de3c76b5eea59dfd2586dd6a95/bench.js#L91-L113 | train |
antonycourtney/tabli-core | lib/js/components/util.js | merge | function merge() {
var res = {};
for (var i = 0; i < arguments.length; i++) {
if (arguments[i]) {
Object.assign(res, arguments[i]);
} else {
if (typeof arguments[i] === 'undefined') {
throw new Error('m(): argument ' + i + ' undefined');
}
}
}
return res;
} | javascript | function merge() {
var res = {};
for (var i = 0; i < arguments.length; i++) {
if (arguments[i]) {
Object.assign(res, arguments[i]);
} else {
if (typeof arguments[i] === 'undefined') {
throw new Error('m(): argument ' + i + ' undefined');
}
}
}
return res;
} | [
"function",
"merge",
"(",
")",
"{",
"var",
"res",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"arguments",
"[",
"i",
"]",
")",
"{",
"Object",
".",
"as... | Object merge operator from the original css-in-js presentation | [
"Object",
"merge",
"operator",
"from",
"the",
"original",
"css",
"-",
"in",
"-",
"js",
"presentation"
] | 76cc540891421bc6c8bdcf00f277ebb6e716fdd9 | https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/lib/js/components/util.js#L11-L24 | train |
huang-xiao-jian/gulp-publish | index.js | publish | function publish(opts) {
// stream options
var defaults = {
enableResolve: false,
directory: './build',
debug: false
};
var options = utils.shallowMerge(opts, defaults);
return through(function(file, enc, callback) {
if (file.isNull()) return callback(null, file);
// emit error event whe... | javascript | function publish(opts) {
// stream options
var defaults = {
enableResolve: false,
directory: './build',
debug: false
};
var options = utils.shallowMerge(opts, defaults);
return through(function(file, enc, callback) {
if (file.isNull()) return callback(null, file);
// emit error event whe... | [
"function",
"publish",
"(",
"opts",
")",
"{",
"// stream options",
"var",
"defaults",
"=",
"{",
"enableResolve",
":",
"false",
",",
"directory",
":",
"'./build'",
",",
"debug",
":",
"false",
"}",
";",
"var",
"options",
"=",
"utils",
".",
"shallowMerge",
"(... | Return transform stream which resolve HTML files.
@param {object} opts - stream options
@returns {Stream} | [
"Return",
"transform",
"stream",
"which",
"resolve",
"HTML",
"files",
"."
] | a093c21c523becfe6869fda170efd1cca459c225 | https://github.com/huang-xiao-jian/gulp-publish/blob/a093c21c523becfe6869fda170efd1cca459c225/index.js#L22-L53 | train |
ConnorWiseman/pga | index.js | multiple | function multiple(pool, fn, queries, callback) {
let queryObjects = queries.map(query => {
if (typeof query === 'string') {
return { text: query, values: [] };
}
return Object.assign({ values: [] }, query);
});
if (callback && typeof callback === 'function') {
return fn(pool, queryObjects,... | javascript | function multiple(pool, fn, queries, callback) {
let queryObjects = queries.map(query => {
if (typeof query === 'string') {
return { text: query, values: [] };
}
return Object.assign({ values: [] }, query);
});
if (callback && typeof callback === 'function') {
return fn(pool, queryObjects,... | [
"function",
"multiple",
"(",
"pool",
",",
"fn",
",",
"queries",
",",
"callback",
")",
"{",
"let",
"queryObjects",
"=",
"queries",
".",
"map",
"(",
"query",
"=>",
"{",
"if",
"(",
"typeof",
"query",
"===",
"'string'",
")",
"{",
"return",
"{",
"text",
"... | Using the specified connection pool, performs the specified function using
a series of queries and a user-defined callback function.
@param {BoundPool} pool
@param {Function} fn
@param {Array.<Object>} queries
@param {Function} callback
@return {Promise}
@private | [
"Using",
"the",
"specified",
"connection",
"pool",
"performs",
"the",
"specified",
"function",
"using",
"a",
"series",
"of",
"queries",
"and",
"a",
"user",
"-",
"defined",
"callback",
"function",
"."
] | 5a186e1039ffe467f40755c6eae0f5deb38e7b41 | https://github.com/ConnorWiseman/pga/blob/5a186e1039ffe467f40755c6eae0f5deb38e7b41/index.js#L22-L44 | train |
ConnorWiseman/pga | index.js | normalize | function normalize(args) {
let result = {
queries: null,
callback: null
};
if (args.length === 1 && Array.isArray(args[0])) {
result.queries = args[0];
} else if (args.length === 2 && Array.isArray(args[0])) {
result.queries = args[0];
if (typeof args[1] === 'function') {
result.cal... | javascript | function normalize(args) {
let result = {
queries: null,
callback: null
};
if (args.length === 1 && Array.isArray(args[0])) {
result.queries = args[0];
} else if (args.length === 2 && Array.isArray(args[0])) {
result.queries = args[0];
if (typeof args[1] === 'function') {
result.cal... | [
"function",
"normalize",
"(",
"args",
")",
"{",
"let",
"result",
"=",
"{",
"queries",
":",
"null",
",",
"callback",
":",
"null",
"}",
";",
"if",
"(",
"args",
".",
"length",
"===",
"1",
"&&",
"Array",
".",
"isArray",
"(",
"args",
"[",
"0",
"]",
")... | Normalizes arguments passed to any of the pga methods that handle multiple
queries- parallel or transact.
@param {Array} args [description]
@return {Object}
@private | [
"Normalizes",
"arguments",
"passed",
"to",
"any",
"of",
"the",
"pga",
"methods",
"that",
"handle",
"multiple",
"queries",
"-",
"parallel",
"or",
"transact",
"."
] | 5a186e1039ffe467f40755c6eae0f5deb38e7b41 | https://github.com/ConnorWiseman/pga/blob/5a186e1039ffe467f40755c6eae0f5deb38e7b41/index.js#L54-L77 | train |
ConnorWiseman/pga | index.js | performParallel | function performParallel(pool, queries, callback) {
let count = 0,
results = new Array(queries.length);
queries.forEach((query, index) => {
pool.query(query, (error, result) => {
if (error) {
return callback(error, results);
}
results[index] = result;
if (++count === q... | javascript | function performParallel(pool, queries, callback) {
let count = 0,
results = new Array(queries.length);
queries.forEach((query, index) => {
pool.query(query, (error, result) => {
if (error) {
return callback(error, results);
}
results[index] = result;
if (++count === q... | [
"function",
"performParallel",
"(",
"pool",
",",
"queries",
",",
"callback",
")",
"{",
"let",
"count",
"=",
"0",
",",
"results",
"=",
"new",
"Array",
"(",
"queries",
".",
"length",
")",
";",
"queries",
".",
"forEach",
"(",
"(",
"query",
",",
"index",
... | Using the specified connection pool, performs a series of specified queries
in parallel, executing a specified callback function once all queries have
successfully completed.
@param {BoundPool} pool
@param {Array.<Object>} queries
@param {Function} callback
@private | [
"Using",
"the",
"specified",
"connection",
"pool",
"performs",
"a",
"series",
"of",
"specified",
"queries",
"in",
"parallel",
"executing",
"a",
"specified",
"callback",
"function",
"once",
"all",
"queries",
"have",
"successfully",
"completed",
"."
] | 5a186e1039ffe467f40755c6eae0f5deb38e7b41 | https://github.com/ConnorWiseman/pga/blob/5a186e1039ffe467f40755c6eae0f5deb38e7b41/index.js#L89-L106 | train |
ConnorWiseman/pga | index.js | performTransaction | function performTransaction(pool, queries, callback) {
pool.connect((error, client, done) => {
if (error) {
done(client);
return callback(error, null);
}
client.query('BEGIN', error => {
if (error) {
return rollback(client, done, error, callback);
}
sequence(queries... | javascript | function performTransaction(pool, queries, callback) {
pool.connect((error, client, done) => {
if (error) {
done(client);
return callback(error, null);
}
client.query('BEGIN', error => {
if (error) {
return rollback(client, done, error, callback);
}
sequence(queries... | [
"function",
"performTransaction",
"(",
"pool",
",",
"queries",
",",
"callback",
")",
"{",
"pool",
".",
"connect",
"(",
"(",
"error",
",",
"client",
",",
"done",
")",
"=>",
"{",
"if",
"(",
"error",
")",
"{",
"done",
"(",
"client",
")",
";",
"return",
... | Using the specified connection pool, performs a series of specified queries
using any specified parameters in sequence, finally executing a specified
callback function with any error or result. Will automatically rollback the
transaction if it fails and commit if it succeeds.
@param {BoundPool} pool
@param {Arra... | [
"Using",
"the",
"specified",
"connection",
"pool",
"performs",
"a",
"series",
"of",
"specified",
"queries",
"using",
"any",
"specified",
"parameters",
"in",
"sequence",
"finally",
"executing",
"a",
"specified",
"callback",
"function",
"with",
"any",
"error",
"or",... | 5a186e1039ffe467f40755c6eae0f5deb38e7b41 | https://github.com/ConnorWiseman/pga/blob/5a186e1039ffe467f40755c6eae0f5deb38e7b41/index.js#L119-L155 | train |
ConnorWiseman/pga | index.js | rollback | function rollback(client, done, error, callback) {
client.query('ROLLBACK', rollbackError => {
done(rollbackError);
return callback(rollbackError || error, null);
});
} | javascript | function rollback(client, done, error, callback) {
client.query('ROLLBACK', rollbackError => {
done(rollbackError);
return callback(rollbackError || error, null);
});
} | [
"function",
"rollback",
"(",
"client",
",",
"done",
",",
"error",
",",
"callback",
")",
"{",
"client",
".",
"query",
"(",
"'ROLLBACK'",
",",
"rollbackError",
"=>",
"{",
"done",
"(",
"rollbackError",
")",
";",
"return",
"callback",
"(",
"rollbackError",
"||... | Rolls back any failed transaction.
@param {Client} client
@param {Function} done
@param {Error} error
@param {Function} callback
@private | [
"Rolls",
"back",
"any",
"failed",
"transaction",
"."
] | 5a186e1039ffe467f40755c6eae0f5deb38e7b41 | https://github.com/ConnorWiseman/pga/blob/5a186e1039ffe467f40755c6eae0f5deb38e7b41/index.js#L166-L171 | train |
cli-kit/cli-property | lib/flatten.js | flatten | function flatten(source, opts) {
opts = opts || {};
var delimiter = opts.delimiter = opts.delimiter || '.';
var o = {};
function iterate(source, parts) {
var k, v;
parts = parts || [];
for(k in source) {
v = source[k];
if(v && typeof v === 'object' && Object.keys(v).length) {
ite... | javascript | function flatten(source, opts) {
opts = opts || {};
var delimiter = opts.delimiter = opts.delimiter || '.';
var o = {};
function iterate(source, parts) {
var k, v;
parts = parts || [];
for(k in source) {
v = source[k];
if(v && typeof v === 'object' && Object.keys(v).length) {
ite... | [
"function",
"flatten",
"(",
"source",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"delimiter",
"=",
"opts",
".",
"delimiter",
"=",
"opts",
".",
"delimiter",
"||",
"'.'",
";",
"var",
"o",
"=",
"{",
"}",
";",
"function",
... | Flatten an object joining keys on a dot delimiter.
Returns the transformed object.
@param source The source object to transform.
@param opts Processing options.
@param opts.delimiter The string to join keys on. | [
"Flatten",
"an",
"object",
"joining",
"keys",
"on",
"a",
"dot",
"delimiter",
"."
] | de6f727af1f8fc1f613fe42200c5e070aa6b0b21 | https://github.com/cli-kit/cli-property/blob/de6f727af1f8fc1f613fe42200c5e070aa6b0b21/lib/flatten.js#L10-L28 | train |
Ragnarokkr/grunt-bumpx | tasks/bump.js | isValidLevel | function isValidLevel ( level ) {
return reLevel.test( level ) || isFunction( level ) || Array.isArray( level );
} | javascript | function isValidLevel ( level ) {
return reLevel.test( level ) || isFunction( level ) || Array.isArray( level );
} | [
"function",
"isValidLevel",
"(",
"level",
")",
"{",
"return",
"reLevel",
".",
"test",
"(",
"level",
")",
"||",
"isFunction",
"(",
"level",
")",
"||",
"Array",
".",
"isArray",
"(",
"level",
")",
";",
"}"
] | To be valid, a `level` must be one of the values into `supportedLevels`, a function, or an array of functions. | [
"To",
"be",
"valid",
"a",
"level",
"must",
"be",
"one",
"of",
"the",
"values",
"into",
"supportedLevels",
"a",
"function",
"or",
"an",
"array",
"of",
"functions",
"."
] | 24b2f6730d35b9cea7b31c74cf709f501add67f8 | https://github.com/Ragnarokkr/grunt-bumpx/blob/24b2f6730d35b9cea7b31c74cf709f501add67f8/tasks/bump.js#L75-L77 | train |
Ragnarokkr/grunt-bumpx | tasks/bump.js | printMsg | function printMsg ( msgId, data ) {
var outputFn;
if ( messages.hasOwnProperty( msgId) ) {
switch ( msgId.match( /^[A-Z]+/ )[0] ) {
case 'INFO':
outputFn = grunt.log.writeln;
break;
case 'VERBOSE':
outputFn = grunt.verbose.writeln;
break;
... | javascript | function printMsg ( msgId, data ) {
var outputFn;
if ( messages.hasOwnProperty( msgId) ) {
switch ( msgId.match( /^[A-Z]+/ )[0] ) {
case 'INFO':
outputFn = grunt.log.writeln;
break;
case 'VERBOSE':
outputFn = grunt.verbose.writeln;
break;
... | [
"function",
"printMsg",
"(",
"msgId",
",",
"data",
")",
"{",
"var",
"outputFn",
";",
"if",
"(",
"messages",
".",
"hasOwnProperty",
"(",
"msgId",
")",
")",
"{",
"switch",
"(",
"msgId",
".",
"match",
"(",
"/",
"^[A-Z]+",
"/",
")",
"[",
"0",
"]",
")",... | Prints out a message according to the type of message ID. | [
"Prints",
"out",
"a",
"message",
"according",
"to",
"the",
"type",
"of",
"message",
"ID",
"."
] | 24b2f6730d35b9cea7b31c74cf709f501add67f8 | https://github.com/Ragnarokkr/grunt-bumpx/blob/24b2f6730d35b9cea7b31c74cf709f501add67f8/tasks/bump.js#L84-L107 | train |
jimf/checkstyle-formatter | index.js | formatMessage | function formatMessage (message) {
return '<error' +
attr(message, 'line') +
attr(message, 'column') +
attr(message, 'severity') +
attr(message, 'message') +
('source' in message ? attr(message, 'source') : '') +
' />'
} | javascript | function formatMessage (message) {
return '<error' +
attr(message, 'line') +
attr(message, 'column') +
attr(message, 'severity') +
attr(message, 'message') +
('source' in message ? attr(message, 'source') : '') +
' />'
} | [
"function",
"formatMessage",
"(",
"message",
")",
"{",
"return",
"'<error'",
"+",
"attr",
"(",
"message",
",",
"'line'",
")",
"+",
"attr",
"(",
"message",
",",
"'column'",
")",
"+",
"attr",
"(",
"message",
",",
"'severity'",
")",
"+",
"attr",
"(",
"mes... | Format error line.
@param {object} message Message object to format
@return {string} | [
"Format",
"error",
"line",
"."
] | d4ce7e332552b4ec46cd90e9f1c2e08e19f0b832 | https://github.com/jimf/checkstyle-formatter/blob/d4ce7e332552b4ec46cd90e9f1c2e08e19f0b832/index.js#L25-L33 | train |
jimf/checkstyle-formatter | index.js | formatResult | function formatResult (result) {
return [
'<file name="' + result.filename + '">',
result.messages.map(formatMessage).join('\n'),
'</file>'
].join('\n')
} | javascript | function formatResult (result) {
return [
'<file name="' + result.filename + '">',
result.messages.map(formatMessage).join('\n'),
'</file>'
].join('\n')
} | [
"function",
"formatResult",
"(",
"result",
")",
"{",
"return",
"[",
"'<file name=\"'",
"+",
"result",
".",
"filename",
"+",
"'\">'",
",",
"result",
".",
"messages",
".",
"map",
"(",
"formatMessage",
")",
".",
"join",
"(",
"'\\n'",
")",
",",
"'</file>'",
... | Format results for a single file.
@param {object} result Results for a single file
@param {string} result.filename Filename for these results
@param {object[]} result.messages Warnings/errors for file
@return {string} XML representation for file and results | [
"Format",
"results",
"for",
"a",
"single",
"file",
"."
] | d4ce7e332552b4ec46cd90e9f1c2e08e19f0b832 | https://github.com/jimf/checkstyle-formatter/blob/d4ce7e332552b4ec46cd90e9f1c2e08e19f0b832/index.js#L43-L49 | train |
piranna/easy-coveralls | index.js | restoreLib | function restoreLib(err1)
{
fs.move(ORIG, LIB, {clobber: true}, function(err2)
{
callback(err1 || err2)
})
} | javascript | function restoreLib(err1)
{
fs.move(ORIG, LIB, {clobber: true}, function(err2)
{
callback(err1 || err2)
})
} | [
"function",
"restoreLib",
"(",
"err1",
")",
"{",
"fs",
".",
"move",
"(",
"ORIG",
",",
"LIB",
",",
"{",
"clobber",
":",
"true",
"}",
",",
"function",
"(",
"err2",
")",
"{",
"callback",
"(",
"err1",
"||",
"err2",
")",
"}",
")",
"}"
] | Restore original not-instrumented library | [
"Restore",
"original",
"not",
"-",
"instrumented",
"library"
] | c4e67d769365e3decbf6b48deea48644196ce1cc | https://github.com/piranna/easy-coveralls/blob/c4e67d769365e3decbf6b48deea48644196ce1cc/index.js#L48-L54 | train |
phun-ky/patsy | lib/patsy.js | function(chunk) {
var patsy = this;
chunk = chunk.trim();
if(chunk == 'exit'){
this.scripture.print('[King Arthur]'.magenta + ': On second thought, let\'s not go to Camelot, it\'s a silly place. I am leaving you behind squire!\n');
program.prompt('[Patsy]'.cyan + ': Sire, do you ... | javascript | function(chunk) {
var patsy = this;
chunk = chunk.trim();
if(chunk == 'exit'){
this.scripture.print('[King Arthur]'.magenta + ': On second thought, let\'s not go to Camelot, it\'s a silly place. I am leaving you behind squire!\n');
program.prompt('[Patsy]'.cyan + ': Sire, do you ... | [
"function",
"(",
"chunk",
")",
"{",
"var",
"patsy",
"=",
"this",
";",
"chunk",
"=",
"chunk",
".",
"trim",
"(",
")",
";",
"if",
"(",
"chunk",
"==",
"'exit'",
")",
"{",
"this",
".",
"scripture",
".",
"print",
"(",
"'[King Arthur]'",
".",
"magenta",
"... | Function to check current input from stdin
@param String chunk
@calls this.die | [
"Function",
"to",
"check",
"current",
"input",
"from",
"stdin"
] | b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5 | https://github.com/phun-ky/patsy/blob/b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5/lib/patsy.js#L245-L291 | train | |
phun-ky/patsy | lib/patsy.js | function(relativeProjectPath, relative){
var src = [];
var complete_path;
var patsy = this;
if(patsy.utils.isArray(relative)){
// For each path, check if path is negated, if it is, remove negation
relative.forEach(function(_path){
if(patsy.utils.isPathNegated(_path))... | javascript | function(relativeProjectPath, relative){
var src = [];
var complete_path;
var patsy = this;
if(patsy.utils.isArray(relative)){
// For each path, check if path is negated, if it is, remove negation
relative.forEach(function(_path){
if(patsy.utils.isPathNegated(_path))... | [
"function",
"(",
"relativeProjectPath",
",",
"relative",
")",
"{",
"var",
"src",
"=",
"[",
"]",
";",
"var",
"complete_path",
";",
"var",
"patsy",
"=",
"this",
";",
"if",
"(",
"patsy",
".",
"utils",
".",
"isArray",
"(",
"relative",
")",
")",
"{",
"// ... | Update relative paths
@param String relativeProjectPah
@param String|Array relative | [
"Update",
"relative",
"paths"
] | b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5 | https://github.com/phun-ky/patsy/blob/b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5/lib/patsy.js#L723-L762 | train | |
phun-ky/patsy | lib/patsy.js | function(how){
var _child, _cfg, patsy = this;
var _execCmd = [];
if(typeof this.project_cfg.project === 'undefined'){
/**
* Require config from the library
*
* @var Object
* @source patsy
*/
var config = require('./config')({
... | javascript | function(how){
var _child, _cfg, patsy = this;
var _execCmd = [];
if(typeof this.project_cfg.project === 'undefined'){
/**
* Require config from the library
*
* @var Object
* @source patsy
*/
var config = require('./config')({
... | [
"function",
"(",
"how",
")",
"{",
"var",
"_child",
",",
"_cfg",
",",
"patsy",
"=",
"this",
";",
"var",
"_execCmd",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"this",
".",
"project_cfg",
".",
"project",
"===",
"'undefined'",
")",
"{",
"/**\n * Req... | Runs grunt tasks
@param String how | [
"Runs",
"grunt",
"tasks"
] | b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5 | https://github.com/phun-ky/patsy/blob/b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5/lib/patsy.js#L768-L843 | train | |
syaning/zhimg | index.js | Image | function Image(src) {
if (!(this instanceof Image)) {
return new Image(src)
}
if (typeof src !== 'string') {
throw new Error('param `src` must be a string')
}
var ret = reg.exec(src)
if (!ret) {
throw new Error('invalid param `src`')
}
this.src = src
this.host = ret[1] || defaultHost
... | javascript | function Image(src) {
if (!(this instanceof Image)) {
return new Image(src)
}
if (typeof src !== 'string') {
throw new Error('param `src` must be a string')
}
var ret = reg.exec(src)
if (!ret) {
throw new Error('invalid param `src`')
}
this.src = src
this.host = ret[1] || defaultHost
... | [
"function",
"Image",
"(",
"src",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Image",
")",
")",
"{",
"return",
"new",
"Image",
"(",
"src",
")",
"}",
"if",
"(",
"typeof",
"src",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"... | Initialize `Image` with given `src`.
@param {String} src
@public | [
"Initialize",
"Image",
"with",
"given",
"src",
"."
] | d63658f67a39ee0804ab61a6890c997a58e3c38e | https://github.com/syaning/zhimg/blob/d63658f67a39ee0804ab61a6890c997a58e3c38e/index.js#L12-L32 | train |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function ($placeholder, file, that) {
$.ajax({
type: "post",
url: that.options.imagesUploadScript,
xhr: function () {
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = that.updateProgressBar;
return xhr;
},
cache: false,
contentType: false,
complete: functi... | javascript | function ($placeholder, file, that) {
$.ajax({
type: "post",
url: that.options.imagesUploadScript,
xhr: function () {
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = that.updateProgressBar;
return xhr;
},
cache: false,
contentType: false,
complete: functi... | [
"function",
"(",
"$placeholder",
",",
"file",
",",
"that",
")",
"{",
"$",
".",
"ajax",
"(",
"{",
"type",
":",
"\"post\"",
",",
"url",
":",
"that",
".",
"options",
".",
"imagesUploadScript",
",",
"xhr",
":",
"function",
"(",
")",
"{",
"var",
"xhr",
... | Upload single file
@param {element} $placeholder Placeholder to add image to
@param {File} file File to upload
@param {object} that Context
@param {void} | [
"Upload",
"single",
"file"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L45-L62 | train | |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (file, that) {
$.ajax({
type: "post",
url: that.options.imagesDeleteScript,
data: {
file: file
}
});
} | javascript | function (file, that) {
$.ajax({
type: "post",
url: that.options.imagesDeleteScript,
data: {
file: file
}
});
} | [
"function",
"(",
"file",
",",
"that",
")",
"{",
"$",
".",
"ajax",
"(",
"{",
"type",
":",
"\"post\"",
",",
"url",
":",
"that",
".",
"options",
".",
"imagesDeleteScript",
",",
"data",
":",
"{",
"file",
":",
"file",
"}",
"}",
")",
";",
"}"
] | Makes ajax call for deleting a file on a server
@param {string} file File name
@param {object} that Context
@return {void} | [
"Makes",
"ajax",
"call",
"for",
"deleting",
"a",
"file",
"on",
"a",
"server"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L71-L79 | train | |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (options) {
if (options && options.$el) {
this.$el = options.$el;
}
this.options = $.extend(this.defaults, options);
this.setImageEvents();
if (this.options.useDragAndDrop === true){
this.setDragAndDropEvents();
}
this.preparePreviousImages();
} | javascript | function (options) {
if (options && options.$el) {
this.$el = options.$el;
}
this.options = $.extend(this.defaults, options);
this.setImageEvents();
if (this.options.useDragAndDrop === true){
this.setDragAndDropEvents();
}
this.preparePreviousImages();
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"$el",
")",
"{",
"this",
".",
"$el",
"=",
"options",
".",
"$el",
";",
"}",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"this",
".",
"defaults",
",",
"opti... | Images initial function
@param {object} options Options to overide defaults
@return {void} | [
"Images",
"initial",
"function"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L90-L104 | train | |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function(buttonLabels){
var label = 'Img';
if (buttonLabels === 'fontawesome' || typeof buttonLabels === 'object' && !!(buttonLabels.fontawesome)) {
label = '<i class="fa fa-picture-o"></i>';
}
if (typeof buttonLabels === 'object' && buttonLabels.img) {
label = buttonLabels.img;
}
return ... | javascript | function(buttonLabels){
var label = 'Img';
if (buttonLabels === 'fontawesome' || typeof buttonLabels === 'object' && !!(buttonLabels.fontawesome)) {
label = '<i class="fa fa-picture-o"></i>';
}
if (typeof buttonLabels === 'object' && buttonLabels.img) {
label = buttonLabels.img;
}
return ... | [
"function",
"(",
"buttonLabels",
")",
"{",
"var",
"label",
"=",
"'Img'",
";",
"if",
"(",
"buttonLabels",
"===",
"'fontawesome'",
"||",
"typeof",
"buttonLabels",
"===",
"'object'",
"&&",
"!",
"!",
"(",
"buttonLabels",
".",
"fontawesome",
")",
")",
"{",
"lab... | Returns insert button
@param {string} buttonLabels
@return {string} | [
"Returns",
"insert",
"button"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L114-L125 | train | |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function ($placeholder) {
var that = this,
$selectFile, files;
$selectFile = $('<input type="file" multiple="multiple">').click();
$selectFile.change(function () {
files = this.files;
that.uploadFiles($placeholder, files, that);
});
$.fn.mediumInsert.insert.deselect();
return $selectFi... | javascript | function ($placeholder) {
var that = this,
$selectFile, files;
$selectFile = $('<input type="file" multiple="multiple">').click();
$selectFile.change(function () {
files = this.files;
that.uploadFiles($placeholder, files, that);
});
$.fn.mediumInsert.insert.deselect();
return $selectFi... | [
"function",
"(",
"$placeholder",
")",
"{",
"var",
"that",
"=",
"this",
",",
"$selectFile",
",",
"files",
";",
"$selectFile",
"=",
"$",
"(",
"'<input type=\"file\" multiple=\"multiple\">'",
")",
".",
"click",
"(",
")",
";",
"$selectFile",
".",
"change",
"(",
... | Add image to placeholder
@param {element} $placeholder Placeholder to add image to
@return {element} $selectFile <input type="file"> element | [
"Add",
"image",
"to",
"placeholder"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L149-L162 | train | |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (e) {
var $progress = $('.progress:first', this.$el),
complete;
if (e.lengthComputable) {
complete = e.loaded / e.total * 100;
complete = complete ? complete : 0;
$progress.attr('value', complete);
$progress.html(complete);
}
} | javascript | function (e) {
var $progress = $('.progress:first', this.$el),
complete;
if (e.lengthComputable) {
complete = e.loaded / e.total * 100;
complete = complete ? complete : 0;
$progress.attr('value', complete);
$progress.html(complete);
}
} | [
"function",
"(",
"e",
")",
"{",
"var",
"$progress",
"=",
"$",
"(",
"'.progress:first'",
",",
"this",
".",
"$el",
")",
",",
"complete",
";",
"if",
"(",
"e",
".",
"lengthComputable",
")",
"{",
"complete",
"=",
"e",
".",
"loaded",
"/",
"e",
".",
"tota... | Update progressbar while upload
@param {event} e XMLHttpRequest.upload.onprogress event
@return {void} | [
"Update",
"progressbar",
"while",
"upload"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L171-L181 | train | |
skerit/alchemy-styleboost | assets/scripts/medium-insert/images.js | function (jqxhr, $placeholder) {
var $progress = $('.progress:first', $placeholder),
$img;
$progress.attr('value', 100);
$progress.html(100);
if (jqxhr.responseText) {
$progress.before('<figure class="mediumInsert-images"><img src="'+ jqxhr.responseText +'" draggable="true" alt=""></figure>');
... | javascript | function (jqxhr, $placeholder) {
var $progress = $('.progress:first', $placeholder),
$img;
$progress.attr('value', 100);
$progress.html(100);
if (jqxhr.responseText) {
$progress.before('<figure class="mediumInsert-images"><img src="'+ jqxhr.responseText +'" draggable="true" alt=""></figure>');
... | [
"function",
"(",
"jqxhr",
",",
"$placeholder",
")",
"{",
"var",
"$progress",
"=",
"$",
"(",
"'.progress:first'",
",",
"$placeholder",
")",
",",
"$img",
";",
"$progress",
".",
"attr",
"(",
"'value'",
",",
"100",
")",
";",
"$progress",
".",
"html",
"(",
... | Show uploaded image after upload completed
@param {jqXHR} jqxhr jqXHR object
@return {void} | [
"Show",
"uploaded",
"image",
"after",
"upload",
"completed"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/images.js#L190-L217 | train | |
mgesmundo/authorify-client | lib/class/Store.js | function(key, callback) {
if (key) {
this.store.proxy.remove(this.prefix + key);
if (callback) {
callback(null, key);
}
} else {
if (callback) {
callback('missing key');
}
}
} | javascript | function(key, callback) {
if (key) {
this.store.proxy.remove(this.prefix + key);
if (callback) {
callback(null, key);
}
} else {
if (callback) {
callback('missing key');
}
}
} | [
"function",
"(",
"key",
",",
"callback",
")",
"{",
"if",
"(",
"key",
")",
"{",
"this",
".",
"store",
".",
"proxy",
".",
"remove",
"(",
"this",
".",
"prefix",
"+",
"key",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
"null",
",",
"... | Destroy a stored item
@param {String} key The key of the item
@param {Function} callback Function called when the operation is done
@return {callback(err, key)} The callback to execute as result
@param {String} callback.err Error if occurred
@param {String} callback.key The key of the destroyed item | [
"Destroy",
"a",
"stored",
"item"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Store.js#L53-L64 | train | |
mgesmundo/authorify-client | lib/class/Store.js | function(key, callback) {
if (key) {
var _data = this.store.proxy.get(this.prefix + key),
data;
if ('undefined' !== typeof window) {
// browser
try {
data = JSON.parse(_data);
} catch (e) {
data = _data;
}
} else {... | javascript | function(key, callback) {
if (key) {
var _data = this.store.proxy.get(this.prefix + key),
data;
if ('undefined' !== typeof window) {
// browser
try {
data = JSON.parse(_data);
} catch (e) {
data = _data;
}
} else {... | [
"function",
"(",
"key",
",",
"callback",
")",
"{",
"if",
"(",
"key",
")",
"{",
"var",
"_data",
"=",
"this",
".",
"store",
".",
"proxy",
".",
"get",
"(",
"this",
".",
"prefix",
"+",
"key",
")",
",",
"data",
";",
"if",
"(",
"'undefined'",
"!==",
... | Load stored item
@param {String} key The key of the item
@param {Function} callback Function called when the item is loaded
@return {callback(err, data)} The callback to execute as result
@param {String} callback.err Error if occurred
@param {Object} callback.data The loaded item | [
"Load",
"stored",
"item"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Store.js#L74-L92 | train | |
mgesmundo/authorify-client | lib/class/Store.js | function(key, data, callback) {
if (key) {
if (data) {
var _data = data;
if ('undefined' !== typeof window && 'object' === typeof data) {
_data = JSON.stringify(_data);
}
this.store.proxy.set(this.prefix + key, _data);
callback(null);
}... | javascript | function(key, data, callback) {
if (key) {
if (data) {
var _data = data;
if ('undefined' !== typeof window && 'object' === typeof data) {
_data = JSON.stringify(_data);
}
this.store.proxy.set(this.prefix + key, _data);
callback(null);
}... | [
"function",
"(",
"key",
",",
"data",
",",
"callback",
")",
"{",
"if",
"(",
"key",
")",
"{",
"if",
"(",
"data",
")",
"{",
"var",
"_data",
"=",
"data",
";",
"if",
"(",
"'undefined'",
"!==",
"typeof",
"window",
"&&",
"'object'",
"===",
"typeof",
"data... | Save an item
@param {String} key The key of the item
@param {Object} data The item
@param {Function} callback Function called when the session is saved
@return {callback(err)} The callback to execute as result
@param {String} callback.status Result from Redis query | [
"Save",
"an",
"item"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Store.js#L102-L117 | train | |
docvy/plugin-installer | lib/cli.js | list | function list() {
return installer.listPlugins(function(listErr, plugins) {
if (listErr) {
return out.error("error listing installed plugins: %s", listErr);
}
if (plugins.length === 0) {
return out.success("no plugins found");
}
var string = "";
for (var idx = 0; idx < plugins.leng... | javascript | function list() {
return installer.listPlugins(function(listErr, plugins) {
if (listErr) {
return out.error("error listing installed plugins: %s", listErr);
}
if (plugins.length === 0) {
return out.success("no plugins found");
}
var string = "";
for (var idx = 0; idx < plugins.leng... | [
"function",
"list",
"(",
")",
"{",
"return",
"installer",
".",
"listPlugins",
"(",
"function",
"(",
"listErr",
",",
"plugins",
")",
"{",
"if",
"(",
"listErr",
")",
"{",
"return",
"out",
".",
"error",
"(",
"\"error listing installed plugins: %s\"",
",",
"list... | listing installed plugins | [
"listing",
"installed",
"plugins"
] | eb645eb21f350a0fbbf783d83b25ab18feeee684 | https://github.com/docvy/plugin-installer/blob/eb645eb21f350a0fbbf783d83b25ab18feeee684/lib/cli.js#L36-L51 | train |
pierrec/node-atok | lib/tokenizer.js | resolveId | function resolveId (prop) {
if (rule[prop] === null || typeof rule[prop] === 'number') return
// Resolve the property to an index
var j = self._getRuleIndex(rule.id)
if (j < 0)
self._error( new Error('Atok#_resolveRules: ' + prop + '() value not found: ' + rule.id) )
rule[prop] = i - j... | javascript | function resolveId (prop) {
if (rule[prop] === null || typeof rule[prop] === 'number') return
// Resolve the property to an index
var j = self._getRuleIndex(rule.id)
if (j < 0)
self._error( new Error('Atok#_resolveRules: ' + prop + '() value not found: ' + rule.id) )
rule[prop] = i - j... | [
"function",
"resolveId",
"(",
"prop",
")",
"{",
"if",
"(",
"rule",
"[",
"prop",
"]",
"===",
"null",
"||",
"typeof",
"rule",
"[",
"prop",
"]",
"===",
"'number'",
")",
"return",
"// Resolve the property to an index",
"var",
"j",
"=",
"self",
".",
"_getRuleIn... | Perform various checks on a continue type property | [
"Perform",
"various",
"checks",
"on",
"a",
"continue",
"type",
"property"
] | abe139e7fa8c092d87e528289b6abd9083df2323 | https://github.com/pierrec/node-atok/blob/abe139e7fa8c092d87e528289b6abd9083df2323/lib/tokenizer.js#L759-L768 | train |
repetere/stylie.modals | lib/stylie.modals.js | function (options) {
events.EventEmitter.call(this);
// this.el = el;
this.options = extend(this.options, options);
// console.log(this.options);
this._init();
this.show = this._show;
this.hide = this._hide;
} | javascript | function (options) {
events.EventEmitter.call(this);
// this.el = el;
this.options = extend(this.options, options);
// console.log(this.options);
this._init();
this.show = this._show;
this.hide = this._hide;
} | [
"function",
"(",
"options",
")",
"{",
"events",
".",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"// this.el = el;",
"this",
".",
"options",
"=",
"extend",
"(",
"this",
".",
"options",
",",
"options",
")",
";",
"// console.log(this.options);",
"this"... | A module that represents a StylieModals object, a componentTab is a page composition tool.
@{@link https://github.com/typesettin/stylie.modals}
@author Yaw Joseph Etse
@copyright Copyright (c) 2014 Typesettin. All rights reserved.
@license MIT
@constructor StylieModals
@requires module:util-extent
@requires module:util... | [
"A",
"module",
"that",
"represents",
"a",
"StylieModals",
"object",
"a",
"componentTab",
"is",
"a",
"page",
"composition",
"tool",
"."
] | a27238e4a3c27fc7761e92d449fe6d1967f1fffb | https://github.com/repetere/stylie.modals/blob/a27238e4a3c27fc7761e92d449fe6d1967f1fffb/lib/stylie.modals.js#L28-L37 | train | |
arpinum-oss/js-promising | benchmarks/compose.js | createFunctions | function createFunctions() {
const result = [];
for (let i = 0; i < count; i++) {
result.push(number => Promise.resolve(number + 1));
}
return result;
} | javascript | function createFunctions() {
const result = [];
for (let i = 0; i < count; i++) {
result.push(number => Promise.resolve(number + 1));
}
return result;
} | [
"function",
"createFunctions",
"(",
")",
"{",
"const",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"result",
".",
"push",
"(",
"number",
"=>",
"Promise",
".",
"resolve",
"(",
... | 100000 functions handled in 267 ms | [
"100000",
"functions",
"handled",
"in",
"267",
"ms"
] | 710712e7d2b1429bda92d21c420d79d16cc6160a | https://github.com/arpinum-oss/js-promising/blob/710712e7d2b1429bda92d21c420d79d16cc6160a/benchmarks/compose.js#L13-L19 | train |
willmark/http-handler | index.js | function(filepath, req, res) {
var path = require("path"),
config = module.exports.config,
result = false,
parentdir;
do {
var defaultdir = path.resolve(path.join(config.responsesdefault, filepath));
parentdir = path.resolve(path.join(config.responses, filepath));
... | javascript | function(filepath, req, res) {
var path = require("path"),
config = module.exports.config,
result = false,
parentdir;
do {
var defaultdir = path.resolve(path.join(config.responsesdefault, filepath));
parentdir = path.resolve(path.join(config.responses, filepath));
... | [
"function",
"(",
"filepath",
",",
"req",
",",
"res",
")",
"{",
"var",
"path",
"=",
"require",
"(",
"\"path\"",
")",
",",
"config",
"=",
"module",
".",
"exports",
".",
"config",
",",
"result",
"=",
"false",
",",
"parentdir",
";",
"do",
"{",
"var",
"... | Join responses root folder to requested sub-directory
id - sub-folder path
req - http request http.IncomingMessage
res - http response http.ServerResponse | [
"Join",
"responses",
"root",
"folder",
"to",
"requested",
"sub",
"-",
"directory",
"id",
"-",
"sub",
"-",
"folder",
"path",
"req",
"-",
"http",
"request",
"http",
".",
"IncomingMessage",
"res",
"-",
"http",
"response",
"http",
".",
"ServerResponse"
] | 63defe72de0214f34500d3d9db75807014f5d134 | https://github.com/willmark/http-handler/blob/63defe72de0214f34500d3d9db75807014f5d134/index.js#L36-L57 | train | |
psastras/swag2blue | index.js | convert | function convert(swagger, done) {
fury.parse({source: swagger}, function (parseErr, res) {
if (parseErr) {
return done(parseErr);
}
fury.serialize({api: res.api}, function (serializeErr, blueprint) {
if (serializeErr) {
return done(serializeErr);
}
done(null, blueprint);
... | javascript | function convert(swagger, done) {
fury.parse({source: swagger}, function (parseErr, res) {
if (parseErr) {
return done(parseErr);
}
fury.serialize({api: res.api}, function (serializeErr, blueprint) {
if (serializeErr) {
return done(serializeErr);
}
done(null, blueprint);
... | [
"function",
"convert",
"(",
"swagger",
",",
"done",
")",
"{",
"fury",
".",
"parse",
"(",
"{",
"source",
":",
"swagger",
"}",
",",
"function",
"(",
"parseErr",
",",
"res",
")",
"{",
"if",
"(",
"parseErr",
")",
"{",
"return",
"done",
"(",
"parseErr",
... | Take a loaded Swagger object and converts it to API Blueprint | [
"Take",
"a",
"loaded",
"Swagger",
"object",
"and",
"converts",
"it",
"to",
"API",
"Blueprint"
] | 443f0703a6b60ed3da9b5cebfa4a9c1f167a9718 | https://github.com/psastras/swag2blue/blob/443f0703a6b60ed3da9b5cebfa4a9c1f167a9718/index.js#L25-L38 | train |
psastras/swag2blue | index.js | run | function run(argv, done) {
if (!argv) {
argv = parser.argv;
}
if (argv.h) {
parser.showHelp();
return done(null);
}
if (!argv._.length) {
return done(new Error('Requires an input argument'));
} else if (argv._.length > 2) {
return done(new Error('Too many arguments given!'));
}
va... | javascript | function run(argv, done) {
if (!argv) {
argv = parser.argv;
}
if (argv.h) {
parser.showHelp();
return done(null);
}
if (!argv._.length) {
return done(new Error('Requires an input argument'));
} else if (argv._.length > 2) {
return done(new Error('Too many arguments given!'));
}
va... | [
"function",
"run",
"(",
"argv",
",",
"done",
")",
"{",
"if",
"(",
"!",
"argv",
")",
"{",
"argv",
"=",
"parser",
".",
"argv",
";",
"}",
"if",
"(",
"argv",
".",
"h",
")",
"{",
"parser",
".",
"showHelp",
"(",
")",
";",
"return",
"done",
"(",
"nu... | Run the command with the given arguments. | [
"Run",
"the",
"command",
"with",
"the",
"given",
"arguments",
"."
] | 443f0703a6b60ed3da9b5cebfa4a9c1f167a9718 | https://github.com/psastras/swag2blue/blob/443f0703a6b60ed3da9b5cebfa4a9c1f167a9718/index.js#L41-L78 | train |
trevorparscal/node-palo | lib/resources/ModuleResource.js | ModuleResource | function ModuleResource( pkg, config ) {
// Parent constructor
ModuleResource.super.call( this, pkg, config );
// Properties
this.imports = config.imports || null;
this.exports = config.exports || null;
this.propertyNamePattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
} | javascript | function ModuleResource( pkg, config ) {
// Parent constructor
ModuleResource.super.call( this, pkg, config );
// Properties
this.imports = config.imports || null;
this.exports = config.exports || null;
this.propertyNamePattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
} | [
"function",
"ModuleResource",
"(",
"pkg",
",",
"config",
")",
"{",
"// Parent constructor",
"ModuleResource",
".",
"super",
".",
"call",
"(",
"this",
",",
"pkg",
",",
"config",
")",
";",
"// Properties",
"this",
".",
"imports",
"=",
"config",
".",
"imports",... | JavaScript module resource.
@class
@extends {FileResource}
@constructor
@param {Package} pkg Package this resource is part of
@param {Object|string[]|string} config Resource configuration or one or more resource file paths | [
"JavaScript",
"module",
"resource",
"."
] | 425efdcf027c71296c732765afdf5cacae6a1a3e | https://github.com/trevorparscal/node-palo/blob/425efdcf027c71296c732765afdf5cacae6a1a3e/lib/resources/ModuleResource.js#L15-L23 | train |
kaelzhang/node-commonjs-walker | lib/walker.js | init | function init (done) {
var node = tools.match_ext(filename, 'node')
var json = tools.match_ext(filename, 'json')
done(null, {
content: content,
json: json,
node: node,
// all other files are considered as javascript files.
js: !node && !json,
})
} | javascript | function init (done) {
var node = tools.match_ext(filename, 'node')
var json = tools.match_ext(filename, 'json')
done(null, {
content: content,
json: json,
node: node,
// all other files are considered as javascript files.
js: !node && !json,
})
} | [
"function",
"init",
"(",
"done",
")",
"{",
"var",
"node",
"=",
"tools",
".",
"match_ext",
"(",
"filename",
",",
"'node'",
")",
"var",
"json",
"=",
"tools",
".",
"match_ext",
"(",
"filename",
",",
"'json'",
")",
"done",
"(",
"null",
",",
"{",
"content... | If no registered compilers, just return | [
"If",
"no",
"registered",
"compilers",
"just",
"return"
] | d96b3b56ffa9efb2eaa33e67c91d32622f79ea37 | https://github.com/kaelzhang/node-commonjs-walker/blob/d96b3b56ffa9efb2eaa33e67c91d32622f79ea37/lib/walker.js#L242-L253 | train |
medic/couchdb-audit | couchdb-audit/kanso.js | function(db, auditDb) {
var dbWrapper = getDbWrapper(db);
var auditDbWrapper;
if (auditDb) {
auditDbWrapper = getDbWrapper(auditDb);
} else {
auditDbWrapper = dbWrapper;
}
var clientWrapper = {
uuids: function(count, callback) {
db.newUUID.call(db, 100, function(err, i... | javascript | function(db, auditDb) {
var dbWrapper = getDbWrapper(db);
var auditDbWrapper;
if (auditDb) {
auditDbWrapper = getDbWrapper(auditDb);
} else {
auditDbWrapper = dbWrapper;
}
var clientWrapper = {
uuids: function(count, callback) {
db.newUUID.call(db, 100, function(err, i... | [
"function",
"(",
"db",
",",
"auditDb",
")",
"{",
"var",
"dbWrapper",
"=",
"getDbWrapper",
"(",
"db",
")",
";",
"var",
"auditDbWrapper",
";",
"if",
"(",
"auditDb",
")",
"{",
"auditDbWrapper",
"=",
"getDbWrapper",
"(",
"auditDb",
")",
";",
"}",
"else",
"... | Sets up auditing to work with the kanso db module.
@name withKanso(db)
@param {Object} db The kanso db instance to use.
@param {Object} auditDb Optionally the kanso db instance to use for auditing.
@api public | [
"Sets",
"up",
"auditing",
"to",
"work",
"with",
"the",
"kanso",
"db",
"module",
"."
] | 88a2fde06830e91966fc82c7356ec46da043fc01 | https://github.com/medic/couchdb-audit/blob/88a2fde06830e91966fc82c7356ec46da043fc01/couchdb-audit/kanso.js#L35-L60 | train | |
mattma/gulp-htmlbars | bower_components/ember/ember-template-compiler.js | domIndexOf | function domIndexOf(nodes, domNode) {
var index = -1;
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.type !== 'TextNode' && node.type !== 'ElementNode') {
continue;
} else {
index++;
}
if (node === domNode) {
re... | javascript | function domIndexOf(nodes, domNode) {
var index = -1;
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.type !== 'TextNode' && node.type !== 'ElementNode') {
continue;
} else {
index++;
}
if (node === domNode) {
re... | [
"function",
"domIndexOf",
"(",
"nodes",
",",
"domNode",
")",
"{",
"var",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"nodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"node",
"=",
"nodes",
"[",
"i",
"]... | Returns the index of `domNode` in the `nodes` array, skipping over any nodes which do not represent DOM nodes. | [
"Returns",
"the",
"index",
"of",
"domNode",
"in",
"the",
"nodes",
"array",
"skipping",
"over",
"any",
"nodes",
"which",
"do",
"not",
"represent",
"DOM",
"nodes",
"."
] | c9e6bcf32023825efc34a93ecf8555b3f98b2bcf | https://github.com/mattma/gulp-htmlbars/blob/c9e6bcf32023825efc34a93ecf8555b3f98b2bcf/bower_components/ember/ember-template-compiler.js#L1891-L1909 | train |
mattma/gulp-htmlbars | bower_components/ember/ember-template-compiler.js | parseComponentBlockParams | function parseComponentBlockParams(element, program) {
var l = element.attributes.length;
var attrNames = [];
for (var i = 0; i < l; i++) {
attrNames.push(element.attributes[i].name);
}
var asIndex = attrNames.indexOf('as');
if (asIndex !== -1 && l > asIndex && attrNames[a... | javascript | function parseComponentBlockParams(element, program) {
var l = element.attributes.length;
var attrNames = [];
for (var i = 0; i < l; i++) {
attrNames.push(element.attributes[i].name);
}
var asIndex = attrNames.indexOf('as');
if (asIndex !== -1 && l > asIndex && attrNames[a... | [
"function",
"parseComponentBlockParams",
"(",
"element",
",",
"program",
")",
"{",
"var",
"l",
"=",
"element",
".",
"attributes",
".",
"length",
";",
"var",
"attrNames",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
... | Checks the component's attributes to see if it uses block params. If it does, registers the block params with the program and removes the corresponding attributes from the element. | [
"Checks",
"the",
"component",
"s",
"attributes",
"to",
"see",
"if",
"it",
"uses",
"block",
"params",
".",
"If",
"it",
"does",
"registers",
"the",
"block",
"params",
"with",
"the",
"program",
"and",
"removes",
"the",
"corresponding",
"attributes",
"from",
"th... | c9e6bcf32023825efc34a93ecf8555b3f98b2bcf | https://github.com/mattma/gulp-htmlbars/blob/c9e6bcf32023825efc34a93ecf8555b3f98b2bcf/bower_components/ember/ember-template-compiler.js#L3889-L3924 | train |
AndreasMadsen/piccolo | lib/client/link.js | onLinkClick | function onLinkClick(event) {
// Resolve anchor link
var page = url.format( url.resolve(location, this.getAttribute('href')) );
// Load new page
piccolo.loadPage( page );
event.preventDefault();
return false;
} | javascript | function onLinkClick(event) {
// Resolve anchor link
var page = url.format( url.resolve(location, this.getAttribute('href')) );
// Load new page
piccolo.loadPage( page );
event.preventDefault();
return false;
} | [
"function",
"onLinkClick",
"(",
"event",
")",
"{",
"// Resolve anchor link",
"var",
"page",
"=",
"url",
".",
"format",
"(",
"url",
".",
"resolve",
"(",
"location",
",",
"this",
".",
"getAttribute",
"(",
"'href'",
")",
")",
")",
";",
"// Load new page",
"pi... | Add handlers to anchor tag | [
"Add",
"handlers",
"to",
"anchor",
"tag"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L23-L31 | train |
AndreasMadsen/piccolo | lib/client/link.js | renderPage | function renderPage(state) {
// Get presenter object
piccolo.require(state.resolved.name, function (error, Resource) {
if (error) return piccolo.emit('error', error);
var presenter = new Resource(state.query.href, document);
presenter[state.resolved.method].apply(presenter, state.resolved... | javascript | function renderPage(state) {
// Get presenter object
piccolo.require(state.resolved.name, function (error, Resource) {
if (error) return piccolo.emit('error', error);
var presenter = new Resource(state.query.href, document);
presenter[state.resolved.method].apply(presenter, state.resolved... | [
"function",
"renderPage",
"(",
"state",
")",
"{",
"// Get presenter object",
"piccolo",
".",
"require",
"(",
"state",
".",
"resolved",
".",
"name",
",",
"function",
"(",
"error",
",",
"Resource",
")",
"{",
"if",
"(",
"error",
")",
"return",
"piccolo",
".",... | Render page change | [
"Render",
"page",
"change"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L49-L57 | train |
AndreasMadsen/piccolo | lib/client/link.js | createStateObject | function createStateObject(page, callback) {
// This callback function will create a change table state object
var create = function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace':... | javascript | function createStateObject(page, callback) {
// This callback function will create a change table state object
var create = function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace':... | [
"function",
"createStateObject",
"(",
"page",
",",
"callback",
")",
"{",
"// This callback function will create a change table state object",
"var",
"create",
"=",
"function",
"(",
")",
"{",
"var",
"query",
"=",
"url",
".",
"parse",
"(",
"page",
")",
";",
"var",
... | Parse a page path and return state object | [
"Parse",
"a",
"page",
"path",
"and",
"return",
"state",
"object"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L60-L77 | train |
AndreasMadsen/piccolo | lib/client/link.js | function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace': 'piccolo',
'query': query
};
callback(state);
} | javascript | function () {
var query = url.parse(page);
var presenter = piccolo.build.router.parse(query.pathname);
var state = {
'resolved': presenter,
'namespace': 'piccolo',
'query': query
};
callback(state);
} | [
"function",
"(",
")",
"{",
"var",
"query",
"=",
"url",
".",
"parse",
"(",
"page",
")",
";",
"var",
"presenter",
"=",
"piccolo",
".",
"build",
".",
"router",
".",
"parse",
"(",
"query",
".",
"pathname",
")",
";",
"var",
"state",
"=",
"{",
"'resolved... | This callback function will create a change table state object | [
"This",
"callback",
"function",
"will",
"create",
"a",
"change",
"table",
"state",
"object"
] | ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d | https://github.com/AndreasMadsen/piccolo/blob/ef43f5634c564eef0d21a4a6aa103b2f1e3baa3d/lib/client/link.js#L63-L74 | train | |
jwoudenberg/chain-args | lib/createChain.js | createChain | function createChain(descriptor, callback) {
if (typeof descriptor !== 'object') {
throw new TypeError('createChain: descriptor is not an object: ' +
descriptor);
}
//Create the Chain class.
function CustomChain(callback) {
if (!(this instanceof CustomChain))... | javascript | function createChain(descriptor, callback) {
if (typeof descriptor !== 'object') {
throw new TypeError('createChain: descriptor is not an object: ' +
descriptor);
}
//Create the Chain class.
function CustomChain(callback) {
if (!(this instanceof CustomChain))... | [
"function",
"createChain",
"(",
"descriptor",
",",
"callback",
")",
"{",
"if",
"(",
"typeof",
"descriptor",
"!==",
"'object'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'createChain: descriptor is not an object: '",
"+",
"descriptor",
")",
";",
"}",
"//Create t... | Take a descriptor object and return a Chain constructor.
An optional default callback for this type of Chain. | [
"Take",
"a",
"descriptor",
"object",
"and",
"return",
"a",
"Chain",
"constructor",
".",
"An",
"optional",
"default",
"callback",
"for",
"this",
"type",
"of",
"Chain",
"."
] | 8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228 | https://github.com/jwoudenberg/chain-args/blob/8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228/lib/createChain.js#L9-L50 | train |
jwoudenberg/chain-args | lib/createChain.js | CustomChain | function CustomChain(callback) {
if (!(this instanceof CustomChain)) {
return new CustomChain(callback);
}
CustomChain.super_.call(this, callback);
CustomChain._lists.forEach(function(listName) {
this._result[listName] = [];
}, this);
} | javascript | function CustomChain(callback) {
if (!(this instanceof CustomChain)) {
return new CustomChain(callback);
}
CustomChain.super_.call(this, callback);
CustomChain._lists.forEach(function(listName) {
this._result[listName] = [];
}, this);
} | [
"function",
"CustomChain",
"(",
"callback",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"CustomChain",
")",
")",
"{",
"return",
"new",
"CustomChain",
"(",
"callback",
")",
";",
"}",
"CustomChain",
".",
"super_",
".",
"call",
"(",
"this",
",",
... | Create the Chain class. | [
"Create",
"the",
"Chain",
"class",
"."
] | 8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228 | https://github.com/jwoudenberg/chain-args/blob/8a4c8a1b8bf66bad98ffaa2e8ef44b08abfb7228/lib/createChain.js#L16-L24 | train |
jisbruzzi/file-combiner | index.js | includedFiles | function includedFiles(name){
let includes=this.getIncludes(this.getFile(name));
let ret=includes.map(include => {
let ret = {
absolute:path.join(name,"../",include.relPath),
relative:include.relPath,
match:include.match
}
return ret;
})
return... | javascript | function includedFiles(name){
let includes=this.getIncludes(this.getFile(name));
let ret=includes.map(include => {
let ret = {
absolute:path.join(name,"../",include.relPath),
relative:include.relPath,
match:include.match
}
return ret;
})
return... | [
"function",
"includedFiles",
"(",
"name",
")",
"{",
"let",
"includes",
"=",
"this",
".",
"getIncludes",
"(",
"this",
".",
"getFile",
"(",
"name",
")",
")",
";",
"let",
"ret",
"=",
"includes",
".",
"map",
"(",
"include",
"=>",
"{",
"let",
"ret",
"=",
... | Returns the paths of the included files, relative to cwd
@param {String} name | [
"Returns",
"the",
"paths",
"of",
"the",
"included",
"files",
"relative",
"to",
"cwd"
] | f5f4135628de75e55aee3dab0d48e58160113d06 | https://github.com/jisbruzzi/file-combiner/blob/f5f4135628de75e55aee3dab0d48e58160113d06/index.js#L25-L36 | train |
mauroc/passport-squiddio | lib/errors/squiddiotokenerror.js | SquiddioTokenError | function SquiddioTokenError(message, type, code, subcode) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'SquiddioTokenError';
this.message = message;
this.type = type;
this.code = code;
this.subcode = subcode;
this.status = 500;
} | javascript | function SquiddioTokenError(message, type, code, subcode) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'SquiddioTokenError';
this.message = message;
this.type = type;
this.code = code;
this.subcode = subcode;
this.status = 500;
} | [
"function",
"SquiddioTokenError",
"(",
"message",
",",
"type",
",",
"code",
",",
"subcode",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"... | `SquiddioTokenError` error.
SquiddioTokenError represents an error received from a Squiddio's token
endpoint. Note that these responses don't conform to the OAuth 2.0
specification.
References:
- https://developers.Squiddio.com/docs/reference/api/errors/
@constructor
@param {String} [message]
@param {String} [type]... | [
"SquiddioTokenError",
"error",
"."
] | f2a7b1defde5b82240a53817c42327a6e9a7ca5b | https://github.com/mauroc/passport-squiddio/blob/f2a7b1defde5b82240a53817c42327a6e9a7ca5b/lib/errors/squiddiotokenerror.js#L18-L27 | train |
mcdonnelldean/metalsmith-move-up | lib/plugin.js | onNextTransform | function onNextTransform (transform, next) {
// check if we should handle this filePath
function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
}
// transform the path
function process (filePath, complete) {
... | javascript | function onNextTransform (transform, next) {
// check if we should handle this filePath
function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
}
// transform the path
function process (filePath, complete) {
... | [
"function",
"onNextTransform",
"(",
"transform",
",",
"next",
")",
"{",
"// check if we should handle this filePath\r",
"function",
"shouldProcess",
"(",
"filePath",
",",
"done",
")",
"{",
"done",
"(",
"!",
"!",
"multimatch",
"(",
"filePath",
",",
"transform",
"."... | will be called once per transform | [
"will",
"be",
"called",
"once",
"per",
"transform"
] | 32457e76fe8736318e6edda2172fa7721068d827 | https://github.com/mcdonnelldean/metalsmith-move-up/blob/32457e76fe8736318e6edda2172fa7721068d827/lib/plugin.js#L64-L94 | train |
mcdonnelldean/metalsmith-move-up | lib/plugin.js | shouldProcess | function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
} | javascript | function shouldProcess (filePath, done) {
done(!!multimatch(filePath, transform.pattern, transform.opts).length)
} | [
"function",
"shouldProcess",
"(",
"filePath",
",",
"done",
")",
"{",
"done",
"(",
"!",
"!",
"multimatch",
"(",
"filePath",
",",
"transform",
".",
"pattern",
",",
"transform",
".",
"opts",
")",
".",
"length",
")",
"}"
] | check if we should handle this filePath | [
"check",
"if",
"we",
"should",
"handle",
"this",
"filePath"
] | 32457e76fe8736318e6edda2172fa7721068d827 | https://github.com/mcdonnelldean/metalsmith-move-up/blob/32457e76fe8736318e6edda2172fa7721068d827/lib/plugin.js#L66-L68 | train |
mcdonnelldean/metalsmith-move-up | lib/plugin.js | process | function process (filePath, complete) {
var filename = path.basename(filePath),
pathParts = path.dirname(filePath).split(path.sep)
// we'll get an empty arrary if we overslice
pathParts = pathParts.slice(transform.by)
pathParts.push(filename)
var newPath = p... | javascript | function process (filePath, complete) {
var filename = path.basename(filePath),
pathParts = path.dirname(filePath).split(path.sep)
// we'll get an empty arrary if we overslice
pathParts = pathParts.slice(transform.by)
pathParts.push(filename)
var newPath = p... | [
"function",
"process",
"(",
"filePath",
",",
"complete",
")",
"{",
"var",
"filename",
"=",
"path",
".",
"basename",
"(",
"filePath",
")",
",",
"pathParts",
"=",
"path",
".",
"dirname",
"(",
"filePath",
")",
".",
"split",
"(",
"path",
".",
"sep",
")",
... | transform the path | [
"transform",
"the",
"path"
] | 32457e76fe8736318e6edda2172fa7721068d827 | https://github.com/mcdonnelldean/metalsmith-move-up/blob/32457e76fe8736318e6edda2172fa7721068d827/lib/plugin.js#L71-L88 | train |
byu-oit/sans-server | bin/server/response.js | Response | function Response(request, key) {
// define private store
const store = {
body: '',
cookies: [],
headers: {},
key: key,
sent: false,
statusCode: 0
};
this[STORE] = store;
/**
* The request that is tied to this response.
* @name Response#re... | javascript | function Response(request, key) {
// define private store
const store = {
body: '',
cookies: [],
headers: {},
key: key,
sent: false,
statusCode: 0
};
this[STORE] = store;
/**
* The request that is tied to this response.
* @name Response#re... | [
"function",
"Response",
"(",
"request",
",",
"key",
")",
"{",
"// define private store",
"const",
"store",
"=",
"{",
"body",
":",
"''",
",",
"cookies",
":",
"[",
"]",
",",
"headers",
":",
"{",
"}",
",",
"key",
":",
"key",
",",
"sent",
":",
"false",
... | Create a response instance.
@param {Request} request The request that is relying on this response that is being created.
@param {Symbol} key
@returns {Response}
@constructor | [
"Create",
"a",
"response",
"instance",
"."
] | 022bcf7b47321e6e8aa20467cd96a6a84a457ec8 | https://github.com/byu-oit/sans-server/blob/022bcf7b47321e6e8aa20467cd96a6a84a457ec8/bin/server/response.js#L33-L118 | train |
bfontaine/tp.js | lib/mocha.js | text | function text(el, str) {
if (el.textContent) {
el.textContent = str;
} else {
el.innerText = str;
}
} | javascript | function text(el, str) {
if (el.textContent) {
el.textContent = str;
} else {
el.innerText = str;
}
} | [
"function",
"text",
"(",
"el",
",",
"str",
")",
"{",
"if",
"(",
"el",
".",
"textContent",
")",
"{",
"el",
".",
"textContent",
"=",
"str",
";",
"}",
"else",
"{",
"el",
".",
"innerText",
"=",
"str",
";",
"}",
"}"
] | Set `el` text to `str`. | [
"Set",
"el",
"text",
"to",
"str",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L2451-L2457 | train |
bfontaine/tp.js | lib/mocha.js | map | function map(cov) {
var ret = {
instrumentation: 'node-jscoverage'
, sloc: 0
, hits: 0
, misses: 0
, coverage: 0
, files: []
};
for (var filename in cov) {
var data = coverage(filename, cov[filename]);
ret.files.push(data);
ret.hits += data.hits;
ret.misses += data.misse... | javascript | function map(cov) {
var ret = {
instrumentation: 'node-jscoverage'
, sloc: 0
, hits: 0
, misses: 0
, coverage: 0
, files: []
};
for (var filename in cov) {
var data = coverage(filename, cov[filename]);
ret.files.push(data);
ret.hits += data.hits;
ret.misses += data.misse... | [
"function",
"map",
"(",
"cov",
")",
"{",
"var",
"ret",
"=",
"{",
"instrumentation",
":",
"'node-jscoverage'",
",",
"sloc",
":",
"0",
",",
"hits",
":",
"0",
",",
"misses",
":",
"0",
",",
"coverage",
":",
"0",
",",
"files",
":",
"[",
"]",
"}",
";",... | Map jscoverage data to a JSON structure
suitable for reporting.
@param {Object} cov
@return {Object}
@api private | [
"Map",
"jscoverage",
"data",
"to",
"a",
"JSON",
"structure",
"suitable",
"for",
"reporting",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L2561-L2588 | train |
bfontaine/tp.js | lib/mocha.js | coverage | function coverage(filename, data) {
var ret = {
filename: filename,
coverage: 0,
hits: 0,
misses: 0,
sloc: 0,
source: {}
};
data.source.forEach(function(line, num){
num++;
if (data[num] === 0) {
ret.misses++;
ret.sloc++;
} else if (data[num] !== undefined) {
... | javascript | function coverage(filename, data) {
var ret = {
filename: filename,
coverage: 0,
hits: 0,
misses: 0,
sloc: 0,
source: {}
};
data.source.forEach(function(line, num){
num++;
if (data[num] === 0) {
ret.misses++;
ret.sloc++;
} else if (data[num] !== undefined) {
... | [
"function",
"coverage",
"(",
"filename",
",",
"data",
")",
"{",
"var",
"ret",
"=",
"{",
"filename",
":",
"filename",
",",
"coverage",
":",
"0",
",",
"hits",
":",
"0",
",",
"misses",
":",
"0",
",",
"sloc",
":",
"0",
",",
"source",
":",
"{",
"}",
... | Map jscoverage data for a single source file
to a JSON structure suitable for reporting.
@param {String} filename name of the source file
@param {Object} data jscoverage coverage data
@return {Object}
@api private | [
"Map",
"jscoverage",
"data",
"for",
"a",
"single",
"source",
"file",
"to",
"a",
"JSON",
"structure",
"suitable",
"for",
"reporting",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L2600-L2632 | train |
bfontaine/tp.js | lib/mocha.js | TAP | function TAP(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, n = 1
, passes = 0
, failures = 0;
runner.on('start', function(){
var total = runner.grepTotal(runner.suite);
console.log('%d..%d', 1, total);
});
runner.on('test end', function(){
++n;
});
... | javascript | function TAP(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, n = 1
, passes = 0
, failures = 0;
runner.on('start', function(){
var total = runner.grepTotal(runner.suite);
console.log('%d..%d', 1, total);
});
runner.on('test end', function(){
++n;
});
... | [
"function",
"TAP",
"(",
"runner",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
")",
";",
"var",
"self",
"=",
"this",
",",
"stats",
"=",
"this",
".",
"stats",
",",
"n",
"=",
"1",
",",
"passes",
"=",
"0",
",",
"failures",
"=",
"0",
... | Initialize a new `TAP` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"TAP",
"reporter",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L3584-L3622 | train |
bfontaine/tp.js | lib/mocha.js | Teamcity | function Teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
});
... | javascript | function Teamcity(runner) {
Base.call(this, runner);
var stats = this.stats;
runner.on('start', function() {
console.log("##teamcity[testSuiteStarted name='mocha.suite']");
});
runner.on('test', function(test) {
console.log("##teamcity[testStarted name='" + escape(test.fullTitle()) + "']");
});
... | [
"function",
"Teamcity",
"(",
"runner",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
")",
";",
"var",
"stats",
"=",
"this",
".",
"stats",
";",
"runner",
".",
"on",
"(",
"'start'",
",",
"function",
"(",
")",
"{",
"console",
".",
"log",
... | Initialize a new `Teamcity` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"Teamcity",
"reporter",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L3659-L3686 | train |
bfontaine/tp.js | lib/mocha.js | XUnit | function XUnit(runner) {
Base.call(this, runner);
var stats = this.stats
, tests = []
, self = this;
runner.on('pass', function(test){
tests.push(test);
});
runner.on('fail', function(test){
tests.push(test);
});
runner.on('end', function(){
console.log(tag('testsuite', {
... | javascript | function XUnit(runner) {
Base.call(this, runner);
var stats = this.stats
, tests = []
, self = this;
runner.on('pass', function(test){
tests.push(test);
});
runner.on('fail', function(test){
tests.push(test);
});
runner.on('end', function(){
console.log(tag('testsuite', {
... | [
"function",
"XUnit",
"(",
"runner",
")",
"{",
"Base",
".",
"call",
"(",
"this",
",",
"runner",
")",
";",
"var",
"stats",
"=",
"this",
".",
"stats",
",",
"tests",
"=",
"[",
"]",
",",
"self",
"=",
"this",
";",
"runner",
".",
"on",
"(",
"'pass'",
... | Initialize a new `XUnit` reporter.
@param {Runner} runner
@api public | [
"Initialize",
"a",
"new",
"XUnit",
"reporter",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L3740-L3768 | train |
bfontaine/tp.js | lib/mocha.js | Runner | function Runner(suite) {
var self = this;
this._globals = [];
this.suite = suite;
this.total = suite.total();
this.failures = 0;
this.on('test end', function(test){ self.checkGlobals(test); });
this.on('hook end', function(hook){ self.checkGlobals(hook); });
this.grep(/.*/);
this.globals(this.globalPr... | javascript | function Runner(suite) {
var self = this;
this._globals = [];
this.suite = suite;
this.total = suite.total();
this.failures = 0;
this.on('test end', function(test){ self.checkGlobals(test); });
this.on('hook end', function(hook){ self.checkGlobals(hook); });
this.grep(/.*/);
this.globals(this.globalPr... | [
"function",
"Runner",
"(",
"suite",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_globals",
"=",
"[",
"]",
";",
"this",
".",
"suite",
"=",
"suite",
";",
"this",
".",
"total",
"=",
"suite",
".",
"total",
"(",
")",
";",
"this",
".",
"... | Initialize a `Runner` for the given `suite`.
Events:
- `start` execution started
- `end` execution complete
- `suite` (suite) test suite execution started
- `suite end` (suite) all tests (and sub-suites) have finished
- `test` (test) test execution started
- `test end` (test) test completed
- `hook` (hook) hoo... | [
"Initialize",
"a",
"Runner",
"for",
"the",
"given",
"suite",
"."
] | dad7cb0f5398b1afcbc481f87c0b59c7131a49ed | https://github.com/bfontaine/tp.js/blob/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/lib/mocha.js#L4109-L4119 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/core/htmlparser/comment.js | function( filter, context ) {
var comment = this.value;
if ( !( comment = filter.onComment( context, comment, this ) ) ) {
this.remove();
return false;
}
if ( typeof comment != 'string' ) {
this.replaceWith( comment );
return false;
}
this.value = comment;
return true;
} | javascript | function( filter, context ) {
var comment = this.value;
if ( !( comment = filter.onComment( context, comment, this ) ) ) {
this.remove();
return false;
}
if ( typeof comment != 'string' ) {
this.replaceWith( comment );
return false;
}
this.value = comment;
return true;
} | [
"function",
"(",
"filter",
",",
"context",
")",
"{",
"var",
"comment",
"=",
"this",
".",
"value",
";",
"if",
"(",
"!",
"(",
"comment",
"=",
"filter",
".",
"onComment",
"(",
"context",
",",
"comment",
",",
"this",
")",
")",
")",
"{",
"this",
".",
... | Filter this comment with given filter.
@since 4.1
@param {CKEDITOR.htmlParser.filter} filter
@returns {Boolean} Method returns `false` when this comment has
been removed or replaced with other node. This is an information for
{@link CKEDITOR.htmlParser.element#filterChildren} that it has
to repeat filter on current po... | [
"Filter",
"this",
"comment",
"with",
"given",
"filter",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/htmlparser/comment.js#L49-L65 | train | |
techhead/mmm | mmm.js | getExistsSync | function getExistsSync(path, exts) {
for (var i=0,len=exts.length; i<len; i++) {
if (fs.existsSync(path + exts[i])) {
return path + exts[i];
}
}
return false;
} | javascript | function getExistsSync(path, exts) {
for (var i=0,len=exts.length; i<len; i++) {
if (fs.existsSync(path + exts[i])) {
return path + exts[i];
}
}
return false;
} | [
"function",
"getExistsSync",
"(",
"path",
",",
"exts",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"exts",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"path",
"+",
"... | Takes a path and array of file extensions
and returns the first path + extension that exists
or returns false. | [
"Takes",
"a",
"path",
"and",
"array",
"of",
"file",
"extensions",
"and",
"returns",
"the",
"first",
"path",
"+",
"extension",
"that",
"exists",
"or",
"returns",
"false",
"."
] | 0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46 | https://github.com/techhead/mmm/blob/0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46/mmm.js#L75-L82 | train |
techhead/mmm | mmm.js | extend | function extend(a,b) {
var c = clone(a);
for (var key in b) {
c[key] = b[key];
}
return c;
} | javascript | function extend(a,b) {
var c = clone(a);
for (var key in b) {
c[key] = b[key];
}
return c;
} | [
"function",
"extend",
"(",
"a",
",",
"b",
")",
"{",
"var",
"c",
"=",
"clone",
"(",
"a",
")",
";",
"for",
"(",
"var",
"key",
"in",
"b",
")",
"{",
"c",
"[",
"key",
"]",
"=",
"b",
"[",
"key",
"]",
";",
"}",
"return",
"c",
";",
"}"
] | Return a new object that inherits from `a`
and also contains the properties of `b`. | [
"Return",
"a",
"new",
"object",
"that",
"inherits",
"from",
"a",
"and",
"also",
"contains",
"the",
"properties",
"of",
"b",
"."
] | 0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46 | https://github.com/techhead/mmm/blob/0ba6fd37cf542e2b48a35f57eff36d3ceff3ef46/mmm.js#L129-L135 | train |
dominikwilkowski/grunt-wakeup | tasks/wakeup.js | randomize | function randomize( obj ) {
var j = 0,
i = Math.floor(Math.random() * (Object.keys(obj).length)),
result;
for(var property in obj) {
if(j === i) {
result = property;
break;
}
j++;
}
return result;
} | javascript | function randomize( obj ) {
var j = 0,
i = Math.floor(Math.random() * (Object.keys(obj).length)),
result;
for(var property in obj) {
if(j === i) {
result = property;
break;
}
j++;
}
return result;
} | [
"function",
"randomize",
"(",
"obj",
")",
"{",
"var",
"j",
"=",
"0",
",",
"i",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"length",
")",
")",
",",
"result",
";",
"fo... | get random value off of an object | [
"get",
"random",
"value",
"off",
"of",
"an",
"object"
] | 0558a2853316630b2793215fe5dd560abbac045a | https://github.com/dominikwilkowski/grunt-wakeup/blob/0558a2853316630b2793215fe5dd560abbac045a/tasks/wakeup.js#L18-L33 | train |
beyo/events | lib/events.js | _createEventRangeValidator | function _createEventRangeValidator(range) {
var ctxRange = _createRangeArray(range);
return function rangeValidator(range) {
var leftIndex = 0;
var rightIndex = 0;
var left;
var right;
for (; leftIndex < ctxRange.length && rightIndex < range.length; ) {
left = ctxRange[leftIndex];
... | javascript | function _createEventRangeValidator(range) {
var ctxRange = _createRangeArray(range);
return function rangeValidator(range) {
var leftIndex = 0;
var rightIndex = 0;
var left;
var right;
for (; leftIndex < ctxRange.length && rightIndex < range.length; ) {
left = ctxRange[leftIndex];
... | [
"function",
"_createEventRangeValidator",
"(",
"range",
")",
"{",
"var",
"ctxRange",
"=",
"_createRangeArray",
"(",
"range",
")",
";",
"return",
"function",
"rangeValidator",
"(",
"range",
")",
"{",
"var",
"leftIndex",
"=",
"0",
";",
"var",
"rightIndex",
"=",
... | Create a range validator. The returned value is a function validating if
a given range matches this range | [
"Create",
"a",
"range",
"validator",
".",
"The",
"returned",
"value",
"is",
"a",
"function",
"validating",
"if",
"a",
"given",
"range",
"matches",
"this",
"range"
] | a5d82b1e3dc5cff012ec15dd0bf0a593ce316bf6 | https://github.com/beyo/events/blob/a5d82b1e3dc5cff012ec15dd0bf0a593ce316bf6/lib/events.js#L258-L284 | train |
tgolen/skelenode-swagger | respond.js | sendSPrintFError | function sendSPrintFError(res, errorArray, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = errorArray;
return sendError(res, obj, code, internalCode);
} | javascript | function sendSPrintFError(res, errorArray, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = errorArray;
return sendError(res, obj, code, internalCode);
} | [
"function",
"sendSPrintFError",
"(",
"res",
",",
"errorArray",
",",
"code",
",",
"internalCode",
")",
"{",
"var",
"obj",
"=",
"{",
"success",
":",
"false",
"}",
";",
"obj",
"[",
"res",
"?",
"'description'",
":",
"'reason'",
"]",
"=",
"errorArray",
";",
... | Sends a SPrintF formatted error to the user. Otherwise, behaves the same as sendStringError.
@param res Optional Express Response object.
@param errorArray The first element should be a string; subsequent args are formatted in to the first string.
@param code The HTTP Status code to send (like 404, 403, etc).
@param in... | [
"Sends",
"a",
"SPrintF",
"formatted",
"error",
"to",
"the",
"user",
".",
"Otherwise",
"behaves",
"the",
"same",
"as",
"sendStringError",
"."
] | 9b8caa81d32b492b26d1bec34ce49ab015afd8bd | https://github.com/tgolen/skelenode-swagger/blob/9b8caa81d32b492b26d1bec34ce49ab015afd8bd/respond.js#L128-L132 | train |
tgolen/skelenode-swagger | respond.js | sendStringError | function sendStringError(res, error, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = error;
return sendError(res, obj, code, internalCode);
} | javascript | function sendStringError(res, error, code, internalCode) {
var obj = { success: false };
obj[res ? 'description' : 'reason'] = error;
return sendError(res, obj, code, internalCode);
} | [
"function",
"sendStringError",
"(",
"res",
",",
"error",
",",
"code",
",",
"internalCode",
")",
"{",
"var",
"obj",
"=",
"{",
"success",
":",
"false",
"}",
";",
"obj",
"[",
"res",
"?",
"'description'",
":",
"'reason'",
"]",
"=",
"error",
";",
"return",
... | Sends a string error to the user. Attempts to localize it.
@param res Optional Express Response object.
@param error The error to send to the user. If it's a string, it will be localized.
@param code The HTTP Status code to send (like 404, 403, etc).
@param internalCode An optional internal code to also send to the cli... | [
"Sends",
"a",
"string",
"error",
"to",
"the",
"user",
".",
"Attempts",
"to",
"localize",
"it",
"."
] | 9b8caa81d32b492b26d1bec34ce49ab015afd8bd | https://github.com/tgolen/skelenode-swagger/blob/9b8caa81d32b492b26d1bec34ce49ab015afd8bd/respond.js#L141-L145 | train |
TempoIQ/tempoiq-node-js | lib/models/device.js | Device | function Device(key, params) {
var p = params || {};
// The primary key of the device [String]
this.key = key;
// Human readable name of the device [String] EG - "My Device"
this.name = p.name || "";
// Indexable attributes. Useful for grouping related Devices.
// EG - {location: '445-w-Erie', model: 'T... | javascript | function Device(key, params) {
var p = params || {};
// The primary key of the device [String]
this.key = key;
// Human readable name of the device [String] EG - "My Device"
this.name = p.name || "";
// Indexable attributes. Useful for grouping related Devices.
// EG - {location: '445-w-Erie', model: 'T... | [
"function",
"Device",
"(",
"key",
",",
"params",
")",
"{",
"var",
"p",
"=",
"params",
"||",
"{",
"}",
";",
"// The primary key of the device [String]",
"this",
".",
"key",
"=",
"key",
";",
"// Human readable name of the device [String] EG - \"My Device\"",
"this",
"... | The top level container for a group of sensors. | [
"The",
"top",
"level",
"container",
"for",
"a",
"group",
"of",
"sensors",
"."
] | b3ab72f9d7760a54df9ef75093d349b28a29864c | https://github.com/TempoIQ/tempoiq-node-js/blob/b3ab72f9d7760a54df9ef75093d349b28a29864c/lib/models/device.js#L4-L16 | train |
benzhou1/iod | lib/send.js | function(err, httpRes, body) {
if (err) _callback(err)
else {
try { var res = JSON.parse(body) }
catch(err) { _callback(null, body) }
if (httpRes && httpRes.statusCode !== 200) {
maybeRetry(res, IOD, IODOpts, apiType, _callback)
}
else _callback(null, res)
}
} | javascript | function(err, httpRes, body) {
if (err) _callback(err)
else {
try { var res = JSON.parse(body) }
catch(err) { _callback(null, body) }
if (httpRes && httpRes.statusCode !== 200) {
maybeRetry(res, IOD, IODOpts, apiType, _callback)
}
else _callback(null, res)
}
} | [
"function",
"(",
"err",
",",
"httpRes",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"_callback",
"(",
"err",
")",
"else",
"{",
"try",
"{",
"var",
"res",
"=",
"JSON",
".",
"parse",
"(",
"body",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"_callba... | Callback for handling request.
Errors if response from IOD server is not 200.
Attempts to JSON parse response body on success, returns original body if
fail to parse.
@param {*} err - Request error
@param {Object} httpRes - Request http response object
@param {*} body - Request body | [
"Callback",
"for",
"handling",
"request",
".",
"Errors",
"if",
"response",
"from",
"IOD",
"server",
"is",
"not",
"200",
".",
"Attempts",
"to",
"JSON",
"parse",
"response",
"body",
"on",
"success",
"returns",
"original",
"body",
"if",
"fail",
"to",
"parse",
... | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L48-L59 | train | |
benzhou1/iod | lib/send.js | maybeRetry | function maybeRetry(err, IOD, IODOpts, apiType, callback) {
var retryApiReq = apiType !== IOD.TYPES.SYNC &&
apiType !== IOD.TYPES.RESULT &&
apiType !== IOD.TYPES.DISCOVERY
if (IODOpts.retries == null || retryApiReq) callback(err)
else if (!--IODOpts.retries) callback(err)
var reqTypeDontRetry = apiType !== IO... | javascript | function maybeRetry(err, IOD, IODOpts, apiType, callback) {
var retryApiReq = apiType !== IOD.TYPES.SYNC &&
apiType !== IOD.TYPES.RESULT &&
apiType !== IOD.TYPES.DISCOVERY
if (IODOpts.retries == null || retryApiReq) callback(err)
else if (!--IODOpts.retries) callback(err)
var reqTypeDontRetry = apiType !== IO... | [
"function",
"maybeRetry",
"(",
"err",
",",
"IOD",
",",
"IODOpts",
",",
"apiType",
",",
"callback",
")",
"{",
"var",
"retryApiReq",
"=",
"apiType",
"!==",
"IOD",
".",
"TYPES",
".",
"SYNC",
"&&",
"apiType",
"!==",
"IOD",
".",
"TYPES",
".",
"RESULT",
"&&"... | If retries is specified on `IODOpts` and is greater than one,
retry request if it is either a Backend failure or time out.
@param {*} err - Error
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - Api type
@param {Function} callback - callback(err | res) | [
"If",
"retries",
"is",
"specified",
"on",
"IODOpts",
"and",
"is",
"greater",
"than",
"one",
"retry",
"request",
"if",
"it",
"is",
"either",
"a",
"Backend",
"failure",
"or",
"time",
"out",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L91-L114 | train |
benzhou1/iod | lib/send.js | makeOptions | function makeOptions(IOD, IODOpts, apiType, reqOpts) {
var path = IodU.makePath(IOD, IODOpts, apiType)
var method = apiType === IOD.TYPES.JOB || !_.isEmpty(IODOpts.files) ?
'post' : IODOpts.method.toLowerCase()
return _.defaults({
url: IOD.host + ':' + IOD.port + path,
path: path,
method: method,
// For ... | javascript | function makeOptions(IOD, IODOpts, apiType, reqOpts) {
var path = IodU.makePath(IOD, IODOpts, apiType)
var method = apiType === IOD.TYPES.JOB || !_.isEmpty(IODOpts.files) ?
'post' : IODOpts.method.toLowerCase()
return _.defaults({
url: IOD.host + ':' + IOD.port + path,
path: path,
method: method,
// For ... | [
"function",
"makeOptions",
"(",
"IOD",
",",
"IODOpts",
",",
"apiType",
",",
"reqOpts",
")",
"{",
"var",
"path",
"=",
"IodU",
".",
"makePath",
"(",
"IOD",
",",
"IODOpts",
",",
"apiType",
")",
"var",
"method",
"=",
"apiType",
"===",
"IOD",
".",
"TYPES",
... | Creates a request options object with.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - IOD request type
@param {Object} reqOpts - Request options for current request
@returns {Object} Request options object | [
"Creates",
"a",
"request",
"options",
"object",
"with",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L125-L143 | train |
benzhou1/iod | lib/send.js | addParamsToData | function addParamsToData(IOD, IODOpts, form) {
form.append('apiKey', IOD.apiKey)
_.each(exports.prepareParams(IODOpts.params), function(paramVal, paramName) {
_.each(T.maybeToArray(paramVal), function(val) {
form.append(paramName, val)
})
})
} | javascript | function addParamsToData(IOD, IODOpts, form) {
form.append('apiKey', IOD.apiKey)
_.each(exports.prepareParams(IODOpts.params), function(paramVal, paramName) {
_.each(T.maybeToArray(paramVal), function(val) {
form.append(paramName, val)
})
})
} | [
"function",
"addParamsToData",
"(",
"IOD",
",",
"IODOpts",
",",
"form",
")",
"{",
"form",
".",
"append",
"(",
"'apiKey'",
",",
"IOD",
".",
"apiKey",
")",
"_",
".",
"each",
"(",
"exports",
".",
"prepareParams",
"(",
"IODOpts",
".",
"params",
")",
",",
... | Add parameters to FormData object.
Automatically append api key.
Modifies `IODOpts` in place.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {FormData} form - FormData object | [
"Add",
"parameters",
"to",
"FormData",
"object",
".",
"Automatically",
"append",
"api",
"key",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L155-L163 | train |
benzhou1/iod | lib/send.js | addFilesToData | function addFilesToData(IOD, IODOpts, apiType, form) {
_.each(T.maybeToArray(IODOpts.files), function(file) {
if (apiType === IOD.TYPES.JOB) {
form.append(file.name, fs.createReadStream(file.path))
}
else form.append('file', fs.createReadStream(file))
})
} | javascript | function addFilesToData(IOD, IODOpts, apiType, form) {
_.each(T.maybeToArray(IODOpts.files), function(file) {
if (apiType === IOD.TYPES.JOB) {
form.append(file.name, fs.createReadStream(file.path))
}
else form.append('file', fs.createReadStream(file))
})
} | [
"function",
"addFilesToData",
"(",
"IOD",
",",
"IODOpts",
",",
"apiType",
",",
"form",
")",
"{",
"_",
".",
"each",
"(",
"T",
".",
"maybeToArray",
"(",
"IODOpts",
".",
"files",
")",
",",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"apiType",
"===",
... | Add files to FormData object.
Modifies `IODOpts` in place.
@param {IOD} IOD - IOD object
@param {Object} IODOpts - IOD options
@param {String} apiType - IOD request type
@param {FormData} form - FormData object | [
"Add",
"files",
"to",
"FormData",
"object",
"."
] | a346628f9bc5e4420e4d00e8f21c4cb268b6237c | https://github.com/benzhou1/iod/blob/a346628f9bc5e4420e4d00e8f21c4cb268b6237c/lib/send.js#L175-L182 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/fakeobjects/plugin.js | replaceCssLength | function replaceCssLength( length1, length2 ) {
var parts1 = cssLengthRegex.exec( length1 ),
parts2 = cssLengthRegex.exec( length2 );
// Omit pixel length unit when necessary,
// e.g. replaceCssLength( 10, '20px' ) -> 20
if ( parts1 ) {
if ( !parts1[ 2 ] && parts2[ 2 ] == 'px' )
return parts2... | javascript | function replaceCssLength( length1, length2 ) {
var parts1 = cssLengthRegex.exec( length1 ),
parts2 = cssLengthRegex.exec( length2 );
// Omit pixel length unit when necessary,
// e.g. replaceCssLength( 10, '20px' ) -> 20
if ( parts1 ) {
if ( !parts1[ 2 ] && parts2[ 2 ] == 'px' )
return parts2... | [
"function",
"replaceCssLength",
"(",
"length1",
",",
"length2",
")",
"{",
"var",
"parts1",
"=",
"cssLengthRegex",
".",
"exec",
"(",
"length1",
")",
",",
"parts2",
"=",
"cssLengthRegex",
".",
"exec",
"(",
"length2",
")",
";",
"// Omit pixel length unit when neces... | Replacing the former CSS length value with the later one, with adjustment to the length unit. | [
"Replacing",
"the",
"former",
"CSS",
"length",
"value",
"with",
"the",
"later",
"one",
"with",
"adjustment",
"to",
"the",
"length",
"unit",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/fakeobjects/plugin.js#L14-L28 | train |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/UiComponent.js | function() {
var results = [];
for (var i=0, cs=this.controls, c; c=cs[i]; i++) {
if (!c.isChrome) {
results.push(c);
}
}
return results;
} | javascript | function() {
var results = [];
for (var i=0, cs=this.controls, c; c=cs[i]; i++) {
if (!c.isChrome) {
results.push(c);
}
}
return results;
} | [
"function",
"(",
")",
"{",
"var",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"cs",
"=",
"this",
".",
"controls",
",",
"c",
";",
"c",
"=",
"cs",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"c",
"."... | Returns all non-chrome controls. | [
"Returns",
"all",
"non",
"-",
"chrome",
"controls",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/UiComponent.js#L121-L129 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/UiComponent.js | function() {
var c$ = this.getClientControls();
for (var i=0, c; c=c$[i]; i++) {
c.destroy();
}
} | javascript | function() {
var c$ = this.getClientControls();
for (var i=0, c; c=c$[i]; i++) {
c.destroy();
}
} | [
"function",
"(",
")",
"{",
"var",
"c$",
"=",
"this",
".",
"getClientControls",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"c",
";",
"c",
"=",
"c$",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"c",
".",
"destroy",
"(",
")",
";",
"}... | Destroys "client controls", the same set of controls returned by
_getClientControls_. | [
"Destroys",
"client",
"controls",
"the",
"same",
"set",
"of",
"controls",
"returned",
"by",
"_getClientControls_",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/UiComponent.js#L134-L139 | train | |
phated/grunt-enyo | tasks/init/enyo/root/enyo/source/kernel/UiComponent.js | function(inMessage, inPayload, inSender) {
// Note: Controls will generally be both in a $ hash and a child list somewhere.
// Attempt to avoid duplicated messages by sending only to components that are not
// UiComponent, as those components are guaranteed not to be in a child list.
// May cause a problem if t... | javascript | function(inMessage, inPayload, inSender) {
// Note: Controls will generally be both in a $ hash and a child list somewhere.
// Attempt to avoid duplicated messages by sending only to components that are not
// UiComponent, as those components are guaranteed not to be in a child list.
// May cause a problem if t... | [
"function",
"(",
"inMessage",
",",
"inPayload",
",",
"inSender",
")",
"{",
"// Note: Controls will generally be both in a $ hash and a child list somewhere.",
"// Attempt to avoid duplicated messages by sending only to components that are not",
"// UiComponent, as those components are guarante... | Sends a message to all my descendents. | [
"Sends",
"a",
"message",
"to",
"all",
"my",
"descendents",
"."
] | d2990ee4cd85eea8db4108c43086c6d8c3c90c30 | https://github.com/phated/grunt-enyo/blob/d2990ee4cd85eea8db4108c43086c6d8c3c90c30/tasks/init/enyo/root/enyo/source/kernel/UiComponent.js#L246-L269 | 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.