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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
six-plus/omni-di | dependency_injector.js | function(levels) {
for (var i = 0; i < levels.length; ++i) {
var level = levels[i];
for (var j = 0; j < level.length; ++j) {
if (level[j].factory) {
_this.injectAndRegister(level[j].name, level[j].factory);
} else if (level[j].obj) {
_this.register(level... | javascript | function(levels) {
for (var i = 0; i < levels.length; ++i) {
var level = levels[i];
for (var j = 0; j < level.length; ++j) {
if (level[j].factory) {
_this.injectAndRegister(level[j].name, level[j].factory);
} else if (level[j].obj) {
_this.register(level... | [
"function",
"(",
"levels",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"levels",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"level",
"=",
"levels",
"[",
"i",
"]",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"... | Given a dependency graph in topological order, assemble it. | [
"Given",
"a",
"dependency",
"graph",
"in",
"topological",
"order",
"assemble",
"it",
"."
] | 6160562747129695d631622da35dbf4cddd577f0 | https://github.com/six-plus/omni-di/blob/6160562747129695d631622da35dbf4cddd577f0/dependency_injector.js#L64-L75 | train | |
RedKenrok/node-planckmatch | library/index.js | function(value, patterns, options, isPath) {
// Parse patterns, match value per pattern, and return results.
return planckmatch.match(value, planckmatch.parse(patterns, options, isPath));
} | javascript | function(value, patterns, options, isPath) {
// Parse patterns, match value per pattern, and return results.
return planckmatch.match(value, planckmatch.parse(patterns, options, isPath));
} | [
"function",
"(",
"value",
",",
"patterns",
",",
"options",
",",
"isPath",
")",
"{",
"// Parse patterns, match value per pattern, and return results.",
"return",
"planckmatch",
".",
"match",
"(",
"value",
",",
"planckmatch",
".",
"parse",
"(",
"patterns",
",",
"optio... | Matches extended glob patterns with a given value.
@param {String} value A value to match to.
@param {String|Array} patterns An extended glob pattern or array of extended glob patterns.
@param {Object} options Glob pattern to regular expression options.
@param {Boolean} isPath Whether it should adapt the pattern to mat... | [
"Matches",
"extended",
"glob",
"patterns",
"with",
"a",
"given",
"value",
"."
] | eb33f15032272dd835effec862d537ad69abd61c | https://github.com/RedKenrok/node-planckmatch/blob/eb33f15032272dd835effec862d537ad69abd61c/library/index.js#L9-L12 | train | |
justin-calleja/no-dups-validator | lib/index.js | noDups | function noDups (iterable = []) {
return (errMsgPrefix = '') => {
const dups = extractDuplicates(iterable)
return dups.size === 0
? [ true, [] ]
: [ false, [ new Error(errMsgPrefix + Array.from(dups).join(', ')) ] ]
}
} | javascript | function noDups (iterable = []) {
return (errMsgPrefix = '') => {
const dups = extractDuplicates(iterable)
return dups.size === 0
? [ true, [] ]
: [ false, [ new Error(errMsgPrefix + Array.from(dups).join(', ')) ] ]
}
} | [
"function",
"noDups",
"(",
"iterable",
"=",
"[",
"]",
")",
"{",
"return",
"(",
"errMsgPrefix",
"=",
"''",
")",
"=>",
"{",
"const",
"dups",
"=",
"extractDuplicates",
"(",
"iterable",
")",
"return",
"dups",
".",
"size",
"===",
"0",
"?",
"[",
"true",
",... | This function is curried.
@param {Iterable} [iterable=[]] - The iterable whose elements are checked for duplicates
@param {String} [errMsgPrefix=''] - A string to prefix any found duplicates in the error message
@return {Tuple<Boolean, Array<Error>>}
@see {@link module:@justinc/jsdocs.Tuple}
@tutorial curry | [
"This",
"function",
"is",
"curried",
"."
] | 5fea089b825c9c18f04cb299e01da81afb84cf13 | https://github.com/justin-calleja/no-dups-validator/blob/5fea089b825c9c18f04cb299e01da81afb84cf13/lib/index.js#L15-L22 | train |
zerkalica/regexp-string-mapper | lib/regexp-string-mapper.js | RegExpStringMapper | function RegExpStringMapper(options) {
if (!(this instanceof RegExpStringMapper)) {
return new RegExpStringMapper(options);
}
options = options || {};
this._formatters = [];
this.addFormatter(createDefaultFormatter(options.serialize || getSerializeFn()));
this.addFormatter(createMomentFormatter(options.moment))... | javascript | function RegExpStringMapper(options) {
if (!(this instanceof RegExpStringMapper)) {
return new RegExpStringMapper(options);
}
options = options || {};
this._formatters = [];
this.addFormatter(createDefaultFormatter(options.serialize || getSerializeFn()));
this.addFormatter(createMomentFormatter(options.moment))... | [
"function",
"RegExpStringMapper",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"RegExpStringMapper",
")",
")",
"{",
"return",
"new",
"RegExpStringMapper",
"(",
"options",
")",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
";"... | RegExp string mapper
@param {Object} options Options
@param {[String]} options.separator Token match separator, default - %
@param {[Formatter[]]} options.formatters Array of formatters | [
"RegExp",
"string",
"mapper"
] | f4ec8a8c5fed5b34dbf8b48948aff7ba73ba268c | https://github.com/zerkalica/regexp-string-mapper/blob/f4ec8a8c5fed5b34dbf8b48948aff7ba73ba268c/lib/regexp-string-mapper.js#L59-L72 | train |
pierrec/node-atok-parser | lib/parser.js | merge | function merge (a, b, soft) {
for (var k in b)
if (!soft || !a.hasOwnProperty(k)) a[k] = b[k]
return a
} | javascript | function merge (a, b, soft) {
for (var k in b)
if (!soft || !a.hasOwnProperty(k)) a[k] = b[k]
return a
} | [
"function",
"merge",
"(",
"a",
",",
"b",
",",
"soft",
")",
"{",
"for",
"(",
"var",
"k",
"in",
"b",
")",
"if",
"(",
"!",
"soft",
"||",
"!",
"a",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"a",
"[",
"k",
"]",
"=",
"b",
"[",
"k",
"]",
"retur... | Copy properties from one object to another - not replacing if required | [
"Copy",
"properties",
"from",
"one",
"object",
"to",
"another",
"-",
"not",
"replacing",
"if",
"required"
] | 414d39904dff73ffdde049212076c14ca40aa20b | https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/lib/parser.js#L23-L27 | train |
pierrec/node-atok-parser | lib/parser.js | inspect | function inspect (s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
.replace(/"/g, '\\"')
.replace(/\r/g, '\\r')
} | javascript | function inspect (s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
.replace(/"/g, '\\"')
.replace(/\r/g, '\\r')
} | [
"function",
"inspect",
"(",
"s",
")",
"{",
"return",
"s",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'\\\\\\\\'",
")",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"'\\\\n'",
")",
".",
"replace",
"(",
"/",
"\\t",
"/",
"g",
",",
"'\\\\... | Show special characters for display | [
"Show",
"special",
"characters",
"for",
"display"
] | 414d39904dff73ffdde049212076c14ca40aa20b | https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/lib/parser.js#L30-L37 | train |
pierrec/node-atok-parser | lib/parser.js | forwardEvent | function forwardEvent (event) {
var n = Atok.events[event]
, args = []
while (n > 0) args.push('a' + n--)
args = args.join()
return 'atok.on("'
+ event
+ '", function forwardEvent (' + args + ') { self.emit_' + event + '(' + args + ') })'
} | javascript | function forwardEvent (event) {
var n = Atok.events[event]
, args = []
while (n > 0) args.push('a' + n--)
args = args.join()
return 'atok.on("'
+ event
+ '", function forwardEvent (' + args + ') { self.emit_' + event + '(' + args + ') })'
} | [
"function",
"forwardEvent",
"(",
"event",
")",
"{",
"var",
"n",
"=",
"Atok",
".",
"events",
"[",
"event",
"]",
",",
"args",
"=",
"[",
"]",
"while",
"(",
"n",
">",
"0",
")",
"args",
".",
"push",
"(",
"'a'",
"+",
"n",
"--",
")",
"args",
"=",
"a... | Set an event arguments list | [
"Set",
"an",
"event",
"arguments",
"list"
] | 414d39904dff73ffdde049212076c14ca40aa20b | https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/lib/parser.js#L76-L86 | train |
mauritsl/bluegate | bluegate.js | function(log) {
var date = this.date.toISOString().substring(0, 19);
var duration = new Date() - this.date;
log(date + ' ' + this.ip + ' "' + this.method + ' ' + this.path + '" ' + this.status + ' ' + this._length + ' ' + duration);
} | javascript | function(log) {
var date = this.date.toISOString().substring(0, 19);
var duration = new Date() - this.date;
log(date + ' ' + this.ip + ' "' + this.method + ' ' + this.path + '" ' + this.status + ' ' + this._length + ' ' + duration);
} | [
"function",
"(",
"log",
")",
"{",
"var",
"date",
"=",
"this",
".",
"date",
".",
"toISOString",
"(",
")",
".",
"substring",
"(",
"0",
",",
"19",
")",
";",
"var",
"duration",
"=",
"new",
"Date",
"(",
")",
"-",
"this",
".",
"date",
";",
"log",
"("... | Log response.
@param {function} log | [
"Log",
"response",
"."
] | 0760e30841709d2e415b5315cf83225614c6dbfe | https://github.com/mauritsl/bluegate/blob/0760e30841709d2e415b5315cf83225614c6dbfe/bluegate.js#L507-L511 | train | |
mauritsl/bluegate | bluegate.js | function(fn) {
var code = fn.toString();
var match = code.match(/^(?:(?:function)?[\s]*\(([^)]*)\)|([^\=\(]+))/);
var args = (match[1] || match[2]);
if (typeof args === 'undefined') {
return [];
}
return args.split(',').map(function(item) {
return item.trim();
}).filter(function(item) {
return... | javascript | function(fn) {
var code = fn.toString();
var match = code.match(/^(?:(?:function)?[\s]*\(([^)]*)\)|([^\=\(]+))/);
var args = (match[1] || match[2]);
if (typeof args === 'undefined') {
return [];
}
return args.split(',').map(function(item) {
return item.trim();
}).filter(function(item) {
return... | [
"function",
"(",
"fn",
")",
"{",
"var",
"code",
"=",
"fn",
".",
"toString",
"(",
")",
";",
"var",
"match",
"=",
"code",
".",
"match",
"(",
"/",
"^(?:(?:function)?[\\s]*\\(([^)]*)\\)|([^\\=\\(]+))",
"/",
")",
";",
"var",
"args",
"=",
"(",
"match",
"[",
... | List function arguments. | [
"List",
"function",
"arguments",
"."
] | 0760e30841709d2e415b5315cf83225614c6dbfe | https://github.com/mauritsl/bluegate/blob/0760e30841709d2e415b5315cf83225614c6dbfe/bluegate.js#L531-L543 | train | |
aleclarson/is-open-comment | index.js | findTags | function findTags(code) {
const tags = []
findTag(code, '\n', tags)
findTag(code, '//', tags)
findTag(code, '/*', tags)
findTag(code, '*/', tags)
return tags
} | javascript | function findTags(code) {
const tags = []
findTag(code, '\n', tags)
findTag(code, '//', tags)
findTag(code, '/*', tags)
findTag(code, '*/', tags)
return tags
} | [
"function",
"findTags",
"(",
"code",
")",
"{",
"const",
"tags",
"=",
"[",
"]",
"findTag",
"(",
"code",
",",
"'\\n'",
",",
"tags",
")",
"findTag",
"(",
"code",
",",
"'//'",
",",
"tags",
")",
"findTag",
"(",
"code",
",",
"'/*'",
",",
"tags",
")",
"... | Returns a sparse array of comment tags | [
"Returns",
"a",
"sparse",
"array",
"of",
"comment",
"tags"
] | f2f775cbc473afdbfd7f0da49cdfcb9b759a1ca9 | https://github.com/aleclarson/is-open-comment/blob/f2f775cbc473afdbfd7f0da49cdfcb9b759a1ca9/index.js#L67-L74 | train |
leozdgao/elecpen | src/index.js | createLogger | function createLogger (writables, prefix, dateFormat) {
if (!Array.isArray(writables)) writables = [ writables ]
writables = writables.filter(w => isDefined(w) && isFunction(w.write))
debug(`There are ${writables.length} writables for this logger`)
let pre = `[${prefix}]`
// default timestamp format
if (... | javascript | function createLogger (writables, prefix, dateFormat) {
if (!Array.isArray(writables)) writables = [ writables ]
writables = writables.filter(w => isDefined(w) && isFunction(w.write))
debug(`There are ${writables.length} writables for this logger`)
let pre = `[${prefix}]`
// default timestamp format
if (... | [
"function",
"createLogger",
"(",
"writables",
",",
"prefix",
",",
"dateFormat",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"writables",
")",
")",
"writables",
"=",
"[",
"writables",
"]",
"writables",
"=",
"writables",
".",
"filter",
"(",
"w"... | Main method for create logger. The logger is just a function to recieve
the record and write to a stream.
@param {Writable} writable A writable stream for logging
@param {string} prefix The prefix to write
@param {string | bool} date The date format
@return {function} A function use li... | [
"Main",
"method",
"for",
"create",
"logger",
".",
"The",
"logger",
"is",
"just",
"a",
"function",
"to",
"recieve",
"the",
"record",
"and",
"write",
"to",
"a",
"stream",
"."
] | 9048727800efc1a4e1ca9b4526f449b878f851b4 | https://github.com/leozdgao/elecpen/blob/9048727800efc1a4e1ca9b4526f449b878f851b4/src/index.js#L30-L47 | train |
leozdgao/elecpen | src/index.js | useDefaultLogger | function useDefaultLogger (opts) {
const {
infoFile, errFile,
append = true,
timestamp = true, // string for a date format or pass true to use default format
} = opts
// The value of `logToConsole` default to true in dev mode
let logToConsole = opts.logToConsole
if (isDev() && !isDefined(logToCon... | javascript | function useDefaultLogger (opts) {
const {
infoFile, errFile,
append = true,
timestamp = true, // string for a date format or pass true to use default format
} = opts
// The value of `logToConsole` default to true in dev mode
let logToConsole = opts.logToConsole
if (isDev() && !isDefined(logToCon... | [
"function",
"useDefaultLogger",
"(",
"opts",
")",
"{",
"const",
"{",
"infoFile",
",",
"errFile",
",",
"append",
"=",
"true",
",",
"timestamp",
"=",
"true",
",",
"// string for a date format or pass true to use default format",
"}",
"=",
"opts",
"// The value of `logTo... | Construct a default logger, it can record the verbose, info , warning, error message and
write it to the file you specified.
Options:
infoFile: Path of the file for recording verbose and info message.
errFile: Path of the file for recording warning and error message.
append: Decide append or truncate the file if it ex... | [
"Construct",
"a",
"default",
"logger",
"it",
"can",
"record",
"the",
"verbose",
"info",
"warning",
"error",
"message",
"and",
"write",
"it",
"to",
"the",
"file",
"you",
"specified",
"."
] | 9048727800efc1a4e1ca9b4526f449b878f851b4 | https://github.com/leozdgao/elecpen/blob/9048727800efc1a4e1ca9b4526f449b878f851b4/src/index.js#L62-L110 | train |
leozdgao/elecpen | src/index.js | streamRecorder | function streamRecorder () {
let lastKey, lastStream
return (key, createStream) => {
if (isFunction(key)) key = key.call()
debug(`Recorder get key: ${key}`)
if (key !== lastKey) {
debug(`Recorder will return a new stream`)
lastKey = key
lastStream = createStream.call(null, key)
... | javascript | function streamRecorder () {
let lastKey, lastStream
return (key, createStream) => {
if (isFunction(key)) key = key.call()
debug(`Recorder get key: ${key}`)
if (key !== lastKey) {
debug(`Recorder will return a new stream`)
lastKey = key
lastStream = createStream.call(null, key)
... | [
"function",
"streamRecorder",
"(",
")",
"{",
"let",
"lastKey",
",",
"lastStream",
"return",
"(",
"key",
",",
"createStream",
")",
"=>",
"{",
"if",
"(",
"isFunction",
"(",
"key",
")",
")",
"key",
"=",
"key",
".",
"call",
"(",
")",
"debug",
"(",
"`",
... | Record the stream by key
@return {function} A function return stream | [
"Record",
"the",
"stream",
"by",
"key"
] | 9048727800efc1a4e1ca9b4526f449b878f851b4 | https://github.com/leozdgao/elecpen/blob/9048727800efc1a4e1ca9b4526f449b878f851b4/src/index.js#L116-L132 | train |
ezseed/watcher | process/helpers.js | function(arr, iterator) {
var i = arr.length - 1, index = null
if(i >= 0){
do {
if(iterator(arr[i])) {
index = i
break
}
} while(i--)
}
return index
} | javascript | function(arr, iterator) {
var i = arr.length - 1, index = null
if(i >= 0){
do {
if(iterator(arr[i])) {
index = i
break
}
} while(i--)
}
return index
} | [
"function",
"(",
"arr",
",",
"iterator",
")",
"{",
"var",
"i",
"=",
"arr",
".",
"length",
"-",
"1",
",",
"index",
"=",
"null",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"do",
"{",
"if",
"(",
"iterator",
"(",
"arr",
"[",
"i",
"]",
")",
")",
"{",
... | Returnn the first index of the array matching the iterator | [
"Returnn",
"the",
"first",
"index",
"of",
"the",
"array",
"matching",
"the",
"iterator"
] | 63c74abd20d2093ae0b05981802d0cb98e4becdb | https://github.com/ezseed/watcher/blob/63c74abd20d2093ae0b05981802d0cb98e4becdb/process/helpers.js#L11-L24 | train | |
codeactual/long-con | lib/long-con/index.js | LongCon | function LongCon() {
this.settings = {
namespace: '',
nlFirst: false,
quiet: false,
time: false,
traceIndent: ' ',
traceLanes: true
};
this.stackDepth = 0;
this.firstLine = true;
} | javascript | function LongCon() {
this.settings = {
namespace: '',
nlFirst: false,
quiet: false,
time: false,
traceIndent: ' ',
traceLanes: true
};
this.stackDepth = 0;
this.firstLine = true;
} | [
"function",
"LongCon",
"(",
")",
"{",
"this",
".",
"settings",
"=",
"{",
"namespace",
":",
"''",
",",
"nlFirst",
":",
"false",
",",
"quiet",
":",
"false",
",",
"time",
":",
"false",
",",
"traceIndent",
":",
"' '",
",",
"traceLanes",
":",
"true",
"... | LongCon constructor.
Usage:
var longCon = require('long-con').create(); // new LongCon() instance
Example configuration:
loncCon
.set('namespace', 'myLib');
var log = longCon.create('[stderr]', console.error, 'red.bold');
// [stderr] myLib error message: ...
log('error message: %s', ...);
Configuration:
- `{stri... | [
"LongCon",
"constructor",
"."
] | e5fb172636ed2f5668068277efdab062ba1cb05d | https://github.com/codeactual/long-con/blob/e5fb172636ed2f5668068277efdab062ba1cb05d/lib/long-con/index.js#L75-L87 | train |
sittingbool/sbool-node-utils | util/promises.js | promiseWithError | function promiseWithError( err, callback) {
var deferred = Q.defer();
if ( err instanceof Error ) {
deferred.reject( err);
} else {
deferred.reject(new Error(err));
}
if ( typeof callback === 'function' ) {
callback(err, null);
}
... | javascript | function promiseWithError( err, callback) {
var deferred = Q.defer();
if ( err instanceof Error ) {
deferred.reject( err);
} else {
deferred.reject(new Error(err));
}
if ( typeof callback === 'function' ) {
callback(err, null);
}
... | [
"function",
"promiseWithError",
"(",
"err",
",",
"callback",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"if",
"(",
"err",
"instanceof",
"Error",
")",
"{",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"... | Creates a promise that only returns an error to be used when promise is expected
but an error is already known and calls the callback if given
@param err - the error object or message as a string
@param callback - optional, a callback with signature function( error, result).
if given this one will be called despite ret... | [
"Creates",
"a",
"promise",
"that",
"only",
"returns",
"an",
"error",
"to",
"be",
"used",
"when",
"promise",
"is",
"expected",
"but",
"an",
"error",
"is",
"already",
"known",
"and",
"calls",
"the",
"callback",
"if",
"given"
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/promises.js#L15-L26 | train |
sittingbool/sbool-node-utils | util/promises.js | promiseWithError | function promiseWithError( result, callback) {
var deferred = Q.defer();
deferred.resolve(result);
if ( typeof callback === 'function' ) {
callback(null, result);
}
return deferred.promise;
} | javascript | function promiseWithError( result, callback) {
var deferred = Q.defer();
deferred.resolve(result);
if ( typeof callback === 'function' ) {
callback(null, result);
}
return deferred.promise;
} | [
"function",
"promiseWithError",
"(",
"result",
",",
"callback",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"deferred",
".",
"resolve",
"(",
"result",
")",
";",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"ca... | Creates a promise that only returns a result to be used when promise is expected
but the result is already known and calls the callback if given
@param result - the result value
@param callback - optional, a callback with signature function( error, result).
if given this one will be called despite returning a promise
@... | [
"Creates",
"a",
"promise",
"that",
"only",
"returns",
"a",
"result",
"to",
"be",
"used",
"when",
"promise",
"is",
"expected",
"but",
"the",
"result",
"is",
"already",
"known",
"and",
"calls",
"the",
"callback",
"if",
"given"
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/promises.js#L36-L43 | train |
sittingbool/sbool-node-utils | util/promises.js | promiseForCallback | function promiseForCallback( fun, callback) {
var deferred = Q.defer();
fun( function( error, result) {
callback(error, result, deferred);
});
return deferred.promise;
} | javascript | function promiseForCallback( fun, callback) {
var deferred = Q.defer();
fun( function( error, result) {
callback(error, result, deferred);
});
return deferred.promise;
} | [
"function",
"promiseForCallback",
"(",
"fun",
",",
"callback",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"fun",
"(",
"function",
"(",
"error",
",",
"result",
")",
"{",
"callback",
"(",
"error",
",",
"result",
",",
"deferred",
... | Returns a promise handling the function and taking a callback to state what to do with the deferred object
@param fun - the function to be executed
@param callback - the callback with signature function ( err, result, deferred)
@returns {*|promise} - the promise generated | [
"Returns",
"a",
"promise",
"handling",
"the",
"function",
"and",
"taking",
"a",
"callback",
"to",
"state",
"what",
"to",
"do",
"with",
"the",
"deferred",
"object"
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/promises.js#L51-L57 | train |
cartridge/cartridge-static-html | task.js | getDataSource | function getDataSource(projectConfig) {
var api = {};
api.getDataForPath = function getDataForPath(requestedPath) {
var templateData, dataPath;
dataPath = path.resolve(projectConfig.paths.src.views.data, requestedPath + '.json');
try{
templateData = require(dataPath);
} catch(err){
templateData = {};... | javascript | function getDataSource(projectConfig) {
var api = {};
api.getDataForPath = function getDataForPath(requestedPath) {
var templateData, dataPath;
dataPath = path.resolve(projectConfig.paths.src.views.data, requestedPath + '.json');
try{
templateData = require(dataPath);
} catch(err){
templateData = {};... | [
"function",
"getDataSource",
"(",
"projectConfig",
")",
"{",
"var",
"api",
"=",
"{",
"}",
";",
"api",
".",
"getDataForPath",
"=",
"function",
"getDataForPath",
"(",
"requestedPath",
")",
"{",
"var",
"templateData",
",",
"dataPath",
";",
"dataPath",
"=",
"pat... | Basic data source api pending it being split out to another file | [
"Basic",
"data",
"source",
"api",
"pending",
"it",
"being",
"split",
"out",
"to",
"another",
"file"
] | a0ef21f14664cbb24e28f48efff05abf7fd95ff4 | https://github.com/cartridge/cartridge-static-html/blob/a0ef21f14664cbb24e28f48efff05abf7fd95ff4/task.js#L16-L38 | train |
cartridge/cartridge-static-html | task.js | DefaultData | function DefaultData(projectConfig) {
var defaultData = require(path.resolve(projectConfig.paths.src.views.data, '_default.json'));
return {
apply: function apply(data) {
return merge.recursive(defaultData, data);
}
};
} | javascript | function DefaultData(projectConfig) {
var defaultData = require(path.resolve(projectConfig.paths.src.views.data, '_default.json'));
return {
apply: function apply(data) {
return merge.recursive(defaultData, data);
}
};
} | [
"function",
"DefaultData",
"(",
"projectConfig",
")",
"{",
"var",
"defaultData",
"=",
"require",
"(",
"path",
".",
"resolve",
"(",
"projectConfig",
".",
"paths",
".",
"src",
".",
"views",
".",
"data",
",",
"'_default.json'",
")",
")",
";",
"return",
"{",
... | Basic default data source pending it being split out | [
"Basic",
"default",
"data",
"source",
"pending",
"it",
"being",
"split",
"out"
] | a0ef21f14664cbb24e28f48efff05abf7fd95ff4 | https://github.com/cartridge/cartridge-static-html/blob/a0ef21f14664cbb24e28f48efff05abf7fd95ff4/task.js#L41-L49 | train |
heineiuo/express-res-html | lib/index.js | extend | function extend() {
var result = {};
var objs = Array.prototype.slice.call(arguments,0);
objs.forEach(function(props, index){
for(var prop in props) {
if(props.hasOwnProperty(prop)) {
result[prop] = props[prop]
}
}
});
return result;
} | javascript | function extend() {
var result = {};
var objs = Array.prototype.slice.call(arguments,0);
objs.forEach(function(props, index){
for(var prop in props) {
if(props.hasOwnProperty(prop)) {
result[prop] = props[prop]
}
}
});
return result;
} | [
"function",
"extend",
"(",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"var",
"objs",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"objs",
".",
"forEach",
"(",
"function",
"(",
"props",
",",
... | Extend multi objects.
@returns {object} | [
"Extend",
"multi",
"objects",
"."
] | a3bb3adb807885ce052997b9c9316a35d1b2dc76 | https://github.com/heineiuo/express-res-html/blob/a3bb3adb807885ce052997b9c9316a35d1b2dc76/lib/index.js#L213-L224 | train |
charlieroberts/gibber.graphics.lib | scripts/gibber/geometry.js | function() {
obj.mesh[ propertyName ].set( propertyObject.x, propertyObject.y, propertyObject.z )
} | javascript | function() {
obj.mesh[ propertyName ].set( propertyObject.x, propertyObject.y, propertyObject.z )
} | [
"function",
"(",
")",
"{",
"obj",
".",
"mesh",
"[",
"propertyName",
"]",
".",
"set",
"(",
"propertyObject",
".",
"x",
",",
"propertyObject",
".",
"y",
",",
"propertyObject",
".",
"z",
")",
"}"
] | for each vector rotation, scale, position | [
"for",
"each",
"vector",
"rotation",
"scale",
"position"
] | 2b684b04406bf174a3795d3d360e3a3ca39531cf | https://github.com/charlieroberts/gibber.graphics.lib/blob/2b684b04406bf174a3795d3d360e3a3ca39531cf/scripts/gibber/geometry.js#L196-L198 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(point, curve) {
var candidates = [],
w = _convertToBezier(point, curve),
degree = curve.length - 1, higherDegree = (2 * degree) - 1,
numSolutions = _findRoots(w, higherDegree, candidates, 0),
v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;
for (var i = 0; i < numSolut... | javascript | function(point, curve) {
var candidates = [],
w = _convertToBezier(point, curve),
degree = curve.length - 1, higherDegree = (2 * degree) - 1,
numSolutions = _findRoots(w, higherDegree, candidates, 0),
v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;
for (var i = 0; i < numSolut... | [
"function",
"(",
"point",
",",
"curve",
")",
"{",
"var",
"candidates",
"=",
"[",
"]",
",",
"w",
"=",
"_convertToBezier",
"(",
"point",
",",
"curve",
")",
",",
"degree",
"=",
"curve",
".",
"length",
"-",
"1",
",",
"higherDegree",
"=",
"(",
"2",
"*",... | Calculates the distance that the point lies from the curve.
@param point a point in the form {x:567, y:3342}
@param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}]. note that this is currently
hardcoded to assume cubiz beziers, but would be better off supporting any d... | [
"Calculates",
"the",
"distance",
"that",
"the",
"point",
"lies",
"from",
"the",
"curve",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L94-L116 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(point, curve) {
var td = _distanceFromCurve(point, curve);
return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location};
} | javascript | function(point, curve) {
var td = _distanceFromCurve(point, curve);
return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location};
} | [
"function",
"(",
"point",
",",
"curve",
")",
"{",
"var",
"td",
"=",
"_distanceFromCurve",
"(",
"point",
",",
"curve",
")",
";",
"return",
"{",
"point",
":",
"_bezier",
"(",
"curve",
",",
"curve",
".",
"length",
"-",
"1",
",",
"td",
".",
"location",
... | finds the nearest point on the curve to the given point. | [
"finds",
"the",
"nearest",
"point",
"on",
"the",
"curve",
"to",
"the",
"given",
"point",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L120-L123 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(w, degree, t, depth) {
var left = [], right = [],
left_count, right_count,
left_t = [], right_t = [];
switch (_getCrossingCount(w, degree)) {
case 0 : {
return 0;
}
case 1 : {
if (depth >= maxRecursion) {
t[0] = (w[0].x + w[degree].x) / 2.0;
return 1;
}
if (_isFlat... | javascript | function(w, degree, t, depth) {
var left = [], right = [],
left_count, right_count,
left_t = [], right_t = [];
switch (_getCrossingCount(w, degree)) {
case 0 : {
return 0;
}
case 1 : {
if (depth >= maxRecursion) {
t[0] = (w[0].x + w[degree].x) / 2.0;
return 1;
}
if (_isFlat... | [
"function",
"(",
"w",
",",
"degree",
",",
"t",
",",
"depth",
")",
"{",
"var",
"left",
"=",
"[",
"]",
",",
"right",
"=",
"[",
"]",
",",
"left_count",
",",
"right_count",
",",
"left_t",
"=",
"[",
"]",
",",
"right_t",
"=",
"[",
"]",
";",
"switch",... | counts how many roots there are. | [
"counts",
"how",
"many",
"roots",
"there",
"are",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L159-L186 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(curve, location) {
var cc = _getCurveFunctions(curve.length - 1),
_x = 0, _y = 0;
for (var i = 0; i < curve.length ; i++) {
_x = _x + (curve[i].x * cc[i](location));
_y = _y + (curve[i].y * cc[i](location));
}
return {x:_x, y:_y};
} | javascript | function(curve, location) {
var cc = _getCurveFunctions(curve.length - 1),
_x = 0, _y = 0;
for (var i = 0; i < curve.length ; i++) {
_x = _x + (curve[i].x * cc[i](location));
_y = _y + (curve[i].y * cc[i](location));
}
return {x:_x, y:_y};
} | [
"function",
"(",
"curve",
",",
"location",
")",
"{",
"var",
"cc",
"=",
"_getCurveFunctions",
"(",
"curve",
".",
"length",
"-",
"1",
")",
",",
"_x",
"=",
"0",
",",
"_y",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"curve",
... | calculates a point on the curve, for a Bezier of arbitrary order.
@param curve an array of control points, eg [{x:10,y:20}, {x:50,y:50}, {x:100,y:100}, {x:120,y:100}]. For a cubic bezier this should have four points.
@param location a decimal indicating the distance along the curve the point should be located at. thi... | [
"calculates",
"a",
"point",
"on",
"the",
"curve",
"for",
"a",
"Bezier",
"of",
"arbitrary",
"order",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L295-L304 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(curve, location) {
var p1 = _pointOnPath(curve, location),
p2 = _pointOnPath(curve.slice(0, curve.length - 1), location),
dy = p2.y - p1.y, dx = p2.x - p1.x;
return dy == 0 ? Infinity : Math.atan(dy / dx);
} | javascript | function(curve, location) {
var p1 = _pointOnPath(curve, location),
p2 = _pointOnPath(curve.slice(0, curve.length - 1), location),
dy = p2.y - p1.y, dx = p2.x - p1.x;
return dy == 0 ? Infinity : Math.atan(dy / dx);
} | [
"function",
"(",
"curve",
",",
"location",
")",
"{",
"var",
"p1",
"=",
"_pointOnPath",
"(",
"curve",
",",
"location",
")",
",",
"p2",
"=",
"_pointOnPath",
"(",
"curve",
".",
"slice",
"(",
"0",
",",
"curve",
".",
"length",
"-",
"1",
")",
",",
"locat... | returns the gradient of the curve at the given location, which is a decimal between 0 and 1 inclusive.
thanks // http://bimixual.org/AnimationLibrary/beziertangents.html | [
"returns",
"the",
"gradient",
"of",
"the",
"curve",
"at",
"the",
"given",
"location",
"which",
"is",
"a",
"decimal",
"between",
"0",
"and",
"1",
"inclusive",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L380-L385 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(curve, location, distance) {
var p = _pointAlongPath(curve, location, distance);
if (p.location > 1) p.location = 1;
if (p.location < 0) p.location = 0;
return _gradientAtPoint(curve, p.location);
} | javascript | function(curve, location, distance) {
var p = _pointAlongPath(curve, location, distance);
if (p.location > 1) p.location = 1;
if (p.location < 0) p.location = 0;
return _gradientAtPoint(curve, p.location);
} | [
"function",
"(",
"curve",
",",
"location",
",",
"distance",
")",
"{",
"var",
"p",
"=",
"_pointAlongPath",
"(",
"curve",
",",
"location",
",",
"distance",
")",
";",
"if",
"(",
"p",
".",
"location",
">",
"1",
")",
"p",
".",
"location",
"=",
"1",
";",... | returns the gradient of the curve at the point which is 'distance' from the given location.
if this point is greater than location 1, the gradient at location 1 is returned.
if this point is less than location 0, the gradient at location 0 is returned. | [
"returns",
"the",
"gradient",
"of",
"the",
"curve",
"at",
"the",
"point",
"which",
"is",
"distance",
"from",
"the",
"given",
"location",
".",
"if",
"this",
"point",
"is",
"greater",
"than",
"location",
"1",
"the",
"gradient",
"at",
"location",
"1",
"is",
... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L392-L397 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(kObj, scopes, map, fn) {
_each(kObj, function(_kObj) {
_unreg(_kObj, map); // deregister existing scopes
_kObj[fn](scopes); // set scopes
_reg(_kObj, map); // register new ones
});
} | javascript | function(kObj, scopes, map, fn) {
_each(kObj, function(_kObj) {
_unreg(_kObj, map); // deregister existing scopes
_kObj[fn](scopes); // set scopes
_reg(_kObj, map); // register new ones
});
} | [
"function",
"(",
"kObj",
",",
"scopes",
",",
"map",
",",
"fn",
")",
"{",
"_each",
"(",
"kObj",
",",
"function",
"(",
"_kObj",
")",
"{",
"_unreg",
"(",
"_kObj",
",",
"map",
")",
";",
"// deregister existing scopes",
"_kObj",
"[",
"fn",
"]",
"(",
"scop... | does the work of changing scopes | [
"does",
"the",
"work",
"of",
"changing",
"scopes"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L2055-L2061 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (_e) {
_draw(_e[0], uip);
_currentInstance.removeClass(_e[0], "jsplumb-dragged");
_currentInstance.select({source: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true);
_currentInstance.select({target: _e[0]... | javascript | function (_e) {
_draw(_e[0], uip);
_currentInstance.removeClass(_e[0], "jsplumb-dragged");
_currentInstance.select({source: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true);
_currentInstance.select({target: _e[0]... | [
"function",
"(",
"_e",
")",
"{",
"_draw",
"(",
"_e",
"[",
"0",
"]",
",",
"uip",
")",
";",
"_currentInstance",
".",
"removeClass",
"(",
"_e",
"[",
"0",
"]",
",",
"\"jsplumb-dragged\"",
")",
";",
"_currentInstance",
".",
"select",
"(",
"{",
"source",
"... | this is one element | [
"this",
"is",
"one",
"element"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L3556-L3562 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (p) {
if (p) {
for (var i = 0; i < p.childNodes.length; i++) {
if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
var cEl = jsPlumb.getElement(p.childNodes[i]),
cid = _currentInstance.getId(p.childNodes[i], null, true);
if (cid && _elementsWithEndpoints[c... | javascript | function (p) {
if (p) {
for (var i = 0; i < p.childNodes.length; i++) {
if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
var cEl = jsPlumb.getElement(p.childNodes[i]),
cid = _currentInstance.getId(p.childNodes[i], null, true);
if (cid && _elementsWithEndpoints[c... | [
"function",
"(",
"p",
")",
"{",
"if",
"(",
"p",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"p",
".",
"childNodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"p",
".",
"childNodes",
"[",
"i",
"]",
".",
"nodeType",
... | look for child elements that have endpoints and register them against this draggable. | [
"look",
"for",
"child",
"elements",
"that",
"have",
"endpoints",
"and",
"register",
"them",
"against",
"this",
"draggable",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L5957-L5978 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (evt, el, zoom) {
var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left: 0, top: 0, width: 0, height: 0 },
body = document.body,
docElem = document.documentElement,
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
scrollLeft = w... | javascript | function (evt, el, zoom) {
var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left: 0, top: 0, width: 0, height: 0 },
body = document.body,
docElem = document.documentElement,
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
scrollLeft = w... | [
"function",
"(",
"evt",
",",
"el",
",",
"zoom",
")",
"{",
"var",
"box",
"=",
"typeof",
"el",
".",
"getBoundingClientRect",
"!==",
"\"undefined\"",
"?",
"el",
".",
"getBoundingClientRect",
"(",
")",
":",
"{",
"left",
":",
"0",
",",
"top",
":",
"0",
",... | return x+y proportion of the given element's size corresponding to the location of the given event. | [
"return",
"x",
"+",
"y",
"proportion",
"of",
"the",
"given",
"element",
"s",
"size",
"corresponding",
"to",
"the",
"location",
"of",
"the",
"given",
"event",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6322-L6341 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (endpoint, placeholder, _jsPlumb) {
var stopped = false;
return {
drag: function () {
if (stopped) {
stopped = false;
return true;
}
if (placeholder.element) {
var _ui = _jsPlumb.getUIPosition(arguments, _jsPlumb.getZoom());
jsPlumb.setPosition(placeholder.element, _ui);... | javascript | function (endpoint, placeholder, _jsPlumb) {
var stopped = false;
return {
drag: function () {
if (stopped) {
stopped = false;
return true;
}
if (placeholder.element) {
var _ui = _jsPlumb.getUIPosition(arguments, _jsPlumb.getZoom());
jsPlumb.setPosition(placeholder.element, _ui);... | [
"function",
"(",
"endpoint",
",",
"placeholder",
",",
"_jsPlumb",
")",
"{",
"var",
"stopped",
"=",
"false",
";",
"return",
"{",
"drag",
":",
"function",
"(",
")",
"{",
"if",
"(",
"stopped",
")",
"{",
"stopped",
"=",
"false",
";",
"return",
"true",
";... | create the drag handler for a connection | [
"create",
"the",
"drag",
"handler",
"for",
"a",
"connection"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6682-L6704 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (placeholder, _jsPlumb, ipco, ips) {
var n = jsPlumb.createElement("div", { position : "absolute" });
_jsPlumb.appendElement(n);
var id = _jsPlumb.getId(n);
jsPlumb.setPosition(n, ipco);
n.style.width = ips[0] + "px";
n.style.height = ips[1] + "px";
_jsPlumb.manage(id, n, true); // TRANSIENT MANA... | javascript | function (placeholder, _jsPlumb, ipco, ips) {
var n = jsPlumb.createElement("div", { position : "absolute" });
_jsPlumb.appendElement(n);
var id = _jsPlumb.getId(n);
jsPlumb.setPosition(n, ipco);
n.style.width = ips[0] + "px";
n.style.height = ips[1] + "px";
_jsPlumb.manage(id, n, true); // TRANSIENT MANA... | [
"function",
"(",
"placeholder",
",",
"_jsPlumb",
",",
"ipco",
",",
"ips",
")",
"{",
"var",
"n",
"=",
"jsPlumb",
".",
"createElement",
"(",
"\"div\"",
",",
"{",
"position",
":",
"\"absolute\"",
"}",
")",
";",
"_jsPlumb",
".",
"appendElement",
"(",
"n",
... | creates a placeholder div for dragging purposes, adds it, and pre-computes its offset. | [
"creates",
"a",
"placeholder",
"div",
"for",
"dragging",
"purposes",
"adds",
"it",
"and",
"pre",
"-",
"computes",
"its",
"offset",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6707-L6718 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (ep, elementWithPrecedence) {
var idx = 0;
if (elementWithPrecedence != null) {
for (var i = 0; i < ep.connections.length; i++) {
if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) {
idx = i;
break;
}
}
}
return ep.co... | javascript | function (ep, elementWithPrecedence) {
var idx = 0;
if (elementWithPrecedence != null) {
for (var i = 0; i < ep.connections.length; i++) {
if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) {
idx = i;
break;
}
}
}
return ep.co... | [
"function",
"(",
"ep",
",",
"elementWithPrecedence",
")",
"{",
"var",
"idx",
"=",
"0",
";",
"if",
"(",
"elementWithPrecedence",
"!=",
"null",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ep",
".",
"connections",
".",
"length",
";",
"... | a helper function that tries to find a connection to the given element, and returns it if so. if elementWithPrecedence is null, or no connection to it is found, we return the first connection in our list. | [
"a",
"helper",
"function",
"that",
"tries",
"to",
"find",
"a",
"connection",
"to",
"the",
"given",
"element",
"and",
"returns",
"it",
"if",
"so",
".",
"if",
"elementWithPrecedence",
"is",
"null",
"or",
"no",
"connection",
"to",
"it",
"is",
"found",
"we",
... | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6740-L6752 | train | |
skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (a, b, c) {
return c >= Math.min(a, b) && c <= Math.max(a, b);
} | javascript | function (a, b, c) {
return c >= Math.min(a, b) && c <= Math.max(a, b);
} | [
"function",
"(",
"a",
",",
"b",
",",
"c",
")",
"{",
"return",
"c",
">=",
"Math",
".",
"min",
"(",
"a",
",",
"b",
")",
"&&",
"c",
"<=",
"Math",
".",
"max",
"(",
"a",
",",
"b",
")",
";",
"}"
] | is c between a and b? | [
"is",
"c",
"between",
"a",
"and",
"b?"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L9757-L9759 | train | |
DmitryMyadzelets/u-machine | examples/oauth-client/oauth/provider.js | done | function done(req, next, err, obj) {
if (err) {
req.error = {error: err.error || err.message};
} else {
req.provider = obj;
}
next();
} | javascript | function done(req, next, err, obj) {
if (err) {
req.error = {error: err.error || err.message};
} else {
req.provider = obj;
}
next();
} | [
"function",
"done",
"(",
"req",
",",
"next",
",",
"err",
",",
"obj",
")",
"{",
"if",
"(",
"err",
")",
"{",
"req",
".",
"error",
"=",
"{",
"error",
":",
"err",
".",
"error",
"||",
"err",
".",
"message",
"}",
";",
"}",
"else",
"{",
"req",
".",
... | Sets error and data object | [
"Sets",
"error",
"and",
"data",
"object"
] | 1a01636b0211abc148feeda4108383d93368c4c7 | https://github.com/DmitryMyadzelets/u-machine/blob/1a01636b0211abc148feeda4108383d93368c4c7/examples/oauth-client/oauth/provider.js#L9-L16 | train |
DmitryMyadzelets/u-machine | examples/oauth-client/oauth/provider.js | check | function check(err, res, body) {
if (err) {
return this.machine(err);
}
var obj;
try {
obj = JSON.parse(body);
} catch (e) {
return this.machine(new Error('Failed to parse as JSON (' + e.message + ') the text: ' + body));
}
if (res.statusCode !== 200) {
return... | javascript | function check(err, res, body) {
if (err) {
return this.machine(err);
}
var obj;
try {
obj = JSON.parse(body);
} catch (e) {
return this.machine(new Error('Failed to parse as JSON (' + e.message + ') the text: ' + body));
}
if (res.statusCode !== 200) {
return... | [
"function",
"check",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"this",
".",
"machine",
"(",
"err",
")",
";",
"}",
"var",
"obj",
";",
"try",
"{",
"obj",
"=",
"JSON",
".",
"parse",
"(",
"body",
")",
";... | Callback for 'request'. Checks response | [
"Callback",
"for",
"request",
".",
"Checks",
"response"
] | 1a01636b0211abc148feeda4108383d93368c4c7 | https://github.com/DmitryMyadzelets/u-machine/blob/1a01636b0211abc148feeda4108383d93368c4c7/examples/oauth-client/oauth/provider.js#L19-L33 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js | renderTemplatesList | function renderTemplatesList( container, templatesDefinitions ) {
// clear loading wait text.
container.setHtml( '' );
for ( var i = 0, totalDefs = templatesDefinitions.length; i < totalDefs; i++ ) {
var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ),
imagesPath = definition.im... | javascript | function renderTemplatesList( container, templatesDefinitions ) {
// clear loading wait text.
container.setHtml( '' );
for ( var i = 0, totalDefs = templatesDefinitions.length; i < totalDefs; i++ ) {
var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ),
imagesPath = definition.im... | [
"function",
"renderTemplatesList",
"(",
"container",
",",
"templatesDefinitions",
")",
"{",
"// clear loading wait text.\r",
"container",
".",
"setHtml",
"(",
"''",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"totalDefs",
"=",
"templatesDefinitions",
".",
"... | Constructs the HTML view of the specified templates data. | [
"Constructs",
"the",
"HTML",
"view",
"of",
"the",
"specified",
"templates",
"data",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js#L11-L29 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js | insertTemplate | function insertTemplate( html ) {
var dialog = CKEDITOR.dialog.getCurrent(),
isReplace = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' );
if ( isReplace ) {
editor.fire( 'saveSnapshot' );
// Everything should happen after the document is loaded (#4073).
editor.setData( html, function() {
... | javascript | function insertTemplate( html ) {
var dialog = CKEDITOR.dialog.getCurrent(),
isReplace = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' );
if ( isReplace ) {
editor.fire( 'saveSnapshot' );
// Everything should happen after the document is loaded (#4073).
editor.setData( html, function() {
... | [
"function",
"insertTemplate",
"(",
"html",
")",
"{",
"var",
"dialog",
"=",
"CKEDITOR",
".",
"dialog",
".",
"getCurrent",
"(",
")",
",",
"isReplace",
"=",
"dialog",
".",
"getValueOf",
"(",
"'selectTpl'",
",",
"'chkInsertOpt'",
")",
";",
"if",
"(",
"isReplac... | Insert the specified template content into editor. @param {Number} index | [
"Insert",
"the",
"specified",
"template",
"content",
"into",
"editor",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js#L60-L83 | train |
operandom/ProtoTyper | lib/prototyper.js | isProperty | function isProperty(name, value) {
currentProperty = name;
updateDescriptor({
'value': value,
'writable': true,
'enumerable': true,
'configurable': true
});
return this;
} | javascript | function isProperty(name, value) {
currentProperty = name;
updateDescriptor({
'value': value,
'writable': true,
'enumerable': true,
'configurable': true
});
return this;
} | [
"function",
"isProperty",
"(",
"name",
",",
"value",
")",
"{",
"currentProperty",
"=",
"name",
";",
"updateDescriptor",
"(",
"{",
"'value'",
":",
"value",
",",
"'writable'",
":",
"true",
",",
"'enumerable'",
":",
"true",
",",
"'configurable'",
":",
"true",
... | Define a new property
@param {String} name The name of the property to be defined or modified.
@param {String} value The value associated with the property. Can be any valid JavaScript value. Defaults to undefined. | [
"Define",
"a",
"new",
"property"
] | 2e826e1871e049e063cafcc4eb5f7d96e9728c6a | https://github.com/operandom/ProtoTyper/blob/2e826e1871e049e063cafcc4eb5f7d96e9728c6a/lib/prototyper.js#L188-L197 | train |
soldair/pinoccio-serial | index.js | function(cb){
serialport.list(function (err, ports) {
if(err) return cb(err);
var pinoccios = [];
ports.forEach(function(port) {
var pnpId = port.pnpId||port.manufacturer||"";
if(pnpId.indexOf('Pinoccio') > -1){
pinoccios.push(port.comName);
}
... | javascript | function(cb){
serialport.list(function (err, ports) {
if(err) return cb(err);
var pinoccios = [];
ports.forEach(function(port) {
var pnpId = port.pnpId||port.manufacturer||"";
if(pnpId.indexOf('Pinoccio') > -1){
pinoccios.push(port.comName);
}
... | [
"function",
"(",
"cb",
")",
"{",
"serialport",
".",
"list",
"(",
"function",
"(",
"err",
",",
"ports",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"var",
"pinoccios",
"=",
"[",
"]",
";",
"ports",
".",
"forEach",
"(",
... | look for connected pinoccios | [
"look",
"for",
"connected",
"pinoccios"
] | 7a93a663ed51deb13d07d16ce7d185092127d4bf | https://github.com/soldair/pinoccio-serial/blob/7a93a663ed51deb13d07d16ce7d185092127d4bf/index.js#L13-L25 | train | |
torworx/ovy | ovy.functions.js | function(fn, args, scope) {
if (!ovy.isArray(args)) {
if (ovy.isIterable(args)) {
args = arrays.clone(args);
} else {
args = args !== undefined ? [args] : [];
}
}
return function() {
... | javascript | function(fn, args, scope) {
if (!ovy.isArray(args)) {
if (ovy.isIterable(args)) {
args = arrays.clone(args);
} else {
args = args !== undefined ? [args] : [];
}
}
return function() {
... | [
"function",
"(",
"fn",
",",
"args",
",",
"scope",
")",
"{",
"if",
"(",
"!",
"ovy",
".",
"isArray",
"(",
"args",
")",
")",
"{",
"if",
"(",
"ovy",
".",
"isIterable",
"(",
"args",
")",
")",
"{",
"args",
"=",
"arrays",
".",
"clone",
"(",
"args",
... | Create a new function from the provided `fn`, the arguments of which are pre-set to `args`.
New arguments passed to the newly created callback when it's invoked are appended after the pre-set ones.
This is especially useful when creating callbacks.
For example:
var originalFunction = function(){
alert(ovy.arrays.from... | [
"Create",
"a",
"new",
"function",
"from",
"the",
"provided",
"fn",
"the",
"arguments",
"of",
"which",
"are",
"pre",
"-",
"set",
"to",
"args",
".",
"New",
"arguments",
"passed",
"to",
"the",
"newly",
"created",
"callback",
"when",
"it",
"s",
"invoked",
"a... | 18e9727305ab37acee1954a3facdd65b3a3526ab | https://github.com/torworx/ovy/blob/18e9727305ab37acee1954a3facdd65b3a3526ab/ovy.functions.js#L122-L136 | train | |
doowb/layout-stack | index.js | assertLayout | function assertLayout(value, defaultLayout) {
var isFalsey = require('falsey');
if (value === false || (value && isFalsey(value))) {
return null;
} else if (!value || value === true) {
return defaultLayout || null;
} else {
return value;
}
} | javascript | function assertLayout(value, defaultLayout) {
var isFalsey = require('falsey');
if (value === false || (value && isFalsey(value))) {
return null;
} else if (!value || value === true) {
return defaultLayout || null;
} else {
return value;
}
} | [
"function",
"assertLayout",
"(",
"value",
",",
"defaultLayout",
")",
"{",
"var",
"isFalsey",
"=",
"require",
"(",
"'falsey'",
")",
";",
"if",
"(",
"value",
"===",
"false",
"||",
"(",
"value",
"&&",
"isFalsey",
"(",
"value",
")",
")",
")",
"{",
"return"... | Assert whether or not a layout should be used based on
the given `value`. If a layout should be used, the name of the
layout is returned, if not `null` is returned.
@param {*} `value`
@return {String|Null} Returns `true` or `null`.
@api private | [
"Assert",
"whether",
"or",
"not",
"a",
"layout",
"should",
"be",
"used",
"based",
"on",
"the",
"given",
"value",
".",
"If",
"a",
"layout",
"should",
"be",
"used",
"the",
"name",
"of",
"the",
"layout",
"is",
"returned",
"if",
"not",
"null",
"is",
"retur... | 147d592edbcbaf5e37da91b89a99c080456f7bf9 | https://github.com/doowb/layout-stack/blob/147d592edbcbaf5e37da91b89a99c080456f7bf9/index.js#L48-L57 | train |
goddyZhao/message-go | lib/message-go.js | go | function go(from, to){
var toStream;
Step(
function checkParams(){
_checkParams(from, to, this)
},
function(err, checkResult){
var checkResultOfFrom;
var checkResultOfTo;
if(err){
log.error('invalid options');
throw err;
return;
}
checkRes... | javascript | function go(from, to){
var toStream;
Step(
function checkParams(){
_checkParams(from, to, this)
},
function(err, checkResult){
var checkResultOfFrom;
var checkResultOfTo;
if(err){
log.error('invalid options');
throw err;
return;
}
checkRes... | [
"function",
"go",
"(",
"from",
",",
"to",
")",
"{",
"var",
"toStream",
";",
"Step",
"(",
"function",
"checkParams",
"(",
")",
"{",
"_checkParams",
"(",
"from",
",",
"to",
",",
"this",
")",
"}",
",",
"function",
"(",
"err",
",",
"checkResult",
")",
... | Let messages go from FROM to TO
@param {String} from directory or file the messages come from
@param {String} to file the message go to | [
"Let",
"messages",
"go",
"from",
"FROM",
"to",
"TO"
] | bb84ca5b92ce8668ea835d765adbc35aacece402 | https://github.com/goddyZhao/message-go/blob/bb84ca5b92ce8668ea835d765adbc35aacece402/lib/message-go.js#L15-L88 | train |
huafu/ember-dev-fixtures | private/initializers/dev-fixtures.js | readOverlay | function readOverlay(application) {
var possibleValues, value;
if (Ember.testing) {
// when in test mode, use the overlay specified in the application
value = {from: 'test:startApp()', name: application.get('devFixtures.overlay')};
}
else {
// else try many locations
possibleValues = [];
loc... | javascript | function readOverlay(application) {
var possibleValues, value;
if (Ember.testing) {
// when in test mode, use the overlay specified in the application
value = {from: 'test:startApp()', name: application.get('devFixtures.overlay')};
}
else {
// else try many locations
possibleValues = [];
loc... | [
"function",
"readOverlay",
"(",
"application",
")",
"{",
"var",
"possibleValues",
",",
"value",
";",
"if",
"(",
"Ember",
".",
"testing",
")",
"{",
"// when in test mode, use the overlay specified in the application",
"value",
"=",
"{",
"from",
":",
"'test:startApp()'"... | Reads and save the overlay
@function readOverlay
@param {Ember.Application} application
@return {{from: string, name: string|null}} | [
"Reads",
"and",
"save",
"the",
"overlay"
] | 811ed4d339c2dc840d5b297b5b244726cf1339ca | https://github.com/huafu/ember-dev-fixtures/blob/811ed4d339c2dc840d5b297b5b244726cf1339ca/private/initializers/dev-fixtures.js#L26-L64 | train |
frisb/fdboost | lib/enhance/rangereader.js | RangeReader | function RangeReader(options) {
RangeReader.__super__.constructor.call(this);
this.begin = options.begin;
this.end = options.end;
this.marker = null;
this.limit = options.limit;
this.reverse = options.reverse;
this.streamingMode = options.streamingMode;
th... | javascript | function RangeReader(options) {
RangeReader.__super__.constructor.call(this);
this.begin = options.begin;
this.end = options.end;
this.marker = null;
this.limit = options.limit;
this.reverse = options.reverse;
this.streamingMode = options.streamingMode;
th... | [
"function",
"RangeReader",
"(",
"options",
")",
"{",
"RangeReader",
".",
"__super__",
".",
"constructor",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"begin",
"=",
"options",
".",
"begin",
";",
"this",
".",
"end",
"=",
"options",
".",
"end",
";",
... | Creates a new Reader instance
@class
@param {object} options Settings.
@param {(Buffer|fdb.KeySelector)} [options.begin] First key in the reader range.
@param {(Buffer|fdb.KeySelector)}} [options.end=undefined] Last key in the reader range.
@param {number} [options.limit=undefined] Only the first limit keys (and their ... | [
"Creates",
"a",
"new",
"Reader",
"instance"
] | 66cfb6552940aa92f35dbb1cf4d0695d842205c2 | https://github.com/frisb/fdboost/blob/66cfb6552940aa92f35dbb1cf4d0695d842205c2/lib/enhance/rangereader.js#L108-L144 | train |
Pocketbrain/native-ads-web-ad-library | src/util/resolveToken.js | resolveToken | function resolveToken(callback) {
var crossDomainStorageAvailable = crossDomainStorage.isAvailable();
logger.info('Resolving token from OfferEngine');
if (crossDomainStorageAvailable) {
initXDomainStorage(function () {
crossDomainStorage.getItem(appSettings.tokenCookieKey, function (dat... | javascript | function resolveToken(callback) {
var crossDomainStorageAvailable = crossDomainStorage.isAvailable();
logger.info('Resolving token from OfferEngine');
if (crossDomainStorageAvailable) {
initXDomainStorage(function () {
crossDomainStorage.getItem(appSettings.tokenCookieKey, function (dat... | [
"function",
"resolveToken",
"(",
"callback",
")",
"{",
"var",
"crossDomainStorageAvailable",
"=",
"crossDomainStorage",
".",
"isAvailable",
"(",
")",
";",
"logger",
".",
"info",
"(",
"'Resolving token from OfferEngine'",
")",
";",
"if",
"(",
"crossDomainStorageAvailab... | Resolve the token for the user visiting the page
@param callback - The callback that is executed when the token is resolved | [
"Resolve",
"the",
"token",
"for",
"the",
"user",
"visiting",
"the",
"page"
] | aafee1c42e0569ee77f334fc2c4eb71eb146957e | https://github.com/Pocketbrain/native-ads-web-ad-library/blob/aafee1c42e0569ee77f334fc2c4eb71eb146957e/src/util/resolveToken.js#L10-L32 | train |
taoyuan/amqper | lib/routify/router.js | handleMessage | function handleMessage(data) {
const message = data;
message.params = that.parser.parse(data);
message.channel = ch;
message.ack = ack;
// Ack method for the msg
function ack() {
debug('ack delivery', data.fields.deliveryTag);
ch.ack(data);
}
if (Array... | javascript | function handleMessage(data) {
const message = data;
message.params = that.parser.parse(data);
message.channel = ch;
message.ack = ack;
// Ack method for the msg
function ack() {
debug('ack delivery', data.fields.deliveryTag);
ch.ack(data);
}
if (Array... | [
"function",
"handleMessage",
"(",
"data",
")",
"{",
"const",
"message",
"=",
"data",
";",
"message",
".",
"params",
"=",
"that",
".",
"parser",
".",
"parse",
"(",
"data",
")",
";",
"message",
".",
"channel",
"=",
"ch",
";",
"message",
".",
"ack",
"="... | callback which is invoked each time a message matches the configured route. | [
"callback",
"which",
"is",
"invoked",
"each",
"time",
"a",
"message",
"matches",
"the",
"configured",
"route",
"."
] | 7d099e9c238c217aa4d1a6ae3970427c94830180 | https://github.com/taoyuan/amqper/blob/7d099e9c238c217aa4d1a6ae3970427c94830180/lib/routify/router.js#L46-L71 | train |
serebano/bitbox | src/bitbox/resolve.js | proxy | function proxy(target, mapping) {
return new Proxy(mapping, {
get(map, key) {
if (Reflect.has(map, key)) {
return resolve(target, Reflect.get(map, key))
}
},
set(map, key, value) {
if (Reflect.has(map, key)) {
return resolve... | javascript | function proxy(target, mapping) {
return new Proxy(mapping, {
get(map, key) {
if (Reflect.has(map, key)) {
return resolve(target, Reflect.get(map, key))
}
},
set(map, key, value) {
if (Reflect.has(map, key)) {
return resolve... | [
"function",
"proxy",
"(",
"target",
",",
"mapping",
")",
"{",
"return",
"new",
"Proxy",
"(",
"mapping",
",",
"{",
"get",
"(",
"map",
",",
"key",
")",
"{",
"if",
"(",
"Reflect",
".",
"has",
"(",
"map",
",",
"key",
")",
")",
"{",
"return",
"resolve... | bitbox.resolve
@param {Object} target
@param {Function|Array} box
@param {Function} method
@return {Any} | [
"bitbox",
".",
"resolve"
] | 3bca8d7078eca40ec32f654fe5f37d7b72f05d60 | https://github.com/serebano/bitbox/blob/3bca8d7078eca40ec32f654fe5f37d7b72f05d60/src/bitbox/resolve.js#L12-L25 | train |
fernandojsg/useragent-info | index.js | splitPlatformInfo | function splitPlatformInfo(uaList) {
for(var i = 0; i < uaList.length; ++i) {
var item = uaList[i];
if (isEnclosedInParens(item)) {
return removeEmptyElements(trimSpacesInEachElement(item.substr(1, item.length-2).split(';')));
}
}
} | javascript | function splitPlatformInfo(uaList) {
for(var i = 0; i < uaList.length; ++i) {
var item = uaList[i];
if (isEnclosedInParens(item)) {
return removeEmptyElements(trimSpacesInEachElement(item.substr(1, item.length-2).split(';')));
}
}
} | [
"function",
"splitPlatformInfo",
"(",
"uaList",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"uaList",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"item",
"=",
"uaList",
"[",
"i",
"]",
";",
"if",
"(",
"isEnclosedInParens",
"(",
... | Finds the special token in the user agent token list that corresponds to the platform info. This is the first element contained in parentheses that has semicolon delimited elements. Returns the platform info as an array split by the semicolons. | [
"Finds",
"the",
"special",
"token",
"in",
"the",
"user",
"agent",
"token",
"list",
"that",
"corresponds",
"to",
"the",
"platform",
"info",
".",
"This",
"is",
"the",
"first",
"element",
"contained",
"in",
"parentheses",
"that",
"has",
"semicolon",
"delimited",
... | 2afa9d26906a74e8e34b1d54ab537aa9b4023499 | https://github.com/fernandojsg/useragent-info/blob/2afa9d26906a74e8e34b1d54ab537aa9b4023499/index.js#L81-L88 | train |
fernandojsg/useragent-info | index.js | findOS | function findOS(uaPlatformInfo) {
var oses = ['Android', 'BSD', 'Linux', 'Windows', 'iPhone OS', 'Mac OS', 'BSD', 'CrOS', 'Darwin', 'Dragonfly', 'Fedora', 'Gentoo', 'Ubuntu', 'debian', 'HP-UX', 'IRIX', 'SunOS', 'Macintosh', 'Win 9x', 'Win98', 'Win95', 'WinNT'];
for(var os in oses) {
for(var i in uaPlatformInfo)... | javascript | function findOS(uaPlatformInfo) {
var oses = ['Android', 'BSD', 'Linux', 'Windows', 'iPhone OS', 'Mac OS', 'BSD', 'CrOS', 'Darwin', 'Dragonfly', 'Fedora', 'Gentoo', 'Ubuntu', 'debian', 'HP-UX', 'IRIX', 'SunOS', 'Macintosh', 'Win 9x', 'Win98', 'Win95', 'WinNT'];
for(var os in oses) {
for(var i in uaPlatformInfo)... | [
"function",
"findOS",
"(",
"uaPlatformInfo",
")",
"{",
"var",
"oses",
"=",
"[",
"'Android'",
",",
"'BSD'",
",",
"'Linux'",
",",
"'Windows'",
",",
"'iPhone OS'",
",",
"'Mac OS'",
",",
"'BSD'",
",",
"'CrOS'",
",",
"'Darwin'",
",",
"'Dragonfly'",
",",
"'Fedor... | Deduces the operating system from the user agent platform info token list. | [
"Deduces",
"the",
"operating",
"system",
"from",
"the",
"user",
"agent",
"platform",
"info",
"token",
"list",
"."
] | 2afa9d26906a74e8e34b1d54ab537aa9b4023499 | https://github.com/fernandojsg/useragent-info/blob/2afa9d26906a74e8e34b1d54ab537aa9b4023499/index.js#L91-L100 | train |
asleepinglion/ouro | lib/meta/class.js | function(filePath) {
if( path.extname(filePath) === '.js' ) {
filePath = path.dirname(filePath);
}
////console.log(colors.gray('loading meta:'), filePath);
this.filePath = filePath;
var meta = require(filePath + '/meta');
//set the name of the class to the last name value
this.nam... | javascript | function(filePath) {
if( path.extname(filePath) === '.js' ) {
filePath = path.dirname(filePath);
}
////console.log(colors.gray('loading meta:'), filePath);
this.filePath = filePath;
var meta = require(filePath + '/meta');
//set the name of the class to the last name value
this.nam... | [
"function",
"(",
"filePath",
")",
"{",
"if",
"(",
"path",
".",
"extname",
"(",
"filePath",
")",
"===",
"'.js'",
")",
"{",
"filePath",
"=",
"path",
".",
"dirname",
"(",
"filePath",
")",
";",
"}",
"////console.log(colors.gray('loading meta:'), filePath);",
"this... | load a meta file and merge on top of current meta data | [
"load",
"a",
"meta",
"file",
"and",
"merge",
"on",
"top",
"of",
"current",
"meta",
"data"
] | b2956e45790d739b85d51bbd9899698aebc132ba | https://github.com/asleepinglion/ouro/blob/b2956e45790d739b85d51bbd9899698aebc132ba/lib/meta/class.js#L34-L54 | train | |
asleepinglion/ouro | lib/meta/class.js | function() {
//if the name was not set by the last meta file set it based on the file path
if( (!this.name || this.name === 'Class') && typeof this.filePath === 'string' ) {
this.name = path.basename(this.filePath);
}
//make sure the meta object exists
if( typeof this.meta !== 'object' ) {
... | javascript | function() {
//if the name was not set by the last meta file set it based on the file path
if( (!this.name || this.name === 'Class') && typeof this.filePath === 'string' ) {
this.name = path.basename(this.filePath);
}
//make sure the meta object exists
if( typeof this.meta !== 'object' ) {
... | [
"function",
"(",
")",
"{",
"//if the name was not set by the last meta file set it based on the file path",
"if",
"(",
"(",
"!",
"this",
".",
"name",
"||",
"this",
".",
"name",
"===",
"'Class'",
")",
"&&",
"typeof",
"this",
".",
"filePath",
"===",
"'string'",
")",... | process & sanitize meta data | [
"process",
"&",
"sanitize",
"meta",
"data"
] | b2956e45790d739b85d51bbd9899698aebc132ba | https://github.com/asleepinglion/ouro/blob/b2956e45790d739b85d51bbd9899698aebc132ba/lib/meta/class.js#L57-L102 | train | |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/clipboard/plugin.js | addListenersToEditable | function addListenersToEditable() {
var editable = editor.editable();
// We'll be catching all pasted content in one line, regardless of whether
// it's introduced by a document command execution (e.g. toolbar buttons) or
// user paste behaviors (e.g. CTRL+V).
editable.on( mainPasteEvent, function... | javascript | function addListenersToEditable() {
var editable = editor.editable();
// We'll be catching all pasted content in one line, regardless of whether
// it's introduced by a document command execution (e.g. toolbar buttons) or
// user paste behaviors (e.g. CTRL+V).
editable.on( mainPasteEvent, function... | [
"function",
"addListenersToEditable",
"(",
")",
"{",
"var",
"editable",
"=",
"editor",
".",
"editable",
"(",
")",
";",
"// We'll be catching all pasted content in one line, regardless of whether\r",
"// it's introduced by a document command execution (e.g. toolbar buttons) or\r",
"//... | Add events listeners to editable. | [
"Add",
"events",
"listeners",
"to",
"editable",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/clipboard/plugin.js#L393-L501 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/clipboard/plugin.js | createCutCopyCmd | function createCutCopyCmd( type ) {
return {
type: type,
canUndo: type == 'cut', // We can't undo copy to clipboard.
startDisabled: true,
exec: function( data ) {
// Attempts to execute the Cut and Copy operations.
function tryToCutCopy( type ) {
if ( CKEDITOR.env.ie )
... | javascript | function createCutCopyCmd( type ) {
return {
type: type,
canUndo: type == 'cut', // We can't undo copy to clipboard.
startDisabled: true,
exec: function( data ) {
// Attempts to execute the Cut and Copy operations.
function tryToCutCopy( type ) {
if ( CKEDITOR.env.ie )
... | [
"function",
"createCutCopyCmd",
"(",
"type",
")",
"{",
"return",
"{",
"type",
":",
"type",
",",
"canUndo",
":",
"type",
"==",
"'cut'",
",",
"// We can't undo copy to clipboard.\r",
"startDisabled",
":",
"true",
",",
"exec",
":",
"function",
"(",
"data",
")",
... | Create object representing Cut or Copy commands. | [
"Create",
"object",
"representing",
"Cut",
"or",
"Copy",
"commands",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/clipboard/plugin.js#L504-L534 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/clipboard/plugin.js | tryToCutCopy | function tryToCutCopy( type ) {
if ( CKEDITOR.env.ie )
return execIECommand( type );
// non-IEs part
try {
// Other browsers throw an error if the command is disabled.
return editor.document.$.execCommand( type, false, null );
} catch ( e ) {
return false;
... | javascript | function tryToCutCopy( type ) {
if ( CKEDITOR.env.ie )
return execIECommand( type );
// non-IEs part
try {
// Other browsers throw an error if the command is disabled.
return editor.document.$.execCommand( type, false, null );
} catch ( e ) {
return false;
... | [
"function",
"tryToCutCopy",
"(",
"type",
")",
"{",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
")",
"return",
"execIECommand",
"(",
"type",
")",
";",
"// non-IEs part\r",
"try",
"{",
"// Other browsers throw an error if the command is disabled.\r",
"return",
"edit... | Attempts to execute the Cut and Copy operations. | [
"Attempts",
"to",
"execute",
"the",
"Cut",
"and",
"Copy",
"operations",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/clipboard/plugin.js#L511-L522 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/clipboard/plugin.js | execIECommand | function execIECommand( command ) {
var doc = editor.document,
body = doc.getBody(),
enabled = false,
onExec = function() {
enabled = true;
};
// The following seems to be the only reliable way to detect that
// clipboard commands are enabled in IE. It will fire the
// onpast... | javascript | function execIECommand( command ) {
var doc = editor.document,
body = doc.getBody(),
enabled = false,
onExec = function() {
enabled = true;
};
// The following seems to be the only reliable way to detect that
// clipboard commands are enabled in IE. It will fire the
// onpast... | [
"function",
"execIECommand",
"(",
"command",
")",
"{",
"var",
"doc",
"=",
"editor",
".",
"document",
",",
"body",
"=",
"doc",
".",
"getBody",
"(",
")",
",",
"enabled",
"=",
"false",
",",
"onExec",
"=",
"function",
"(",
")",
"{",
"enabled",
"=",
"true... | Tries to execute any of the paste, cut or copy commands in IE. Returns a boolean indicating that the operation succeeded. @param {String} command *LOWER CASED* name of command ('paste', 'cut', 'copy'). | [
"Tries",
"to",
"execute",
"any",
"of",
"the",
"paste",
"cut",
"or",
"copy",
"commands",
"in",
"IE",
".",
"Returns",
"a",
"boolean",
"indicating",
"that",
"the",
"operation",
"succeeded",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/clipboard/plugin.js#L586-L606 | train |
skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/clipboard/plugin.js | onKey | function onKey( event ) {
if ( editor.mode != 'wysiwyg' )
return;
switch ( event.data.keyCode ) {
// Paste
case CKEDITOR.CTRL + 86: // CTRL+V
case CKEDITOR.SHIFT + 45: // SHIFT+INS
var editable = editor.editable();
// Cancel 'paste' event because ctrl+v is for IE handled
... | javascript | function onKey( event ) {
if ( editor.mode != 'wysiwyg' )
return;
switch ( event.data.keyCode ) {
// Paste
case CKEDITOR.CTRL + 86: // CTRL+V
case CKEDITOR.SHIFT + 45: // SHIFT+INS
var editable = editor.editable();
// Cancel 'paste' event because ctrl+v is for IE handled
... | [
"function",
"onKey",
"(",
"event",
")",
"{",
"if",
"(",
"editor",
".",
"mode",
"!=",
"'wysiwyg'",
")",
"return",
";",
"switch",
"(",
"event",
".",
"data",
".",
"keyCode",
")",
"{",
"// Paste\r",
"case",
"CKEDITOR",
".",
"CTRL",
"+",
"86",
":",
"// CT... | Listens for some clipboard related keystrokes, so they get customized. Needs to be bind to keydown event. | [
"Listens",
"for",
"some",
"clipboard",
"related",
"keystrokes",
"so",
"they",
"get",
"customized",
".",
"Needs",
"to",
"be",
"bind",
"to",
"keydown",
"event",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/clipboard/plugin.js#L854-L882 | train |
lipcoin/lipcore-p2p | lib/peer.js | Peer | function Peer(options) {
/* jshint maxstatements: 26 */
/* jshint maxcomplexity: 8 */
if (!(this instanceof Peer)) {
return new Peer(options);
}
if (options.socket) {
this.socket = options.socket;
this.host = this.socket.remoteAddress;
this.port = this.socket.remotePort;
this.status = Pe... | javascript | function Peer(options) {
/* jshint maxstatements: 26 */
/* jshint maxcomplexity: 8 */
if (!(this instanceof Peer)) {
return new Peer(options);
}
if (options.socket) {
this.socket = options.socket;
this.host = this.socket.remoteAddress;
this.port = this.socket.remotePort;
this.status = Pe... | [
"function",
"Peer",
"(",
"options",
")",
"{",
"/* jshint maxstatements: 26 */",
"/* jshint maxcomplexity: 8 */",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Peer",
")",
")",
"{",
"return",
"new",
"Peer",
"(",
"options",
")",
";",
"}",
"if",
"(",
"options",
"... | The Peer constructor will create an instance of Peer to send and receive messages
using the standard Bitcoin protocol. A Peer instance represents one connection
on the Bitcoin network. To create a new peer connection provide the host and port
options and then invoke the connect method. Additionally, a newly connected s... | [
"The",
"Peer",
"constructor",
"will",
"create",
"an",
"instance",
"of",
"Peer",
"to",
"send",
"and",
"receive",
"messages",
"using",
"the",
"standard",
"Bitcoin",
"protocol",
".",
"A",
"Peer",
"instance",
"represents",
"one",
"connection",
"on",
"the",
"Bitcoi... | d2000feb9ffdc6390a47981f1663c1ab71aa1de9 | https://github.com/lipcoin/lipcore-p2p/blob/d2000feb9ffdc6390a47981f1663c1ab71aa1de9/lib/peer.js#L40-L107 | train |
rhyolight/github-data | lib/commit.js | Commit | function Commit(source, githubClient) {
this.gh = githubClient;
this.sha = source.sha;
this.htmlUrl = source.html_url;
this.author = source.author;
this.committer = source.committer;
this.message = source.message;
this.treeSha = source.tree.sha;
this.tree = undefined;
} | javascript | function Commit(source, githubClient) {
this.gh = githubClient;
this.sha = source.sha;
this.htmlUrl = source.html_url;
this.author = source.author;
this.committer = source.committer;
this.message = source.message;
this.treeSha = source.tree.sha;
this.tree = undefined;
} | [
"function",
"Commit",
"(",
"source",
",",
"githubClient",
")",
"{",
"this",
".",
"gh",
"=",
"githubClient",
";",
"this",
".",
"sha",
"=",
"source",
".",
"sha",
";",
"this",
".",
"htmlUrl",
"=",
"source",
".",
"html_url",
";",
"this",
".",
"author",
"... | A git commit object. Contains a tree.
@class Commit
@param source {Object} JSON response from API, used to build.
@param githubClient {Object} GitHub API Client object.
@constructor | [
"A",
"git",
"commit",
"object",
".",
"Contains",
"a",
"tree",
"."
] | 5d6a3fc0e7ecfeaec03e4815b0940c2d9ce07d64 | https://github.com/rhyolight/github-data/blob/5d6a3fc0e7ecfeaec03e4815b0940c2d9ce07d64/lib/commit.js#L10-L19 | train |
rranauro/boxspringjs | helpers.js | function(obj, d) {
var k;
d = typeof d === 'undefined' ? 0 : d;
d += 1;
for (k in obj) {
if (obj.hasOwnProperty(k) && _.isObject(obj[k])) {
return depth(obj[k], d);
}
}
return (d);
} | javascript | function(obj, d) {
var k;
d = typeof d === 'undefined' ? 0 : d;
d += 1;
for (k in obj) {
if (obj.hasOwnProperty(k) && _.isObject(obj[k])) {
return depth(obj[k], d);
}
}
return (d);
} | [
"function",
"(",
"obj",
",",
"d",
")",
"{",
"var",
"k",
";",
"d",
"=",
"typeof",
"d",
"===",
"'undefined'",
"?",
"0",
":",
"d",
";",
"d",
"+=",
"1",
";",
"for",
"(",
"k",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
... | calculate the hierarchical depth of an object | [
"calculate",
"the",
"hierarchical",
"depth",
"of",
"an",
"object"
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/helpers.js#L162-L173 | train | |
rranauro/boxspringjs | helpers.js | function(year) {
var yr;
if (!year) {
// initialize date "buckets" for year and month;
year = [1900, 2100];
this._years = {};
for (yr = year[0]; yr <= year[1]; yr += 1) {
this._years[yr] = new Year(yr);
}
} else {
this.year = year;
}
return this;
} | javascript | function(year) {
var yr;
if (!year) {
// initialize date "buckets" for year and month;
year = [1900, 2100];
this._years = {};
for (yr = year[0]; yr <= year[1]; yr += 1) {
this._years[yr] = new Year(yr);
}
} else {
this.year = year;
}
return this;
} | [
"function",
"(",
"year",
")",
"{",
"var",
"yr",
";",
"if",
"(",
"!",
"year",
")",
"{",
"// initialize date \"buckets\" for year and month;",
"year",
"=",
"[",
"1900",
",",
"2100",
"]",
";",
"this",
".",
"_years",
"=",
"{",
"}",
";",
"for",
"(",
"yr",
... | define an object for time buckets | [
"define",
"an",
"object",
"for",
"time",
"buckets"
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/helpers.js#L433-L448 | train | |
rranauro/boxspringjs | helpers.js | function() {
var _findYear = function(years) {
return _.toInt( _.reduce(years, function(res, year) {
return res || ((this._years[year].sum() > 0) ? year : undefined);
}, undefined, this) );
};
if (!_findYear.call(this, _.keys(this._years))) {
return [];
}
return _.range( _findYear.call(this, _.keys(this... | javascript | function() {
var _findYear = function(years) {
return _.toInt( _.reduce(years, function(res, year) {
return res || ((this._years[year].sum() > 0) ? year : undefined);
}, undefined, this) );
};
if (!_findYear.call(this, _.keys(this._years))) {
return [];
}
return _.range( _findYear.call(this, _.keys(this... | [
"function",
"(",
")",
"{",
"var",
"_findYear",
"=",
"function",
"(",
"years",
")",
"{",
"return",
"_",
".",
"toInt",
"(",
"_",
".",
"reduce",
"(",
"years",
",",
"function",
"(",
"res",
",",
"year",
")",
"{",
"return",
"res",
"||",
"(",
"(",
"this... | return the beginning of the range at the first accumulated value and the end of the range at the last accumulated value; | [
"return",
"the",
"beginning",
"of",
"the",
"range",
"at",
"the",
"first",
"accumulated",
"value",
"and",
"the",
"end",
"of",
"the",
"range",
"at",
"the",
"last",
"accumulated",
"value",
";"
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/helpers.js#L504-L515 | train | |
rranauro/boxspringjs | helpers.js | function(hash) {
return function(row) {
var testValue = function(value, rowValue) {
if (value === '*' || value === '' || !value) {
return true;
}
if (_.isString(rowValue)) {
return (rowValue.toLowerCase() === value.toLowerCase());
}
if (_.isArray(rowValue)) {
return (_.contains(_.map(rowVa... | javascript | function(hash) {
return function(row) {
var testValue = function(value, rowValue) {
if (value === '*' || value === '' || !value) {
return true;
}
if (_.isString(rowValue)) {
return (rowValue.toLowerCase() === value.toLowerCase());
}
if (_.isArray(rowValue)) {
return (_.contains(_.map(rowVa... | [
"function",
"(",
"hash",
")",
"{",
"return",
"function",
"(",
"row",
")",
"{",
"var",
"testValue",
"=",
"function",
"(",
"value",
",",
"rowValue",
")",
"{",
"if",
"(",
"value",
"===",
"'*'",
"||",
"value",
"===",
"''",
"||",
"!",
"value",
")",
"{",... | matcher returns a function based on the provided hash. The new function takes the query hash and returns true only if all property values in the query match each property value in the subject; | [
"matcher",
"returns",
"a",
"function",
"based",
"on",
"the",
"provided",
"hash",
".",
"The",
"new",
"function",
"takes",
"the",
"query",
"hash",
"and",
"returns",
"true",
"only",
"if",
"all",
"property",
"values",
"in",
"the",
"query",
"match",
"each",
"pr... | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/helpers.js#L676-L712 | train | |
rranauro/boxspringjs | helpers.js | function(json) {
return({
values: json,
depth: 1,
// map over all rows to get the set of properties available in each document
series_list: _.reduce(json, function(res, row, key) {
return _.uniq( res.concat( _.plain( row ).keys().value() ) );
}, [])
});
} | javascript | function(json) {
return({
values: json,
depth: 1,
// map over all rows to get the set of properties available in each document
series_list: _.reduce(json, function(res, row, key) {
return _.uniq( res.concat( _.plain( row ).keys().value() ) );
}, [])
});
} | [
"function",
"(",
"json",
")",
"{",
"return",
"(",
"{",
"values",
":",
"json",
",",
"depth",
":",
"1",
",",
"// map over all rows to get the set of properties available in each document",
"series_list",
":",
"_",
".",
"reduce",
"(",
"json",
",",
"function",
"(",
... | format a collection of Rows into a json object compatible with the Google-Vis helper library. | [
"format",
"a",
"collection",
"of",
"Rows",
"into",
"a",
"json",
"object",
"compatible",
"with",
"the",
"Google",
"-",
"Vis",
"helper",
"library",
"."
] | 43fd13ae45ba5b16ba9144084b96748a1cd8c0ea | https://github.com/rranauro/boxspringjs/blob/43fd13ae45ba5b16ba9144084b96748a1cd8c0ea/helpers.js#L1017-L1027 | train | |
gaiajs/gaiajs | lib/router/index.js | logRoute | function logRoute(routeConfig, filters) {
filters = filters ? filters.join(', ') : "";
$log.info(
'{method="%s", path="%s", filters="%s"} bind on controller %s#%s',
routeConfig.method,
routeConfig.path,
filters,
routeConfig.controller,
... | javascript | function logRoute(routeConfig, filters) {
filters = filters ? filters.join(', ') : "";
$log.info(
'{method="%s", path="%s", filters="%s"} bind on controller %s#%s',
routeConfig.method,
routeConfig.path,
filters,
routeConfig.controller,
... | [
"function",
"logRoute",
"(",
"routeConfig",
",",
"filters",
")",
"{",
"filters",
"=",
"filters",
"?",
"filters",
".",
"join",
"(",
"', '",
")",
":",
"\"\"",
";",
"$log",
".",
"info",
"(",
"'{method=\"%s\", path=\"%s\", filters=\"%s\"} bind on controller %s#%s'",
"... | helper for log route | [
"helper",
"for",
"log",
"route"
] | a8ebc50274b83bed8bed007e691761bdc3b52eaa | https://github.com/gaiajs/gaiajs/blob/a8ebc50274b83bed8bed007e691761bdc3b52eaa/lib/router/index.js#L15-L25 | train |
gaiajs/gaiajs | lib/router/index.js | generateGenericControllers | function generateGenericControllers(controllers, models) {
var genericControllers = {},
genericRoute = [];
models.forEach(function(model) {
var persistence = $database.getPersistenceOfModel(model);
if (null == persistence) {
throw new Error('');
... | javascript | function generateGenericControllers(controllers, models) {
var genericControllers = {},
genericRoute = [];
models.forEach(function(model) {
var persistence = $database.getPersistenceOfModel(model);
if (null == persistence) {
throw new Error('');
... | [
"function",
"generateGenericControllers",
"(",
"controllers",
",",
"models",
")",
"{",
"var",
"genericControllers",
"=",
"{",
"}",
",",
"genericRoute",
"=",
"[",
"]",
";",
"models",
".",
"forEach",
"(",
"function",
"(",
"model",
")",
"{",
"var",
"persistence... | Generate genereic controllers | [
"Generate",
"genereic",
"controllers"
] | a8ebc50274b83bed8bed007e691761bdc3b52eaa | https://github.com/gaiajs/gaiajs/blob/a8ebc50274b83bed8bed007e691761bdc3b52eaa/lib/router/index.js#L61-L147 | train |
thlorenz/pdetail | pdetail.js | detailRange | function detailRange(cards) {
if (cache.has(cards)) return cache.get(cards)
var [ r1, r2, suitedness ] = cards
if (r1 === r2) return addPairDetails(r1, new Set())
if (ranks.indexOf(r1) > ranks.indexOf(r2)) {
const tmp = r1; r1 = r2; r2 = tmp
}
var res
if (suitedness === 's') res = addSuitedDetails(... | javascript | function detailRange(cards) {
if (cache.has(cards)) return cache.get(cards)
var [ r1, r2, suitedness ] = cards
if (r1 === r2) return addPairDetails(r1, new Set())
if (ranks.indexOf(r1) > ranks.indexOf(r2)) {
const tmp = r1; r1 = r2; r2 = tmp
}
var res
if (suitedness === 's') res = addSuitedDetails(... | [
"function",
"detailRange",
"(",
"cards",
")",
"{",
"if",
"(",
"cache",
".",
"has",
"(",
"cards",
")",
")",
"return",
"cache",
".",
"get",
"(",
"cards",
")",
"var",
"[",
"r1",
",",
"r2",
",",
"suitedness",
"]",
"=",
"cards",
"if",
"(",
"r1",
"==="... | Provides all possible combinations of a given part of a card range.
```
'99' => '9h9s', '9h9d', '9h9c', '9s9d', '9s9c', '9d9c'
'AKs' => 'AhKh', 'AsKs', 'AdKd', 'AcKc'
'KQo' => 'KhQs', 'KhQd', 'KhQc', 'KsQh', 'KsQd', 'KsQc',
'KdQh', 'KdQs', 'KdQc', 'KcQh', 'KcQs', 'KcQd'
'JT' => 'JhTh', 'JhTs', 'JhTd', 'JhTc', 'Js... | [
"Provides",
"all",
"possible",
"combinations",
"of",
"a",
"given",
"part",
"of",
"a",
"card",
"range",
"."
] | ab2acfb3701fa2892689a1918cbd3b63f9b3feea | https://github.com/thlorenz/pdetail/blob/ab2acfb3701fa2892689a1918cbd3b63f9b3feea/pdetail.js#L118-L134 | train |
thlorenz/pdetail | pdetail.js | rangeFromDetail | function rangeFromDetail(set) {
const pairs = new Map()
const suiteds = new Map()
const offsuits = new Map()
function updateMap(map, key, val) {
if (!map.has(key)) map.set(key, new Set())
map.get(key).add(val)
}
for (const cards of set) {
var [ r1, s1, r2, s2 ] = cards
if (r1 === r2) {
... | javascript | function rangeFromDetail(set) {
const pairs = new Map()
const suiteds = new Map()
const offsuits = new Map()
function updateMap(map, key, val) {
if (!map.has(key)) map.set(key, new Set())
map.get(key).add(val)
}
for (const cards of set) {
var [ r1, s1, r2, s2 ] = cards
if (r1 === r2) {
... | [
"function",
"rangeFromDetail",
"(",
"set",
")",
"{",
"const",
"pairs",
"=",
"new",
"Map",
"(",
")",
"const",
"suiteds",
"=",
"new",
"Map",
"(",
")",
"const",
"offsuits",
"=",
"new",
"Map",
"(",
")",
"function",
"updateMap",
"(",
"map",
",",
"key",
",... | Calculates a range from the detail combos, i.e. obtained via `detailRange`.
@name rangeFromDetail
@function
@parm {Set} set of combinations to obtain a range for
@return object with the following props:
- {Map} pairs: all pairs found grouped, i.e. `AA: { AdAs, AdAc ... }`
- {Map} suiteds: all suiteds found grouped, i.... | [
"Calculates",
"a",
"range",
"from",
"the",
"detail",
"combos",
"i",
".",
"e",
".",
"obtained",
"via",
"detailRange",
"."
] | ab2acfb3701fa2892689a1918cbd3b63f9b3feea | https://github.com/thlorenz/pdetail/blob/ab2acfb3701fa2892689a1918cbd3b63f9b3feea/pdetail.js#L150-L194 | train |
eush77/cmpby | index.js | fixArgs | function fixArgs (callee) {
return (options, fn) => {
if (typeof fn != 'function' && typeof options == 'function') {
fn = options;
options = {};
}
else {
options = options || {};
}
options.asc = options.asc || options.asc == null;
return callee(options, fn);
};
} | javascript | function fixArgs (callee) {
return (options, fn) => {
if (typeof fn != 'function' && typeof options == 'function') {
fn = options;
options = {};
}
else {
options = options || {};
}
options.asc = options.asc || options.asc == null;
return callee(options, fn);
};
} | [
"function",
"fixArgs",
"(",
"callee",
")",
"{",
"return",
"(",
"options",
",",
"fn",
")",
"=>",
"{",
"if",
"(",
"typeof",
"fn",
"!=",
"'function'",
"&&",
"typeof",
"options",
"==",
"'function'",
")",
"{",
"fn",
"=",
"options",
";",
"options",
"=",
"{... | Deal with missing arguments and default values. | [
"Deal",
"with",
"missing",
"arguments",
"and",
"default",
"values",
"."
] | 480afc8b513acb872fe09627ebf2876c1e51c63c | https://github.com/eush77/cmpby/blob/480afc8b513acb872fe09627ebf2876c1e51c63c/index.js#L39-L53 | train |
eush77/cmpby | index.js | compare | function compare (options, less, x, y) {
const ifLess = options.asc ? -1 : 1;
return less(x, y) ? ifLess
: less(y, x) ? -ifLess
: 0;
} | javascript | function compare (options, less, x, y) {
const ifLess = options.asc ? -1 : 1;
return less(x, y) ? ifLess
: less(y, x) ? -ifLess
: 0;
} | [
"function",
"compare",
"(",
"options",
",",
"less",
",",
"x",
",",
"y",
")",
"{",
"const",
"ifLess",
"=",
"options",
".",
"asc",
"?",
"-",
"1",
":",
"1",
";",
"return",
"less",
"(",
"x",
",",
"y",
")",
"?",
"ifLess",
":",
"less",
"(",
"y",
",... | Core comparator logic. | [
"Core",
"comparator",
"logic",
"."
] | 480afc8b513acb872fe09627ebf2876c1e51c63c | https://github.com/eush77/cmpby/blob/480afc8b513acb872fe09627ebf2876c1e51c63c/index.js#L57-L63 | train |
quorrajs/elixir | index.js | overrideConfig | function overrideConfig() {
_.merge(Elixir.config, require(path.join(process.cwd(), 'elixirConfig.js')));
} | javascript | function overrideConfig() {
_.merge(Elixir.config, require(path.join(process.cwd(), 'elixirConfig.js')));
} | [
"function",
"overrideConfig",
"(",
")",
"{",
"_",
".",
"merge",
"(",
"Elixir",
".",
"config",
",",
"require",
"(",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'elixirConfig.js'",
")",
")",
")",
";",
"}"
] | Allow for config overrides, via an elixirConfig.js file. | [
"Allow",
"for",
"config",
"overrides",
"via",
"an",
"elixirConfig",
".",
"js",
"file",
"."
] | 3390f81bc07c948b1d4295cb1963ec2a9ce2ca9a | https://github.com/quorrajs/elixir/blob/3390f81bc07c948b1d4295cb1963ec2a9ce2ca9a/index.js#L24-L26 | train |
quorrajs/elixir | index.js | overrideTasks | function overrideTasks() {
function noop() {
Elixir.log.heading.error('Quorra don\'t have php tests!')
}
Elixir.extend('phpSpec', noop);
Elixir.extend('phpunit', noop);
Elixir.extend('babel', function () {
new Elixir.Task('babel', function () {
Elixir.log.heading('Alert!... | javascript | function overrideTasks() {
function noop() {
Elixir.log.heading.error('Quorra don\'t have php tests!')
}
Elixir.extend('phpSpec', noop);
Elixir.extend('phpunit', noop);
Elixir.extend('babel', function () {
new Elixir.Task('babel', function () {
Elixir.log.heading('Alert!... | [
"function",
"overrideTasks",
"(",
")",
"{",
"function",
"noop",
"(",
")",
"{",
"Elixir",
".",
"log",
".",
"heading",
".",
"error",
"(",
"'Quorra don\\'t have php tests!'",
")",
"}",
"Elixir",
".",
"extend",
"(",
"'phpSpec'",
",",
"noop",
")",
";",
"Elixir"... | Ovrride some of the tasks provided by the laravel-elixir module | [
"Ovrride",
"some",
"of",
"the",
"tasks",
"provided",
"by",
"the",
"laravel",
"-",
"elixir",
"module"
] | 3390f81bc07c948b1d4295cb1963ec2a9ce2ca9a | https://github.com/quorrajs/elixir/blob/3390f81bc07c948b1d4295cb1963ec2a9ce2ca9a/index.js#L31-L46 | train |
alessioalex/npm-dep-chain | index.js | getNpmData | function getNpmData(pkg, npmClient, callback) {
callback = once(callback);
// default to latest version
if (!pkg.version || pkg.version === 'latest') {
pkg.version = '*';
}
npmClient.get(pkg.name, { staleOk: true }, errTo(callback, function(npmPackageInfo) {
var version;
version = semver.maxSa... | javascript | function getNpmData(pkg, npmClient, callback) {
callback = once(callback);
// default to latest version
if (!pkg.version || pkg.version === 'latest') {
pkg.version = '*';
}
npmClient.get(pkg.name, { staleOk: true }, errTo(callback, function(npmPackageInfo) {
var version;
version = semver.maxSa... | [
"function",
"getNpmData",
"(",
"pkg",
",",
"npmClient",
",",
"callback",
")",
"{",
"callback",
"=",
"once",
"(",
"callback",
")",
";",
"// default to latest version",
"if",
"(",
"!",
"pkg",
".",
"version",
"||",
"pkg",
".",
"version",
"===",
"'latest'",
")... | Fetches data from the NPM registry for a package based on its name and version range.
It will find the maximum version that satisfies the range.
@param {Object} pkg - contains version and name of the package
@param {Object} npmClient - instance of npm-pkginfo
@param {Function} callback | [
"Fetches",
"data",
"from",
"the",
"NPM",
"registry",
"for",
"a",
"package",
"based",
"on",
"its",
"name",
"and",
"version",
"range",
".",
"It",
"will",
"find",
"the",
"maximum",
"version",
"that",
"satisfies",
"the",
"range",
"."
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/index.js#L24-L47 | train |
alessioalex/npm-dep-chain | index.js | getBulkNpmData | function getBulkNpmData(pkgs, collection, npmClient, callback) {
var next, results;
results = [];
next = after(pkgs.length, function(err) {
return callback(err, results);
});
pkgs.forEach(function(pkg) {
// make sure not to make unnecessary queries to the registry
if (isDuplicate(collection[p... | javascript | function getBulkNpmData(pkgs, collection, npmClient, callback) {
var next, results;
results = [];
next = after(pkgs.length, function(err) {
return callback(err, results);
});
pkgs.forEach(function(pkg) {
// make sure not to make unnecessary queries to the registry
if (isDuplicate(collection[p... | [
"function",
"getBulkNpmData",
"(",
"pkgs",
",",
"collection",
",",
"npmClient",
",",
"callback",
")",
"{",
"var",
"next",
",",
"results",
";",
"results",
"=",
"[",
"]",
";",
"next",
"=",
"after",
"(",
"pkgs",
".",
"length",
",",
"function",
"(",
"err",... | Fetches data from the NPM registry for all the packages provided.
@param {Array} pkgs - an array of packages objects containing the name && version props
@param {Object} collection - collection of processed packages
@param {Object} npmClient - instance of npm-registry-client
@param {Function} callback | [
"Fetches",
"data",
"from",
"the",
"NPM",
"registry",
"for",
"all",
"the",
"packages",
"provided",
"."
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/index.js#L57-L77 | train |
alessioalex/npm-dep-chain | index.js | mapDependencies | function mapDependencies(dependencies) {
var deps;
deps = (dependencies) ? Object.keys(dependencies) : [];
return deps.map(function(name) {
return {
name: name,
version: dependencies[name]
};
});
} | javascript | function mapDependencies(dependencies) {
var deps;
deps = (dependencies) ? Object.keys(dependencies) : [];
return deps.map(function(name) {
return {
name: name,
version: dependencies[name]
};
});
} | [
"function",
"mapDependencies",
"(",
"dependencies",
")",
"{",
"var",
"deps",
";",
"deps",
"=",
"(",
"dependencies",
")",
"?",
"Object",
".",
"keys",
"(",
"dependencies",
")",
":",
"[",
"]",
";",
"return",
"deps",
".",
"map",
"(",
"function",
"(",
"name... | Map the dependencies object to an array containing name && value properties.
@param {Object} dependencies
@returns {Array} | [
"Map",
"the",
"dependencies",
"object",
"to",
"an",
"array",
"containing",
"name",
"&&",
"value",
"properties",
"."
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/index.js#L85-L96 | train |
alessioalex/npm-dep-chain | index.js | isDuplicate | function isDuplicate(pkg, version) {
var versions;
// no duplicates
if (pkg) {
versions = Object.keys(pkg);
if (versions.length && semver.maxSatisfying(versions, version)) {
return true;
}
}
return false;
} | javascript | function isDuplicate(pkg, version) {
var versions;
// no duplicates
if (pkg) {
versions = Object.keys(pkg);
if (versions.length && semver.maxSatisfying(versions, version)) {
return true;
}
}
return false;
} | [
"function",
"isDuplicate",
"(",
"pkg",
",",
"version",
")",
"{",
"var",
"versions",
";",
"// no duplicates",
"if",
"(",
"pkg",
")",
"{",
"versions",
"=",
"Object",
".",
"keys",
"(",
"pkg",
")",
";",
"if",
"(",
"versions",
".",
"length",
"&&",
"semver",... | Check if a version of a package already exists
@param {Object} pkg - an object with the keys representing the versions of a module
@param {String} version - version range
@returns {Array}
TODO: refactor this, first arg should be versions instead | [
"Check",
"if",
"a",
"version",
"of",
"a",
"package",
"already",
"exists"
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/index.js#L106-L119 | train |
alessioalex/npm-dep-chain | index.js | addToQueue | function addToQueue(queue, packageInfo) {
var exists;
function matchesVersion(version, range) {
var matches;
try {
matches = semver.satisfies(packageInfo.version, item.version);
}
catch (err) {
matches = false;
}
return matches;
}
exists = queue.some(function(item) {
... | javascript | function addToQueue(queue, packageInfo) {
var exists;
function matchesVersion(version, range) {
var matches;
try {
matches = semver.satisfies(packageInfo.version, item.version);
}
catch (err) {
matches = false;
}
return matches;
}
exists = queue.some(function(item) {
... | [
"function",
"addToQueue",
"(",
"queue",
",",
"packageInfo",
")",
"{",
"var",
"exists",
";",
"function",
"matchesVersion",
"(",
"version",
",",
"range",
")",
"{",
"var",
"matches",
";",
"try",
"{",
"matches",
"=",
"semver",
".",
"satisfies",
"(",
"packageIn... | Add the package to the queue in case the name && version doen't exist or
the version range isn't matched.
@param {Object} queue - contains packages info from NPM registry
@param {String} packageInfo - data retrieved from the NPM registry for a package | [
"Add",
"the",
"package",
"to",
"the",
"queue",
"in",
"case",
"the",
"name",
"&&",
"version",
"doen",
"t",
"exist",
"or",
"the",
"version",
"range",
"isn",
"t",
"matched",
"."
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/index.js#L154-L183 | train |
alessioalex/npm-dep-chain | index.js | processDeps | function processDeps(queue, collection, callback, errBack) {
return errTo(errBack, function(packages) {
var deps;
packages.forEach(function(pkg) {
// add the package to the collection of processed packages
addPackage(collection, pkg);
// if the module has dependencies, add them to the proc... | javascript | function processDeps(queue, collection, callback, errBack) {
return errTo(errBack, function(packages) {
var deps;
packages.forEach(function(pkg) {
// add the package to the collection of processed packages
addPackage(collection, pkg);
// if the module has dependencies, add them to the proc... | [
"function",
"processDeps",
"(",
"queue",
",",
"collection",
",",
"callback",
",",
"errBack",
")",
"{",
"return",
"errTo",
"(",
"errBack",
",",
"function",
"(",
"packages",
")",
"{",
"var",
"deps",
";",
"packages",
".",
"forEach",
"(",
"function",
"(",
"p... | Add the packages to the "results" collection and add their direct
dependencies to the `queue` so they can be processed later. When all done,
invoke callback.
@param {Object} queue
@param {Object} collection
@param {Function} callback | [
"Add",
"the",
"packages",
"to",
"the",
"results",
"collection",
"and",
"add",
"their",
"direct",
"dependencies",
"to",
"the",
"queue",
"so",
"they",
"can",
"be",
"processed",
"later",
".",
"When",
"all",
"done",
"invoke",
"callback",
"."
] | 2ec7c18dc48fbdf1a997760321c75e984f73810c | https://github.com/alessioalex/npm-dep-chain/blob/2ec7c18dc48fbdf1a997760321c75e984f73810c/index.js#L223-L242 | train |
sitegui/this-commit | index.js | getGitFolder | function getGitFolder() {
// Based on logic in Module._nodeModulePaths at
// https://github.com/joyent/node/blob/master/lib/module.js
var from = path.resolve('.'),
parts = from.split(process.platform === 'win32' ? /[\/\\]/ : /\//),
tip, dir
for (tip = parts.length - 1; tip >= 0; tip--) {
dir = parts.slice(0,... | javascript | function getGitFolder() {
// Based on logic in Module._nodeModulePaths at
// https://github.com/joyent/node/blob/master/lib/module.js
var from = path.resolve('.'),
parts = from.split(process.platform === 'win32' ? /[\/\\]/ : /\//),
tip, dir
for (tip = parts.length - 1; tip >= 0; tip--) {
dir = parts.slice(0,... | [
"function",
"getGitFolder",
"(",
")",
"{",
"// Based on logic in Module._nodeModulePaths at",
"// https://github.com/joyent/node/blob/master/lib/module.js",
"var",
"from",
"=",
"path",
".",
"resolve",
"(",
"'.'",
")",
",",
"parts",
"=",
"from",
".",
"split",
"(",
"proce... | Find the absolute path for the git folder
@returns {string} - '' if not found | [
"Find",
"the",
"absolute",
"path",
"for",
"the",
"git",
"folder"
] | 46bce14f3c5625cb3c18ca958a0591c074d6698c | https://github.com/sitegui/this-commit/blob/46bce14f3c5625cb3c18ca958a0591c074d6698c/index.js#L43-L62 | train |
sitegui/this-commit | index.js | readRef | function readRef(gitFolder, refName) {
var ref
try {
ref = fs.readFileSync(path.join(gitFolder, refName), 'utf8').trim()
return isSHA1(ref) ? ref : ''
} catch (e) {
// Last chance: read from packed-refs
return readPackedRef(gitFolder, refName)
}
} | javascript | function readRef(gitFolder, refName) {
var ref
try {
ref = fs.readFileSync(path.join(gitFolder, refName), 'utf8').trim()
return isSHA1(ref) ? ref : ''
} catch (e) {
// Last chance: read from packed-refs
return readPackedRef(gitFolder, refName)
}
} | [
"function",
"readRef",
"(",
"gitFolder",
",",
"refName",
")",
"{",
"var",
"ref",
"try",
"{",
"ref",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"gitFolder",
",",
"refName",
")",
",",
"'utf8'",
")",
".",
"trim",
"(",
")",
"return",
... | Return the commit name for the given ref name
@param {string} gitFolder
@param {string} refName
@returns {string} - '' if not found | [
"Return",
"the",
"commit",
"name",
"for",
"the",
"given",
"ref",
"name"
] | 46bce14f3c5625cb3c18ca958a0591c074d6698c | https://github.com/sitegui/this-commit/blob/46bce14f3c5625cb3c18ca958a0591c074d6698c/index.js#L70-L79 | train |
sitegui/this-commit | index.js | readPackedRef | function readPackedRef(gitFolder, refName) {
var packedRefs, i, each, match
try {
packedRefs = fs.readFileSync(path.join(gitFolder, 'packed-refs'), 'utf8').split(/\r?\n/)
} catch (e) {
return ''
}
for (i = 0; i < packedRefs.length; i++) {
each = packedRefs[i].trim()
// Look for lines like:
// 1d6f5f98... | javascript | function readPackedRef(gitFolder, refName) {
var packedRefs, i, each, match
try {
packedRefs = fs.readFileSync(path.join(gitFolder, 'packed-refs'), 'utf8').split(/\r?\n/)
} catch (e) {
return ''
}
for (i = 0; i < packedRefs.length; i++) {
each = packedRefs[i].trim()
// Look for lines like:
// 1d6f5f98... | [
"function",
"readPackedRef",
"(",
"gitFolder",
",",
"refName",
")",
"{",
"var",
"packedRefs",
",",
"i",
",",
"each",
",",
"match",
"try",
"{",
"packedRefs",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"gitFolder",
",",
"'packed-refs'",
... | Return the commit name for the given ref name from packed-refs file
@param {string} gitFolder
@param {string} refName
@returns {string} - '' if not found | [
"Return",
"the",
"commit",
"name",
"for",
"the",
"given",
"ref",
"name",
"from",
"packed",
"-",
"refs",
"file"
] | 46bce14f3c5625cb3c18ca958a0591c074d6698c | https://github.com/sitegui/this-commit/blob/46bce14f3c5625cb3c18ca958a0591c074d6698c/index.js#L87-L107 | train |
jl-/gulp-docy | docstrap/Gruntfile.js | jsdocCommand | function jsdocCommand( jsdoc ) {
var cmd = [];
cmd.unshift( jsdoc.options );
if ( jsdoc.tutorials.length > 0 ) {
cmd.push( "-u " + path.resolve( jsdoc.tutorials ) );
}
cmd.push( "-d " + path.resolve( jsdoc.dest ) );
cmd.push( "-t " + path.resolve( jsdoc.template ) );
cmd.push( "-c " + path.resolve( jsd... | javascript | function jsdocCommand( jsdoc ) {
var cmd = [];
cmd.unshift( jsdoc.options );
if ( jsdoc.tutorials.length > 0 ) {
cmd.push( "-u " + path.resolve( jsdoc.tutorials ) );
}
cmd.push( "-d " + path.resolve( jsdoc.dest ) );
cmd.push( "-t " + path.resolve( jsdoc.template ) );
cmd.push( "-c " + path.resolve( jsd... | [
"function",
"jsdocCommand",
"(",
"jsdoc",
")",
"{",
"var",
"cmd",
"=",
"[",
"]",
";",
"cmd",
".",
"unshift",
"(",
"jsdoc",
".",
"options",
")",
";",
"if",
"(",
"jsdoc",
".",
"tutorials",
".",
"length",
">",
"0",
")",
"{",
"cmd",
".",
"push",
"(",... | Normalizes all paths from a JSDoc task definition and and returns an executable string that can be passed to the shell.
@param {object} jsdoc A JSDoc definition
@returns {string} | [
"Normalizes",
"all",
"paths",
"from",
"a",
"JSDoc",
"task",
"definition",
"and",
"and",
"returns",
"an",
"executable",
"string",
"that",
"can",
"be",
"passed",
"to",
"the",
"shell",
"."
] | 40c2ba2da57c8ddb0a877340acc9a0604b1bafb4 | https://github.com/jl-/gulp-docy/blob/40c2ba2da57c8ddb0a877340acc9a0604b1bafb4/docstrap/Gruntfile.js#L81-L97 | train |
jl-/gulp-docy | docstrap/Gruntfile.js | getBootSwatchList | function getBootSwatchList( done ) {
var options = {
hostname : 'api.bootswatch.com',
port : 80,
path : '/',
method : 'GET'
};
var body = "";
var req = http.request( options, function ( res ) {
res.setEncoding( 'utf8' );
res.on( 'data', function ( chunk ) {
body += chunk;
} );... | javascript | function getBootSwatchList( done ) {
var options = {
hostname : 'api.bootswatch.com',
port : 80,
path : '/',
method : 'GET'
};
var body = "";
var req = http.request( options, function ( res ) {
res.setEncoding( 'utf8' );
res.on( 'data', function ( chunk ) {
body += chunk;
} );... | [
"function",
"getBootSwatchList",
"(",
"done",
")",
"{",
"var",
"options",
"=",
"{",
"hostname",
":",
"'api.bootswatch.com'",
",",
"port",
":",
"80",
",",
"path",
":",
"'/'",
",",
"method",
":",
"'GET'",
"}",
";",
"var",
"body",
"=",
"\"\"",
";",
"var",... | Gets the list of available Bootswatches from, well, Bootswatch.
@see http://news.bootswatch.com/post/22193315172/bootswatch-api
@param {function(err, responseBody)} done The callback when complete
@param {?object} done.err If an error occurred, you will find it here.
@param {object} done.responseBody This is a parsed ... | [
"Gets",
"the",
"list",
"of",
"available",
"Bootswatches",
"from",
"well",
"Bootswatch",
"."
] | 40c2ba2da57c8ddb0a877340acc9a0604b1bafb4 | https://github.com/jl-/gulp-docy/blob/40c2ba2da57c8ddb0a877340acc9a0604b1bafb4/docstrap/Gruntfile.js#L362-L388 | train |
jl-/gulp-docy | docstrap/Gruntfile.js | getBootSwatchComponent | function getBootSwatchComponent( url, done ) {
var body = "";
var req = http.request( url, function ( res ) {
res.setEncoding( 'utf8' );
res.on( 'data', function ( chunk ) {
body += chunk;
} );
res.on( 'end', function () {
done( null, body );
} );
res.on( 'error', function ( e ) {
do... | javascript | function getBootSwatchComponent( url, done ) {
var body = "";
var req = http.request( url, function ( res ) {
res.setEncoding( 'utf8' );
res.on( 'data', function ( chunk ) {
body += chunk;
} );
res.on( 'end', function () {
done( null, body );
} );
res.on( 'error', function ( e ) {
do... | [
"function",
"getBootSwatchComponent",
"(",
"url",
",",
"done",
")",
"{",
"var",
"body",
"=",
"\"\"",
";",
"var",
"req",
"=",
"http",
".",
"request",
"(",
"url",
",",
"function",
"(",
"res",
")",
"{",
"res",
".",
"setEncoding",
"(",
"'utf8'",
")",
";"... | This method will get one of the components from Bootswatch, which is generally a `less` file or a `lessVariables` file.
@see http://news.bootswatch.com/post/22193315172/bootswatch-api
@param {string} url The url to retreive from
@param {function(err, responseText)} done The callback when complete
@param {?object} done... | [
"This",
"method",
"will",
"get",
"one",
"of",
"the",
"components",
"from",
"Bootswatch",
"which",
"is",
"generally",
"a",
"less",
"file",
"or",
"a",
"lessVariables",
"file",
"."
] | 40c2ba2da57c8ddb0a877340acc9a0604b1bafb4 | https://github.com/jl-/gulp-docy/blob/40c2ba2da57c8ddb0a877340acc9a0604b1bafb4/docstrap/Gruntfile.js#L400-L420 | train |
junmer/is-otf | index.js | getViewTag | function getViewTag(view, offset) {
var tag = '', i;
for (i = offset; i < offset + 4; i += 1) {
tag += String.fromCharCode(view.getInt8(i));
}
return tag;
} | javascript | function getViewTag(view, offset) {
var tag = '', i;
for (i = offset; i < offset + 4; i += 1) {
tag += String.fromCharCode(view.getInt8(i));
}
return tag;
} | [
"function",
"getViewTag",
"(",
"view",
",",
"offset",
")",
"{",
"var",
"tag",
"=",
"''",
",",
"i",
";",
"for",
"(",
"i",
"=",
"offset",
";",
"i",
"<",
"offset",
"+",
"4",
";",
"i",
"+=",
"1",
")",
"{",
"tag",
"+=",
"String",
".",
"fromCharCode"... | Retrieve a 4-character tag from the DataView.
@param {DataView} view DataView
@param {number} strLen string length
@param {number} byteOffset byteOffset
@return {string} string | [
"Retrieve",
"a",
"4",
"-",
"character",
"tag",
"from",
"the",
"DataView",
"."
] | c42b15e09602ce92ac1cc16c24b6fbd4a3f336d2 | https://github.com/junmer/is-otf/blob/c42b15e09602ce92ac1cc16c24b6fbd4a3f336d2/index.js#L65-L71 | train |
andornaut/react-keybinding-mixin | index.js | function() {
// The last component to be unmounted uninstalls the event listener.
if (components.length == 0) {
document.removeEventListener(EVENT_TYPE, dispatchEvent);
}
components.splice(components.indexOf(this), 1);
} | javascript | function() {
// The last component to be unmounted uninstalls the event listener.
if (components.length == 0) {
document.removeEventListener(EVENT_TYPE, dispatchEvent);
}
components.splice(components.indexOf(this), 1);
} | [
"function",
"(",
")",
"{",
"// The last component to be unmounted uninstalls the event listener.",
"if",
"(",
"components",
".",
"length",
"==",
"0",
")",
"{",
"document",
".",
"removeEventListener",
"(",
"EVENT_TYPE",
",",
"dispatchEvent",
")",
";",
"}",
"components"... | Un-register for keyboard events. | [
"Un",
"-",
"register",
"for",
"keyboard",
"events",
"."
] | 7429700964968bf82b69a6f45e3855b3d306e83e | https://github.com/andornaut/react-keybinding-mixin/blob/7429700964968bf82b69a6f45e3855b3d306e83e/index.js#L103-L109 | train | |
andornaut/react-keybinding-mixin | index.js | function(key, callback, options) {
var binding;
key = key.charCodeAt ? key.toUpperCase().charCodeAt() : key;
options = assign({}, DEFAULT_OPTIONS, options || {});
binding = { callback: callback, options: options };
if (!this.keyBindings[key]) {
this.keyBindings[key]... | javascript | function(key, callback, options) {
var binding;
key = key.charCodeAt ? key.toUpperCase().charCodeAt() : key;
options = assign({}, DEFAULT_OPTIONS, options || {});
binding = { callback: callback, options: options };
if (!this.keyBindings[key]) {
this.keyBindings[key]... | [
"function",
"(",
"key",
",",
"callback",
",",
"options",
")",
"{",
"var",
"binding",
";",
"key",
"=",
"key",
".",
"charCodeAt",
"?",
"key",
".",
"toUpperCase",
"(",
")",
".",
"charCodeAt",
"(",
")",
":",
"key",
";",
"options",
"=",
"assign",
"(",
"... | Bind a callback to the keydown event for a particular key.
The options argument may contain booleans which describe the modifier
keys to which the key-binding should apply. If options.input is true,
then the supplied callback will be invoked even if the keydown event
is triggered on an input field or button.
@param {... | [
"Bind",
"a",
"callback",
"to",
"the",
"keydown",
"event",
"for",
"a",
"particular",
"key",
"."
] | 7429700964968bf82b69a6f45e3855b3d306e83e | https://github.com/andornaut/react-keybinding-mixin/blob/7429700964968bf82b69a6f45e3855b3d306e83e/index.js#L125-L137 | train | |
tunnckoCore/request-all | index.js | normalize | function normalize (url, opts, callback) {
url = typeof url === 'string' ? {url: url} : url
opts = extend(url, opts)
if (typeof opts.url !== 'string') {
throw new TypeError('request-all: missing request url')
}
if (typeof callback !== 'function') {
throw new TypeError('request-all: expect a callback'... | javascript | function normalize (url, opts, callback) {
url = typeof url === 'string' ? {url: url} : url
opts = extend(url, opts)
if (typeof opts.url !== 'string') {
throw new TypeError('request-all: missing request url')
}
if (typeof callback !== 'function') {
throw new TypeError('request-all: expect a callback'... | [
"function",
"normalize",
"(",
"url",
",",
"opts",
",",
"callback",
")",
"{",
"url",
"=",
"typeof",
"url",
"===",
"'string'",
"?",
"{",
"url",
":",
"url",
"}",
":",
"url",
"opts",
"=",
"extend",
"(",
"url",
",",
"opts",
")",
"if",
"(",
"typeof",
"... | > Normalize and validate arguments and options
@param {String|Object} `url`
@param {Object} `opts`
@param {Function} `callback`
@return {Object} | [
">",
"Normalize",
"and",
"validate",
"arguments",
"and",
"options"
] | 5cbdf42d7f0999742acdf4f7394ad530b7ff5655 | https://github.com/tunnckoCore/request-all/blob/5cbdf42d7f0999742acdf4f7394ad530b7ff5655/index.js#L64-L83 | train |
tunnckoCore/request-all | index.js | normalizeUrl | function normalizeUrl (url) {
if (!url || /per_page=/.test(url)) return url
/* istanbul ignore next */
if ((/&/.test(url) && !/&$/.test(url)) || (!/\?$/.test(url) && /\?/.test(url))) {
return url + '&per_page=100'
}
return /\?$/.test(url) ? url + 'per_page=100' : url + '?per_page=100'
} | javascript | function normalizeUrl (url) {
if (!url || /per_page=/.test(url)) return url
/* istanbul ignore next */
if ((/&/.test(url) && !/&$/.test(url)) || (!/\?$/.test(url) && /\?/.test(url))) {
return url + '&per_page=100'
}
return /\?$/.test(url) ? url + 'per_page=100' : url + '?per_page=100'
} | [
"function",
"normalizeUrl",
"(",
"url",
")",
"{",
"if",
"(",
"!",
"url",
"||",
"/",
"per_page=",
"/",
".",
"test",
"(",
"url",
")",
")",
"return",
"url",
"/* istanbul ignore next */",
"if",
"(",
"(",
"/",
"&",
"/",
".",
"test",
"(",
"url",
")",
"&&... | > Normalize URL query
@param {String} `url`
@return {String} | [
">",
"Normalize",
"URL",
"query"
] | 5cbdf42d7f0999742acdf4f7394ad530b7ff5655 | https://github.com/tunnckoCore/request-all/blob/5cbdf42d7f0999742acdf4f7394ad530b7ff5655/index.js#L92-L99 | train |
tunnckoCore/request-all | index.js | tryParse | function tryParse (val) {
var res = null
try {
res = JSON.parse(val.toString())
} catch (err) {
res = err
}
return res
} | javascript | function tryParse (val) {
var res = null
try {
res = JSON.parse(val.toString())
} catch (err) {
res = err
}
return res
} | [
"function",
"tryParse",
"(",
"val",
")",
"{",
"var",
"res",
"=",
"null",
"try",
"{",
"res",
"=",
"JSON",
".",
"parse",
"(",
"val",
".",
"toString",
"(",
")",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"res",
"=",
"err",
"}",
"return",
"res",
"}"
... | > Catch JSON parse errors
@param {Buffer} `val`
@return {String|Array|Error} | [
">",
"Catch",
"JSON",
"parse",
"errors"
] | 5cbdf42d7f0999742acdf4f7394ad530b7ff5655 | https://github.com/tunnckoCore/request-all/blob/5cbdf42d7f0999742acdf4f7394ad530b7ff5655/index.js#L134-L142 | train |
gtriggiano/dnsmq-messagebus | src/SubConnection.js | connect | function connect (master) {
if (_socket && _socket._master.name === master.name) {
debug(`already connected to master ${master.name}`)
return
}
if (_connectingMaster && _connectingMaster.name === master.name) {
debug(`already connecting to master ${master.name}`)
return
}
_c... | javascript | function connect (master) {
if (_socket && _socket._master.name === master.name) {
debug(`already connected to master ${master.name}`)
return
}
if (_connectingMaster && _connectingMaster.name === master.name) {
debug(`already connecting to master ${master.name}`)
return
}
_c... | [
"function",
"connect",
"(",
"master",
")",
"{",
"if",
"(",
"_socket",
"&&",
"_socket",
".",
"_master",
".",
"name",
"===",
"master",
".",
"name",
")",
"{",
"debug",
"(",
"`",
"${",
"master",
".",
"name",
"}",
"`",
")",
"return",
"}",
"if",
"(",
"... | creates a new sub socket and tries to connect it to the provided master;
after connection the socket is used to receive messages from the bus
and an eventual previous socket is closed
@param {object} master
@return {object} the subscribeConnection instance | [
"creates",
"a",
"new",
"sub",
"socket",
"and",
"tries",
"to",
"connect",
"it",
"to",
"the",
"provided",
"master",
";",
"after",
"connection",
"the",
"socket",
"is",
"used",
"to",
"receive",
"messages",
"from",
"the",
"bus",
"and",
"an",
"eventual",
"previo... | ab935cae537f8a7e61a6ed6fba247661281c9374 | https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/SubConnection.js#L116-L178 | train |
gtriggiano/dnsmq-messagebus | src/SubConnection.js | subscribe | function subscribe (channels) {
channels.forEach(channel => {
if (~_subscribedChannels.indexOf(channel)) return
_subscribedChannels.push(channel)
if (_socket) _socket.subscribe(channel)
})
return connection
} | javascript | function subscribe (channels) {
channels.forEach(channel => {
if (~_subscribedChannels.indexOf(channel)) return
_subscribedChannels.push(channel)
if (_socket) _socket.subscribe(channel)
})
return connection
} | [
"function",
"subscribe",
"(",
"channels",
")",
"{",
"channels",
".",
"forEach",
"(",
"channel",
"=>",
"{",
"if",
"(",
"~",
"_subscribedChannels",
".",
"indexOf",
"(",
"channel",
")",
")",
"return",
"_subscribedChannels",
".",
"push",
"(",
"channel",
")",
"... | subscribes the component to the passed channels
@param {[string]} channels
@return {object} the subscribeConnection instance | [
"subscribes",
"the",
"component",
"to",
"the",
"passed",
"channels"
] | ab935cae537f8a7e61a6ed6fba247661281c9374 | https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/SubConnection.js#L199-L206 | train |
gtriggiano/dnsmq-messagebus | src/SubConnection.js | unsubscribe | function unsubscribe (channels) {
pullAll(_subscribedChannels, channels)
if (_socket) channels.forEach(channel => _socket.unsubscribe(channel))
return connection
} | javascript | function unsubscribe (channels) {
pullAll(_subscribedChannels, channels)
if (_socket) channels.forEach(channel => _socket.unsubscribe(channel))
return connection
} | [
"function",
"unsubscribe",
"(",
"channels",
")",
"{",
"pullAll",
"(",
"_subscribedChannels",
",",
"channels",
")",
"if",
"(",
"_socket",
")",
"channels",
".",
"forEach",
"(",
"channel",
"=>",
"_socket",
".",
"unsubscribe",
"(",
"channel",
")",
")",
"return",... | unsubscribes the component from the passed channels
@param {[string]} channels
@return {object} the subscribeConnection instance | [
"unsubscribes",
"the",
"component",
"from",
"the",
"passed",
"channels"
] | ab935cae537f8a7e61a6ed6fba247661281c9374 | https://github.com/gtriggiano/dnsmq-messagebus/blob/ab935cae537f8a7e61a6ed6fba247661281c9374/src/SubConnection.js#L212-L216 | train |
MiguelCastillo/roolio | src/matcher.js | matcher | function matcher(match) {
if (match instanceof RegExp) {
return function(criteria) {
return match.test(criteria);
};
}
return function(criteria) {
return criteria === match;
};
} | javascript | function matcher(match) {
if (match instanceof RegExp) {
return function(criteria) {
return match.test(criteria);
};
}
return function(criteria) {
return criteria === match;
};
} | [
"function",
"matcher",
"(",
"match",
")",
"{",
"if",
"(",
"match",
"instanceof",
"RegExp",
")",
"{",
"return",
"function",
"(",
"criteria",
")",
"{",
"return",
"match",
".",
"test",
"(",
"criteria",
")",
";",
"}",
";",
"}",
"return",
"function",
"(",
... | Default matching rule with strict comparison. Or if the match is a regex
then the comparison is done by calling the `test` method on the regex.
@param {*} match - If the input is a regex, then matches will be done using
the regex itself. Otherwise, the comparison is done with strict comparison.
@returns {boolean} | [
"Default",
"matching",
"rule",
"with",
"strict",
"comparison",
".",
"Or",
"if",
"the",
"match",
"is",
"a",
"regex",
"then",
"the",
"comparison",
"is",
"done",
"by",
"calling",
"the",
"test",
"method",
"on",
"the",
"regex",
"."
] | a62434e8f9622e1dbec3452f463b5e86913d49a8 | https://github.com/MiguelCastillo/roolio/blob/a62434e8f9622e1dbec3452f463b5e86913d49a8/src/matcher.js#L10-L20 | train |
SBoudrias/gulp-validate-jsdoc | validate-jsdoc.js | analyzeFunction | function analyzeFunction(node) {
var comment = node.leadingComments[0];
if (comment.type !== 'Block') {
return;
}
var data = doctrine.parse(comment.value, { unwrap: true });
var params = [];
data.tags.forEach(function (tag) {
if (tag.title === 'param') {
params.push(tag.name);
}
});
var missing = [];... | javascript | function analyzeFunction(node) {
var comment = node.leadingComments[0];
if (comment.type !== 'Block') {
return;
}
var data = doctrine.parse(comment.value, { unwrap: true });
var params = [];
data.tags.forEach(function (tag) {
if (tag.title === 'param') {
params.push(tag.name);
}
});
var missing = [];... | [
"function",
"analyzeFunction",
"(",
"node",
")",
"{",
"var",
"comment",
"=",
"node",
".",
"leadingComments",
"[",
"0",
"]",
";",
"if",
"(",
"comment",
".",
"type",
"!==",
"'Block'",
")",
"{",
"return",
";",
"}",
"var",
"data",
"=",
"doctrine",
".",
"... | Take a function node and analyze its JsDoc comments
@param {FunctionDeclaration} node FunctionDeclaration esprima node
@return {null}
@throws {Error} Will throw when invalid JsDoc is encountered | [
"Take",
"a",
"function",
"node",
"and",
"analyze",
"its",
"JsDoc",
"comments"
] | 23eae3f5b24310a93d546a40cc9a9e7ab4542d9a | https://github.com/SBoudrias/gulp-validate-jsdoc/blob/23eae3f5b24310a93d546a40cc9a9e7ab4542d9a/validate-jsdoc.js#L13-L41 | train |
SBoudrias/gulp-validate-jsdoc | validate-jsdoc.js | verify | function verify(node) {
switch (node.type) {
case esprima.Syntax.FunctionDeclaration:
if (node.leadingComments && node.leadingComments.length === 1) {
analyzeFunction(node);
}
break;
default:
break;
}
} | javascript | function verify(node) {
switch (node.type) {
case esprima.Syntax.FunctionDeclaration:
if (node.leadingComments && node.leadingComments.length === 1) {
analyzeFunction(node);
}
break;
default:
break;
}
} | [
"function",
"verify",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"type",
")",
"{",
"case",
"esprima",
".",
"Syntax",
".",
"FunctionDeclaration",
":",
"if",
"(",
"node",
".",
"leadingComments",
"&&",
"node",
".",
"leadingComments",
".",
"length",
... | Accept a node and analyze it if it's a function
@param {Object} node Esprima node
@return {null} | [
"Accept",
"a",
"node",
"and",
"analyze",
"it",
"if",
"it",
"s",
"a",
"function"
] | 23eae3f5b24310a93d546a40cc9a9e7ab4542d9a | https://github.com/SBoudrias/gulp-validate-jsdoc/blob/23eae3f5b24310a93d546a40cc9a9e7ab4542d9a/validate-jsdoc.js#L48-L58 | train |
mastilver/node-annotation-router | index.js | pathParse | function pathParse(fullPath){
var parsedPath = {
ext: path.extname(fullPath),
dir: path.dirname(fullPath),
full: fullPath,
base: path.basename(fullPath),
};
parsedPath.name = path.basename(fullPath, parsedPath.ext);
return parsedPath;
} | javascript | function pathParse(fullPath){
var parsedPath = {
ext: path.extname(fullPath),
dir: path.dirname(fullPath),
full: fullPath,
base: path.basename(fullPath),
};
parsedPath.name = path.basename(fullPath, parsedPath.ext);
return parsedPath;
} | [
"function",
"pathParse",
"(",
"fullPath",
")",
"{",
"var",
"parsedPath",
"=",
"{",
"ext",
":",
"path",
".",
"extname",
"(",
"fullPath",
")",
",",
"dir",
":",
"path",
".",
"dirname",
"(",
"fullPath",
")",
",",
"full",
":",
"fullPath",
",",
"base",
":"... | mimics the path.parse function | [
"mimics",
"the",
"path",
".",
"parse",
"function"
] | 340eec100fca9faa7f4762ff6c937b619c04524f | https://github.com/mastilver/node-annotation-router/blob/340eec100fca9faa7f4762ff6c937b619c04524f/index.js#L182-L194 | train |
wilmoore/function-pipeline.js | index.js | pipe | function pipe () {
var fns = [].slice.call(arguments)
var end = fns.length
var idx = -1
var out
return function pipe (initialValue) {
out = initialValue
while (++idx < end) {
out = fns[idx](out)
}
return out
}
} | javascript | function pipe () {
var fns = [].slice.call(arguments)
var end = fns.length
var idx = -1
var out
return function pipe (initialValue) {
out = initialValue
while (++idx < end) {
out = fns[idx](out)
}
return out
}
} | [
"function",
"pipe",
"(",
")",
"{",
"var",
"fns",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
"var",
"end",
"=",
"fns",
".",
"length",
"var",
"idx",
"=",
"-",
"1",
"var",
"out",
"return",
"function",
"pipe",
"(",
"initialValue",... | Similar to the Unix `|` operator; returns a function that invokes the given series of
functions whose output is subsequently passed to the next function in the series.
@param {…Function|Function[]} fns
- Functions to apply as an argument list or array of arguments.
@return {Function}
Function that invokes the given s... | [
"Similar",
"to",
"the",
"Unix",
"|",
"operator",
";",
"returns",
"a",
"function",
"that",
"invokes",
"the",
"given",
"series",
"of",
"functions",
"whose",
"output",
"is",
"subsequently",
"passed",
"to",
"the",
"next",
"function",
"in",
"the",
"series",
"."
] | f5dcd11d9e4fd7b819dd86ed4c0e3c30e5a73f4c | https://github.com/wilmoore/function-pipeline.js/blob/f5dcd11d9e4fd7b819dd86ed4c0e3c30e5a73f4c/index.js#L20-L35 | 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.