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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
andrewdavey/vogue | src/VogueClient.js | VogueClient | function VogueClient(clientSocket, watcher) {
this.socket = clientSocket;
this.watcher = watcher;
this.watchedFiles = {};
clientSocket.on('watch', this.handleMessage.bind(this));
clientSocket.on('disconnect', this.disconnect.bind(this));
} | javascript | function VogueClient(clientSocket, watcher) {
this.socket = clientSocket;
this.watcher = watcher;
this.watchedFiles = {};
clientSocket.on('watch', this.handleMessage.bind(this));
clientSocket.on('disconnect', this.disconnect.bind(this));
} | [
"function",
"VogueClient",
"(",
"clientSocket",
",",
"watcher",
")",
"{",
"this",
".",
"socket",
"=",
"clientSocket",
";",
"this",
".",
"watcher",
"=",
"watcher",
";",
"this",
".",
"watchedFiles",
"=",
"{",
"}",
";",
"clientSocket",
".",
"on",
"(",
"'wat... | Encapsulates a web socket client connection from a web browser. | [
"Encapsulates",
"a",
"web",
"socket",
"client",
"connection",
"from",
"a",
"web",
"browser",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/VogueClient.js#L6-L12 | train |
alexindigo/configly | lib/load.js | load | function load(context)
{
var files
, layers
, cacheKey
;
// TODO: make it proper optional param
context = context || {};
// create new context
// in case if `load` called without context
context = typeOf(context) == 'function' ? context : this.new(context);
// fallback to defaults
context... | javascript | function load(context)
{
var files
, layers
, cacheKey
;
// TODO: make it proper optional param
context = context || {};
// create new context
// in case if `load` called without context
context = typeOf(context) == 'function' ? context : this.new(context);
// fallback to defaults
context... | [
"function",
"load",
"(",
"context",
")",
"{",
"var",
"files",
",",
"layers",
",",
"cacheKey",
";",
"// TODO: make it proper optional param",
"context",
"=",
"context",
"||",
"{",
"}",
";",
"// create new context",
"// in case if `load` called without context",
"context"... | Loads config objects from several environment-derived files
and merges them in specific order.
By default it loads JSON files, also custom pluggable parsers are supported.
@param {function|object} [context] - custom context to use for search and loading config files
@returns {object} - result merged config object | [
"Loads",
"config",
"objects",
"from",
"several",
"environment",
"-",
"derived",
"files",
"and",
"merges",
"them",
"in",
"specific",
"order",
".",
"By",
"default",
"it",
"loads",
"JSON",
"files",
"also",
"custom",
"pluggable",
"parsers",
"are",
"supported",
"."... | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/load.js#L20-L54 | train |
simbo/gulp-static-site-generator | index.js | transformChunk | function transformChunk(chunk, encoding, done) {
if (chunk.isNull()) return done();
if (chunk.isStream()) return this.emit('error', new PluginError(logFlag, 'Streaming not supported'));
if (
!(chunk.isMarkdown = options.regexpMarkdown.test(chunk.relative)) &&
!(chunk.isTemplate = options.regexpT... | javascript | function transformChunk(chunk, encoding, done) {
if (chunk.isNull()) return done();
if (chunk.isStream()) return this.emit('error', new PluginError(logFlag, 'Streaming not supported'));
if (
!(chunk.isMarkdown = options.regexpMarkdown.test(chunk.relative)) &&
!(chunk.isTemplate = options.regexpT... | [
"function",
"transformChunk",
"(",
"chunk",
",",
"encoding",
",",
"done",
")",
"{",
"if",
"(",
"chunk",
".",
"isNull",
"(",
")",
")",
"return",
"done",
"(",
")",
";",
"if",
"(",
"chunk",
".",
"isStream",
"(",
")",
")",
"return",
"this",
".",
"emit"... | transforms a stream chunk
@param {object} chunk chunk object
@param {string} encoding file encoding
@param {Function} done callback
@return {undefined} | [
"transforms",
"a",
"stream",
"chunk"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L73-L92 | train |
simbo/gulp-static-site-generator | index.js | transformChunkData | function transformChunkData(chunk) {
var matter = grayMatter(String(chunk.contents)),
relPath = chunk.hasOwnProperty('data') && chunk.data.relativePath ?
chunk.data.relativePath : getRelativePath(chunk.relative),
absPath = path.normalize(path.join(options.basePath, relPath));
chunk.dat... | javascript | function transformChunkData(chunk) {
var matter = grayMatter(String(chunk.contents)),
relPath = chunk.hasOwnProperty('data') && chunk.data.relativePath ?
chunk.data.relativePath : getRelativePath(chunk.relative),
absPath = path.normalize(path.join(options.basePath, relPath));
chunk.dat... | [
"function",
"transformChunkData",
"(",
"chunk",
")",
"{",
"var",
"matter",
"=",
"grayMatter",
"(",
"String",
"(",
"chunk",
".",
"contents",
")",
")",
",",
"relPath",
"=",
"chunk",
".",
"hasOwnProperty",
"(",
"'data'",
")",
"&&",
"chunk",
".",
"data",
"."... | merge site data, options data, frontmatter data into chunk data
@param {object} chunk stream chunk object
@return {object} chunk with transformed data | [
"merge",
"site",
"data",
"options",
"data",
"frontmatter",
"data",
"into",
"chunk",
"data"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L99-L124 | train |
simbo/gulp-static-site-generator | index.js | transformChunkContents | function transformChunkContents(chunk) {
var contents = String(chunk.contents);
try {
if (chunk.isMarkdown) {
contents = options.renderMarkdown(contents);
}
if (chunk.isTemplate) {
contents = options.renderTemplate(contents, chunk.data, chunk.data.srcPath);
}
chunk.... | javascript | function transformChunkContents(chunk) {
var contents = String(chunk.contents);
try {
if (chunk.isMarkdown) {
contents = options.renderMarkdown(contents);
}
if (chunk.isTemplate) {
contents = options.renderTemplate(contents, chunk.data, chunk.data.srcPath);
}
chunk.... | [
"function",
"transformChunkContents",
"(",
"chunk",
")",
"{",
"var",
"contents",
"=",
"String",
"(",
"chunk",
".",
"contents",
")",
";",
"try",
"{",
"if",
"(",
"chunk",
".",
"isMarkdown",
")",
"{",
"contents",
"=",
"options",
".",
"renderMarkdown",
"(",
... | render chunk contents with markdown renderer, wrap layout, render template
@param {object} chunk stream chunk object
@return {object} chunk with transformed contents | [
"render",
"chunk",
"contents",
"with",
"markdown",
"renderer",
"wrap",
"layout",
"render",
"template"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L131-L146 | train |
simbo/gulp-static-site-generator | index.js | renderTemplate | function renderTemplate(contents, data, filename) {
if (!templateCache.hasOwnProperty(contents)) {
var jadeOptions = merge.recursive({}, options.jadeOptions, {filename: filename});
templateCache[contents] = options.jade.compile(contents, jadeOptions);
}
var locals = merge.recursive({}, data, {lo... | javascript | function renderTemplate(contents, data, filename) {
if (!templateCache.hasOwnProperty(contents)) {
var jadeOptions = merge.recursive({}, options.jadeOptions, {filename: filename});
templateCache[contents] = options.jade.compile(contents, jadeOptions);
}
var locals = merge.recursive({}, data, {lo... | [
"function",
"renderTemplate",
"(",
"contents",
",",
"data",
",",
"filename",
")",
"{",
"if",
"(",
"!",
"templateCache",
".",
"hasOwnProperty",
"(",
"contents",
")",
")",
"{",
"var",
"jadeOptions",
"=",
"merge",
".",
"recursive",
"(",
"{",
"}",
",",
"opti... | render a template string with optional data
@param {string} contents template
@param {object} data optional template data
@param {object} filename optional template path for importing/mergeing
@return {string} rendered template | [
"render",
"a",
"template",
"string",
"with",
"optional",
"data"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L155-L162 | train |
simbo/gulp-static-site-generator | index.js | applyLayout | function applyLayout(chunk) {
chunk.data.contents = String(chunk.contents);
var layout = getLayout(chunk.data.layout),
contents = options.renderTemplate(layout.contents, chunk.data, layout.path);
chunk.contents = new Buffer(contents);
return chunk;
} | javascript | function applyLayout(chunk) {
chunk.data.contents = String(chunk.contents);
var layout = getLayout(chunk.data.layout),
contents = options.renderTemplate(layout.contents, chunk.data, layout.path);
chunk.contents = new Buffer(contents);
return chunk;
} | [
"function",
"applyLayout",
"(",
"chunk",
")",
"{",
"chunk",
".",
"data",
".",
"contents",
"=",
"String",
"(",
"chunk",
".",
"contents",
")",
";",
"var",
"layout",
"=",
"getLayout",
"(",
"chunk",
".",
"data",
".",
"layout",
")",
",",
"contents",
"=",
... | set chunk contents as template data property and render it with a layout
@param {object} chunk stream chunk object
@return {object} chunk with applied layout | [
"set",
"chunk",
"contents",
"as",
"template",
"data",
"property",
"and",
"render",
"it",
"with",
"a",
"layout"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L190-L196 | train |
simbo/gulp-static-site-generator | index.js | getRelativePath | function getRelativePath(filePath) {
var urlPath = path.join(
path.dirname(filePath),
path.basename(filePath, path.extname(filePath))
);
if (options.slugify) {
urlPath = urlPath.split('/').map(function(part) {
return slug(part, options.slugOptions);
}).join('/');
}
ur... | javascript | function getRelativePath(filePath) {
var urlPath = path.join(
path.dirname(filePath),
path.basename(filePath, path.extname(filePath))
);
if (options.slugify) {
urlPath = urlPath.split('/').map(function(part) {
return slug(part, options.slugOptions);
}).join('/');
}
ur... | [
"function",
"getRelativePath",
"(",
"filePath",
")",
"{",
"var",
"urlPath",
"=",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"filePath",
")",
",",
"path",
".",
"basename",
"(",
"filePath",
",",
"path",
".",
"extname",
"(",
"filePath",
")",
"... | transform a src file path into an relative url path
@param {string} filePath file path
@return {string} url | [
"transform",
"a",
"src",
"file",
"path",
"into",
"an",
"relative",
"url",
"path"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L203-L216 | train |
simbo/gulp-static-site-generator | index.js | getLayout | function getLayout(layout) {
if (!layoutCache.hasOwnProperty(layout)) {
var layoutContents = false,
layoutPath = path.join(
path.isAbsolute(options.layoutPath) ?
options.layoutPath : path.join(process.cwd(), options.layoutPath),
layout
);
try {
layoutCon... | javascript | function getLayout(layout) {
if (!layoutCache.hasOwnProperty(layout)) {
var layoutContents = false,
layoutPath = path.join(
path.isAbsolute(options.layoutPath) ?
options.layoutPath : path.join(process.cwd(), options.layoutPath),
layout
);
try {
layoutCon... | [
"function",
"getLayout",
"(",
"layout",
")",
"{",
"if",
"(",
"!",
"layoutCache",
".",
"hasOwnProperty",
"(",
"layout",
")",
")",
"{",
"var",
"layoutContents",
"=",
"false",
",",
"layoutPath",
"=",
"path",
".",
"join",
"(",
"path",
".",
"isAbsolute",
"(",... | read a layout file from given path; store it in cache object for further
usage; return object with layout contents and absolute path
@param {string} layout path to layout
@return {object} layout contents and path | [
"read",
"a",
"layout",
"file",
"from",
"given",
"path",
";",
"store",
"it",
"in",
"cache",
"object",
"for",
"further",
"usage",
";",
"return",
"object",
"with",
"layout",
"contents",
"and",
"absolute",
"path"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L224-L243 | train |
simbo/gulp-static-site-generator | index.js | logDuplicate | function logDuplicate(chunk) {
log(logFlag,
chalk.black.bgYellow('WARNING') + ' skipping ' +
chalk.magenta(chunk.data.srcRelativePath) +
' as it would output to same path as ' +
chalk.magenta(buffer[chunk.relative].data.srcRelativePath)
);
} | javascript | function logDuplicate(chunk) {
log(logFlag,
chalk.black.bgYellow('WARNING') + ' skipping ' +
chalk.magenta(chunk.data.srcRelativePath) +
' as it would output to same path as ' +
chalk.magenta(buffer[chunk.relative].data.srcRelativePath)
);
} | [
"function",
"logDuplicate",
"(",
"chunk",
")",
"{",
"log",
"(",
"logFlag",
",",
"chalk",
".",
"black",
".",
"bgYellow",
"(",
"'WARNING'",
")",
"+",
"' skipping '",
"+",
"chalk",
".",
"magenta",
"(",
"chunk",
".",
"data",
".",
"srcRelativePath",
")",
"+",... | log possible output overwrite to console
@param {object} chunk stream chunk object
@return {undefined} | [
"log",
"possible",
"output",
"overwrite",
"to",
"console"
] | 5bedaa01d6da11feb76c4c67a4d40337177d4d4f | https://github.com/simbo/gulp-static-site-generator/blob/5bedaa01d6da11feb76c4c67a4d40337177d4d4f/index.js#L250-L257 | train |
alexindigo/configly | lib/include_files.js | includeFiles | function includeFiles(config, backRef)
{
backRef = backRef || [];
Object.keys(config).forEach(function(key)
{
var value, oneOffContext;
if (typeof config[key] == 'string')
{
// create temp context
oneOffContext = merge.call(cloneFunction, this, { files: [config[key]] });
// try to... | javascript | function includeFiles(config, backRef)
{
backRef = backRef || [];
Object.keys(config).forEach(function(key)
{
var value, oneOffContext;
if (typeof config[key] == 'string')
{
// create temp context
oneOffContext = merge.call(cloneFunction, this, { files: [config[key]] });
// try to... | [
"function",
"includeFiles",
"(",
"config",
",",
"backRef",
")",
"{",
"backRef",
"=",
"backRef",
"||",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"config",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"value",
",",
"oneOffContext",... | Replaces object's elements with content of corresponding files, if exist
@param {object} config - config object to process
@param {array} [backRef] - back reference to the parent element
@returns {object} - resolved object | [
"Replaces",
"object",
"s",
"elements",
"with",
"content",
"of",
"corresponding",
"files",
"if",
"exist"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/include_files.js#L21-L60 | train |
jansanchez/gulp-email | lib/gulp-email.js | GulpEmail | function GulpEmail(opts, cb) {
this.fullContent = '';
this.default = {};
this.cb = cb || this.callback;
this.options = extend(this.default, opts);
this.stream = new Transform({objectMode: true});
this.stream._transform = function(chunk, encoding, callback){
var fullPath = null,
file = {},
relative = chu... | javascript | function GulpEmail(opts, cb) {
this.fullContent = '';
this.default = {};
this.cb = cb || this.callback;
this.options = extend(this.default, opts);
this.stream = new Transform({objectMode: true});
this.stream._transform = function(chunk, encoding, callback){
var fullPath = null,
file = {},
relative = chu... | [
"function",
"GulpEmail",
"(",
"opts",
",",
"cb",
")",
"{",
"this",
".",
"fullContent",
"=",
"''",
";",
"this",
".",
"default",
"=",
"{",
"}",
";",
"this",
".",
"cb",
"=",
"cb",
"||",
"this",
".",
"callback",
";",
"this",
".",
"options",
"=",
"ext... | Gulp Email. | [
"Gulp",
"Email",
"."
] | d0821e3434a13b90780581ef4752b14e422b2726 | https://github.com/jansanchez/gulp-email/blob/d0821e3434a13b90780581ef4752b14e422b2726/lib/gulp-email.js#L19-L54 | train |
akabekobeko/npm-wpxml2md | src/lib/gfm.js | Cell | function Cell (node, content) {
let index = 0
if (node.parentNode && node.parentNode.childNodes) {
index = Util.arrayIndexOf(node.parentNode.childNodes, node)
}
const prefix = (index === 0 ? '| ' : ' ')
return prefix + content + ' |'
} | javascript | function Cell (node, content) {
let index = 0
if (node.parentNode && node.parentNode.childNodes) {
index = Util.arrayIndexOf(node.parentNode.childNodes, node)
}
const prefix = (index === 0 ? '| ' : ' ')
return prefix + content + ' |'
} | [
"function",
"Cell",
"(",
"node",
",",
"content",
")",
"{",
"let",
"index",
"=",
"0",
"if",
"(",
"node",
".",
"parentNode",
"&&",
"node",
".",
"parentNode",
".",
"childNodes",
")",
"{",
"index",
"=",
"Util",
".",
"arrayIndexOf",
"(",
"node",
".",
"par... | Convert the DOM node to cell text of the table.
@param {Node} node DOM node.
@param {String} content Content text.
@return {String} Cell text. | [
"Convert",
"the",
"DOM",
"node",
"to",
"cell",
"text",
"of",
"the",
"table",
"."
] | 87d81074407db4a9b8b62e17a21db13cf5d835dd | https://github.com/akabekobeko/npm-wpxml2md/blob/87d81074407db4a9b8b62e17a21db13cf5d835dd/src/lib/gfm.js#L11-L19 | train |
alexindigo/configly | lib/get_var.js | getVar | function getVar(token, env)
{
var modifiers = token.split(/\s+/)
, name = modifiers.pop()
, result = ''
;
if (typeof env[name] == 'string' && env[name].length > 0)
{
result = env[name];
// process value with modifiers, right to left
result = modifiers.reverse().reduce(function(ac... | javascript | function getVar(token, env)
{
var modifiers = token.split(/\s+/)
, name = modifiers.pop()
, result = ''
;
if (typeof env[name] == 'string' && env[name].length > 0)
{
result = env[name];
// process value with modifiers, right to left
result = modifiers.reverse().reduce(function(ac... | [
"function",
"getVar",
"(",
"token",
",",
"env",
")",
"{",
"var",
"modifiers",
"=",
"token",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
",",
"name",
"=",
"modifiers",
".",
"pop",
"(",
")",
",",
"result",
"=",
"''",
";",
"if",
"(",
"typeof",
"env",
... | Gets environment variable by provided name,
or return empty string if it doesn't exists
@param {string} token - variable token (name + modifiers) to process
@param {object} env - object to search within
@returns {string} - either variable if it exists or empty string | [
"Gets",
"environment",
"variable",
"by",
"provided",
"name",
"or",
"return",
"empty",
"string",
"if",
"it",
"doesn",
"t",
"exists"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/get_var.js#L14-L36 | train |
sergeche/grunt-frontend | tasks/lib/javascript.js | function(config, env) {
return env.grunt.util._.extend({
banner: '',
compress: {
warnings: false
},
mangle: {},
beautify: false,
report: false
}, env.task.options(config.uglify || {}));
} | javascript | function(config, env) {
return env.grunt.util._.extend({
banner: '',
compress: {
warnings: false
},
mangle: {},
beautify: false,
report: false
}, env.task.options(config.uglify || {}));
} | [
"function",
"(",
"config",
",",
"env",
")",
"{",
"return",
"env",
".",
"grunt",
".",
"util",
".",
"_",
".",
"extend",
"(",
"{",
"banner",
":",
"''",
",",
"compress",
":",
"{",
"warnings",
":",
"false",
"}",
",",
"mangle",
":",
"{",
"}",
",",
"b... | Returns config for UglifyJS
@param {Objecy} config Current config
@param {Objecy} env Task environment (`grunt` and `task` properties)
@return {Object} | [
"Returns",
"config",
"for",
"UglifyJS"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/javascript.js#L51-L61 | train | |
sergeche/grunt-frontend | tasks/lib/javascript.js | function(files, config, catalog, env) {
var uglifyConfig = this.uglifyConfig(config, env);
var grunt = env.grunt;
var _ = grunt.util._;
files.forEach(function(f) {
var src = validFiles(f.src, grunt, config);
var dest = utils.fileInfo(f.dest, config);
grunt.log.write('Processing ' + dest.catalogPath.cy... | javascript | function(files, config, catalog, env) {
var uglifyConfig = this.uglifyConfig(config, env);
var grunt = env.grunt;
var _ = grunt.util._;
files.forEach(function(f) {
var src = validFiles(f.src, grunt, config);
var dest = utils.fileInfo(f.dest, config);
grunt.log.write('Processing ' + dest.catalogPath.cy... | [
"function",
"(",
"files",
",",
"config",
",",
"catalog",
",",
"env",
")",
"{",
"var",
"uglifyConfig",
"=",
"this",
".",
"uglifyConfig",
"(",
"config",
",",
"env",
")",
";",
"var",
"grunt",
"=",
"env",
".",
"grunt",
";",
"var",
"_",
"=",
"grunt",
".... | Processes given JS files
@param {Array} files Normalized Grunt task file list
@param {Object} config Current task config
@param {Object} catalog Output catalog
@param {Object} env Task environment (`grunt` and `task` properties)
@return {Object} Updated catalog | [
"Processes",
"given",
"JS",
"files"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/javascript.js#L71-L125 | train | |
alexindigo/configly | lib/get_cache_key.js | getCacheKey | function getCacheKey()
{
// use the one from the context
var directories = this.directories || this.defaults.directories;
return resolveDir(directories)
+ ':'
+ getFiles.call(this, process.env).join(',')
+ ':'
+ resolveExts.call(this).join(',')
;
} | javascript | function getCacheKey()
{
// use the one from the context
var directories = this.directories || this.defaults.directories;
return resolveDir(directories)
+ ':'
+ getFiles.call(this, process.env).join(',')
+ ':'
+ resolveExts.call(this).join(',')
;
} | [
"function",
"getCacheKey",
"(",
")",
"{",
"// use the one from the context",
"var",
"directories",
"=",
"this",
".",
"directories",
"||",
"this",
".",
"defaults",
".",
"directories",
";",
"return",
"resolveDir",
"(",
"directories",
")",
"+",
"':'",
"+",
"getFile... | Generates cache key from the search directories
and provided list of parsers
@returns {string} - cache key | [
"Generates",
"cache",
"key",
"from",
"the",
"search",
"directories",
"and",
"provided",
"list",
"of",
"parsers"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/get_cache_key.js#L16-L27 | train |
alexindigo/configly | lib/get_cache_key.js | resolveDir | function resolveDir(directories)
{
var directoriesAbsPath;
if (typeOf(directories) == 'array')
{
directoriesAbsPath = directories.map(function(d)
{
return path.resolve(d);
}).join('|');
}
else
{
directoriesAbsPath = path.resolve(directories);
}
return directoriesAbsPath;
} | javascript | function resolveDir(directories)
{
var directoriesAbsPath;
if (typeOf(directories) == 'array')
{
directoriesAbsPath = directories.map(function(d)
{
return path.resolve(d);
}).join('|');
}
else
{
directoriesAbsPath = path.resolve(directories);
}
return directoriesAbsPath;
} | [
"function",
"resolveDir",
"(",
"directories",
")",
"{",
"var",
"directoriesAbsPath",
";",
"if",
"(",
"typeOf",
"(",
"directories",
")",
"==",
"'array'",
")",
"{",
"directoriesAbsPath",
"=",
"directories",
".",
"map",
"(",
"function",
"(",
"d",
")",
"{",
"r... | Resolves `directories` argument into a absolute path
@param {array|string} directories - directories to resolve
@returns {string} - absolute path to the directories | [
"Resolves",
"directories",
"argument",
"into",
"a",
"absolute",
"path"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/get_cache_key.js#L35-L52 | train |
CezaryDanielNowak/node-api-cache-proxy | index.js | function(href) {
var url = extract(href)
var queryObj = omit(url.qs, this.config.excludeRequestParams)
var desiredUrlParams = Object.keys(queryObj).map(function(paramName) {
return paramName + '=' + encodeURIComponent(queryObj[paramName])
}).join('&')
return desiredUrlParams ? url.url + '?' + desiredUrlP... | javascript | function(href) {
var url = extract(href)
var queryObj = omit(url.qs, this.config.excludeRequestParams)
var desiredUrlParams = Object.keys(queryObj).map(function(paramName) {
return paramName + '=' + encodeURIComponent(queryObj[paramName])
}).join('&')
return desiredUrlParams ? url.url + '?' + desiredUrlP... | [
"function",
"(",
"href",
")",
"{",
"var",
"url",
"=",
"extract",
"(",
"href",
")",
"var",
"queryObj",
"=",
"omit",
"(",
"url",
".",
"qs",
",",
"this",
".",
"config",
".",
"excludeRequestParams",
")",
"var",
"desiredUrlParams",
"=",
"Object",
".",
"keys... | clearURL takes url string as input and remove parameters, that are
listed in config.excludeRequestParams
@param {string} href
@return {string} | [
"clearURL",
"takes",
"url",
"string",
"as",
"input",
"and",
"remove",
"parameters",
"that",
"are",
"listed",
"in",
"config",
".",
"excludeRequestParams"
] | 7499f9a92161903693a49d51e615ef79b2027cb1 | https://github.com/CezaryDanielNowak/node-api-cache-proxy/blob/7499f9a92161903693a49d51e615ef79b2027cb1/index.js#L143-L152 | train | |
CezaryDanielNowak/node-api-cache-proxy | index.js | function(envelope) {
var filePath = this._getFileName(envelope)
filendir.writeFile(filePath, JSON.stringify(envelope), function(err) {
if (err) {
log('File could not be saved in ' + this.config.cacheDir)
throw err
}
}.bind(this))
} | javascript | function(envelope) {
var filePath = this._getFileName(envelope)
filendir.writeFile(filePath, JSON.stringify(envelope), function(err) {
if (err) {
log('File could not be saved in ' + this.config.cacheDir)
throw err
}
}.bind(this))
} | [
"function",
"(",
"envelope",
")",
"{",
"var",
"filePath",
"=",
"this",
".",
"_getFileName",
"(",
"envelope",
")",
"filendir",
".",
"writeFile",
"(",
"filePath",
",",
"JSON",
".",
"stringify",
"(",
"envelope",
")",
",",
"function",
"(",
"err",
")",
"{",
... | Save request to file
@param {object} envelope
@return {none} | [
"Save",
"request",
"to",
"file"
] | 7499f9a92161903693a49d51e615ef79b2027cb1 | https://github.com/CezaryDanielNowak/node-api-cache-proxy/blob/7499f9a92161903693a49d51e615ef79b2027cb1/index.js#L171-L180 | train | |
CezaryDanielNowak/node-api-cache-proxy | index.js | function(req, returnReference) {
getRawBody(req).then(function(bodyBuffer) {
returnReference.requestBody = bodyBuffer.toString()
}).catch(function() {
log('Unhandled error in getRawBody', arguments)
})
} | javascript | function(req, returnReference) {
getRawBody(req).then(function(bodyBuffer) {
returnReference.requestBody = bodyBuffer.toString()
}).catch(function() {
log('Unhandled error in getRawBody', arguments)
})
} | [
"function",
"(",
"req",
",",
"returnReference",
")",
"{",
"getRawBody",
"(",
"req",
")",
".",
"then",
"(",
"function",
"(",
"bodyBuffer",
")",
"{",
"returnReference",
".",
"requestBody",
"=",
"bodyBuffer",
".",
"toString",
"(",
")",
"}",
")",
".",
"catch... | POST, PUT methods' payload need to be taken out from request object.
@param {object} req Request object | [
"POST",
"PUT",
"methods",
"payload",
"need",
"to",
"be",
"taken",
"out",
"from",
"request",
"object",
"."
] | 7499f9a92161903693a49d51e615ef79b2027cb1 | https://github.com/CezaryDanielNowak/node-api-cache-proxy/blob/7499f9a92161903693a49d51e615ef79b2027cb1/index.js#L196-L202 | train | |
alexindigo/configly | lib/create_new.js | createNew | function createNew(options)
{
var copy = cloneFunction(configly)
, instance = copy.bind(copy)
;
// enrich copy with helper methods
// mind baked-in context of the copies
applyProps.call(this, copy, options);
// get fresh list of filenames
// if needed
copy.files = copy.files || getFilenames.... | javascript | function createNew(options)
{
var copy = cloneFunction(configly)
, instance = copy.bind(copy)
;
// enrich copy with helper methods
// mind baked-in context of the copies
applyProps.call(this, copy, options);
// get fresh list of filenames
// if needed
copy.files = copy.files || getFilenames.... | [
"function",
"createNew",
"(",
"options",
")",
"{",
"var",
"copy",
"=",
"cloneFunction",
"(",
"configly",
")",
",",
"instance",
"=",
"copy",
".",
"bind",
"(",
"copy",
")",
";",
"// enrich copy with helper methods",
"// mind baked-in context of the copies",
"applyProp... | Creates new copy of configly
immutable to singleton modifications
which will help to keep it stable
when used with in the libraries
@param {object} [options] - custom options to set as new defaults on the new instance
@returns {function} - immutable copy of configly | [
"Creates",
"new",
"copy",
"of",
"configly",
"immutable",
"to",
"singleton",
"modifications",
"which",
"will",
"help",
"to",
"keep",
"it",
"stable",
"when",
"used",
"with",
"in",
"the",
"libraries"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/create_new.js#L19-L38 | train |
alexindigo/configly | lib/create_new.js | copyProps | function copyProps(target)
{
Object.keys(this).forEach(function(key)
{
target[key] = typeof this[key] == 'function' ? this[key].bind(this) : this[key];
}.bind(this));
return target;
} | javascript | function copyProps(target)
{
Object.keys(this).forEach(function(key)
{
target[key] = typeof this[key] == 'function' ? this[key].bind(this) : this[key];
}.bind(this));
return target;
} | [
"function",
"copyProps",
"(",
"target",
")",
"{",
"Object",
".",
"keys",
"(",
"this",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"target",
"[",
"key",
"]",
"=",
"typeof",
"this",
"[",
"key",
"]",
"==",
"'function'",
"?",
"this",
"[... | Copies public properties to the provided target
@param {object} target - properties copy destination
@returns {object} - updated target object | [
"Copies",
"public",
"properties",
"to",
"the",
"provided",
"target"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/create_new.js#L80-L88 | train |
alexindigo/configly | lib/create_new.js | getFilenames | function getFilenames()
{
var hostname = getHostname()
, host = hostname.split('.')[0]
;
return [
'default',
'', // allow suffixes as a basename (e.g. `environment`)
host,
hostname,
'local',
this.defaults.customIncludeFiles,
this.defaults.customEnvVars,
'runtime'
];
} | javascript | function getFilenames()
{
var hostname = getHostname()
, host = hostname.split('.')[0]
;
return [
'default',
'', // allow suffixes as a basename (e.g. `environment`)
host,
hostname,
'local',
this.defaults.customIncludeFiles,
this.defaults.customEnvVars,
'runtime'
];
} | [
"function",
"getFilenames",
"(",
")",
"{",
"var",
"hostname",
"=",
"getHostname",
"(",
")",
",",
"host",
"=",
"hostname",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
";",
"return",
"[",
"'default'",
",",
"''",
",",
"// allow suffixes as a basename (e.g. ... | Creates list of filenames to search with
@returns {array} - list of the filenames | [
"Creates",
"list",
"of",
"filenames",
"to",
"search",
"with"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/create_new.js#L105-L121 | train |
kunruch/mmpilot | lib/utils.js | deepMerge | function deepMerge (base, custom) {
Object.keys(custom).forEach(function (key) {
if (!base.hasOwnProperty(key) || typeof base[key] !== 'object') {
base[key] = custom[key]
} else {
base[key] = deepMerge(base[key], custom[key])
}
})
return base
} | javascript | function deepMerge (base, custom) {
Object.keys(custom).forEach(function (key) {
if (!base.hasOwnProperty(key) || typeof base[key] !== 'object') {
base[key] = custom[key]
} else {
base[key] = deepMerge(base[key], custom[key])
}
})
return base
} | [
"function",
"deepMerge",
"(",
"base",
",",
"custom",
")",
"{",
"Object",
".",
"keys",
"(",
"custom",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"base",
".",
"hasOwnProperty",
"(",
"key",
")",
"||",
"typeof",
"base",
... | Recusrsively merge config and custom, overriding the base value with custom values | [
"Recusrsively",
"merge",
"config",
"and",
"custom",
"overriding",
"the",
"base",
"value",
"with",
"custom",
"values"
] | 7a996b632ea244c807d20673d96d4ad564666022 | https://github.com/kunruch/mmpilot/blob/7a996b632ea244c807d20673d96d4ad564666022/lib/utils.js#L6-L16 | train |
kunruch/mmpilot | lib/utils.js | iterateFiles | function iterateFiles (dir, options, cb) {
var iterateOptions = {
ext: [], // extensions to look for
dirs: false, // do callback for dirs too
skip_: true, // skip files & dirs starting with _
recursive: true // do a recursive find
}
options = deepMerge(iterateOptions, options)
// console.log('o... | javascript | function iterateFiles (dir, options, cb) {
var iterateOptions = {
ext: [], // extensions to look for
dirs: false, // do callback for dirs too
skip_: true, // skip files & dirs starting with _
recursive: true // do a recursive find
}
options = deepMerge(iterateOptions, options)
// console.log('o... | [
"function",
"iterateFiles",
"(",
"dir",
",",
"options",
",",
"cb",
")",
"{",
"var",
"iterateOptions",
"=",
"{",
"ext",
":",
"[",
"]",
",",
"// extensions to look for",
"dirs",
":",
"false",
",",
"// do callback for dirs too",
"skip_",
":",
"true",
",",
"// s... | Iterates through a given folder and calls cb for each file found based on given options | [
"Iterates",
"through",
"a",
"given",
"folder",
"and",
"calls",
"cb",
"for",
"each",
"file",
"found",
"based",
"on",
"given",
"options"
] | 7a996b632ea244c807d20673d96d4ad564666022 | https://github.com/kunruch/mmpilot/blob/7a996b632ea244c807d20673d96d4ad564666022/lib/utils.js#L21-L32 | train |
kunruch/mmpilot | lib/utils.js | iterateRecurse | function iterateRecurse (dir, options, cb) {
try {
var files = fs.readdirSync(dir)
files.forEach(function (file, index) {
var parsedPath = path.parse(file)
var name = parsedPath.name
var ext = parsedPath.ext
var srcpath = path.join(dir, file)
if (options.skip_ && name.charAt(0) ... | javascript | function iterateRecurse (dir, options, cb) {
try {
var files = fs.readdirSync(dir)
files.forEach(function (file, index) {
var parsedPath = path.parse(file)
var name = parsedPath.name
var ext = parsedPath.ext
var srcpath = path.join(dir, file)
if (options.skip_ && name.charAt(0) ... | [
"function",
"iterateRecurse",
"(",
"dir",
",",
"options",
",",
"cb",
")",
"{",
"try",
"{",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"dir",
")",
"files",
".",
"forEach",
"(",
"function",
"(",
"file",
",",
"index",
")",
"{",
"var",
"parsedPa... | Private recursive method for doing the above | [
"Private",
"recursive",
"method",
"for",
"doing",
"the",
"above"
] | 7a996b632ea244c807d20673d96d4ad564666022 | https://github.com/kunruch/mmpilot/blob/7a996b632ea244c807d20673d96d4ad564666022/lib/utils.js#L37-L70 | train |
revin/innertext | index.js | innertext | function innertext (html) {
// Drop everything inside <...> (i.e., tags/elements), and keep the text.
// Unlike browser innerText, this removes newlines; it also doesn't handle
// un-encoded `<` or `>` characters very well, so don't feed it malformed HTML
return entities.decode(html.split(/<[^>]+>/)
.map(fu... | javascript | function innertext (html) {
// Drop everything inside <...> (i.e., tags/elements), and keep the text.
// Unlike browser innerText, this removes newlines; it also doesn't handle
// un-encoded `<` or `>` characters very well, so don't feed it malformed HTML
return entities.decode(html.split(/<[^>]+>/)
.map(fu... | [
"function",
"innertext",
"(",
"html",
")",
"{",
"// Drop everything inside <...> (i.e., tags/elements), and keep the text.",
"// Unlike browser innerText, this removes newlines; it also doesn't handle",
"// un-encoded `<` or `>` characters very well, so don't feed it malformed HTML",
"return",
"... | Quick and dirty way of getting the text representation of a string of HTML, basically close to what a DOM node's innerText property would be | [
"Quick",
"and",
"dirty",
"way",
"of",
"getting",
"the",
"text",
"representation",
"of",
"a",
"string",
"of",
"HTML",
"basically",
"close",
"to",
"what",
"a",
"DOM",
"node",
"s",
"innerText",
"property",
"would",
"be"
] | 3fc61111e10d381dc701206e734249793eca8034 | https://github.com/revin/innertext/blob/3fc61111e10d381dc701206e734249793eca8034/index.js#L8-L17 | train |
akabekobeko/npm-wpxml2md | examples/util.js | existsSync | function existsSync (path) {
try {
Fs.accessSync(Path.resolve(path), Fs.F_OK)
return true
} catch (err) {
return false
}
} | javascript | function existsSync (path) {
try {
Fs.accessSync(Path.resolve(path), Fs.F_OK)
return true
} catch (err) {
return false
}
} | [
"function",
"existsSync",
"(",
"path",
")",
"{",
"try",
"{",
"Fs",
".",
"accessSync",
"(",
"Path",
".",
"resolve",
"(",
"path",
")",
",",
"Fs",
".",
"F_OK",
")",
"return",
"true",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"false",
"}",
"}"
] | Check the existence of a file or folder.
@param {String} path Path of the file or folder.
@return {Boolean} True if exists. Otherwise false. | [
"Check",
"the",
"existence",
"of",
"a",
"file",
"or",
"folder",
"."
] | 87d81074407db4a9b8b62e17a21db13cf5d835dd | https://github.com/akabekobeko/npm-wpxml2md/blob/87d81074407db4a9b8b62e17a21db13cf5d835dd/examples/util.js#L11-L18 | train |
alexindigo/configly | lib/get_files.js | getFiles | function getFiles(env)
{
var files = []
, environment = env['NODE_ENV'] || this.defaults.environment
, appInstance = env['NODE_APP_INSTANCE']
;
// generate config files variations
this.files.forEach(function(baseName)
{
// check for variables
// keep baseName if no variables found
... | javascript | function getFiles(env)
{
var files = []
, environment = env['NODE_ENV'] || this.defaults.environment
, appInstance = env['NODE_APP_INSTANCE']
;
// generate config files variations
this.files.forEach(function(baseName)
{
// check for variables
// keep baseName if no variables found
... | [
"function",
"getFiles",
"(",
"env",
")",
"{",
"var",
"files",
"=",
"[",
"]",
",",
"environment",
"=",
"env",
"[",
"'NODE_ENV'",
"]",
"||",
"this",
".",
"defaults",
".",
"environment",
",",
"appInstance",
"=",
"env",
"[",
"'NODE_APP_INSTANCE'",
"]",
";",
... | Creates list of files to load configuration from
derived from the passed environment-like object
@param {object} env - environment-like object (e.g. `process.env`)
@returns {array} - ordered list of config files to load | [
"Creates",
"list",
"of",
"files",
"to",
"load",
"configuration",
"from",
"derived",
"from",
"the",
"passed",
"environment",
"-",
"like",
"object"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/get_files.js#L15-L35 | train |
alexindigo/configly | lib/merge_layers.js | mergeLayers | function mergeLayers(layers)
{
var _instance = this
, result = null
;
layers.forEach(function(layer)
{
layer.exts.forEach(function(ext)
{
ext.dirs.forEach(function(cfg)
{
// have customizable's array merge function
result = merge.call({
useCustomAdapters: ... | javascript | function mergeLayers(layers)
{
var _instance = this
, result = null
;
layers.forEach(function(layer)
{
layer.exts.forEach(function(ext)
{
ext.dirs.forEach(function(cfg)
{
// have customizable's array merge function
result = merge.call({
useCustomAdapters: ... | [
"function",
"mergeLayers",
"(",
"layers",
")",
"{",
"var",
"_instance",
"=",
"this",
",",
"result",
"=",
"null",
";",
"layers",
".",
"forEach",
"(",
"function",
"(",
"layer",
")",
"{",
"layer",
".",
"exts",
".",
"forEach",
"(",
"function",
"(",
"ext",
... | Merges provided layers into a single config object,
respecting order of the layers
@param {array} layers - list of config objects
@returns {object} - single config object | [
"Merges",
"provided",
"layers",
"into",
"a",
"single",
"config",
"object",
"respecting",
"order",
"of",
"the",
"layers"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/merge_layers.js#L13-L39 | train |
noerw/gitbook-plugin-localized-footer | index.js | function() {
cfg = this.config.get('pluginsConfig.localized-footer'), _this = this;
try {
fs.statSync(this.resolve(cfg.filename));
hasFooterFile = true;
} catch (e) {
hasFooterFile = false;
return;
}
... | javascript | function() {
cfg = this.config.get('pluginsConfig.localized-footer'), _this = this;
try {
fs.statSync(this.resolve(cfg.filename));
hasFooterFile = true;
} catch (e) {
hasFooterFile = false;
return;
}
... | [
"function",
"(",
")",
"{",
"cfg",
"=",
"this",
".",
"config",
".",
"get",
"(",
"'pluginsConfig.localized-footer'",
")",
",",
"_this",
"=",
"this",
";",
"try",
"{",
"fs",
".",
"statSync",
"(",
"this",
".",
"resolve",
"(",
"cfg",
".",
"filename",
")",
... | called on each book & each language book | [
"called",
"on",
"each",
"book",
"&",
"each",
"language",
"book"
] | 6dd48632e6c39b8bb223f0aed3ee832be17dab99 | https://github.com/noerw/gitbook-plugin-localized-footer/blob/6dd48632e6c39b8bb223f0aed3ee832be17dab99/index.js#L9-L29 | train | |
alexindigo/configly | lib/apply_hooks.js | applyHooks | function applyHooks(config, filename)
{
// sort hooks short first + alphabetically
Object.keys(this.hooks).sort(compareHooks).forEach(function(hook)
{
// in order to match hook should either the same length
// as the filename or smaller
if (filename.substr(0, hook.length) === hook)
{
config ... | javascript | function applyHooks(config, filename)
{
// sort hooks short first + alphabetically
Object.keys(this.hooks).sort(compareHooks).forEach(function(hook)
{
// in order to match hook should either the same length
// as the filename or smaller
if (filename.substr(0, hook.length) === hook)
{
config ... | [
"function",
"applyHooks",
"(",
"config",
",",
"filename",
")",
"{",
"// sort hooks short first + alphabetically",
"Object",
".",
"keys",
"(",
"this",
".",
"hooks",
")",
".",
"sort",
"(",
"compareHooks",
")",
".",
"forEach",
"(",
"function",
"(",
"hook",
")",
... | Applies matched hooks
@param {object} config - config object to apply hooks to
@param {string} filename - base filename to match hooks against
@returns {object} - modified config object | [
"Applies",
"matched",
"hooks"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/apply_hooks.js#L11-L25 | train |
alexindigo/configly | lib/apply_hooks.js | compareHooks | function compareHooks(a, b)
{
return a.length < b.length ? -1 : (a.length > b.length ? 1 : (a < b ? -1 : (a > b ? 1 : 0)));
} | javascript | function compareHooks(a, b)
{
return a.length < b.length ? -1 : (a.length > b.length ? 1 : (a < b ? -1 : (a > b ? 1 : 0)));
} | [
"function",
"compareHooks",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
".",
"length",
"<",
"b",
".",
"length",
"?",
"-",
"1",
":",
"(",
"a",
".",
"length",
">",
"b",
".",
"length",
"?",
"1",
":",
"(",
"a",
"<",
"b",
"?",
"-",
"1",
":",
... | Compares hook names shorter to longer and alphabetically
@param {string} a - first key
@param {string} b - second key
@returns {number} -1 - `a` comes first, 0 - positions unchanged, 1 - `b` comes first | [
"Compares",
"hook",
"names",
"shorter",
"to",
"longer",
"and",
"alphabetically"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/apply_hooks.js#L34-L37 | train |
alexindigo/configly | lib/has_value.js | hasValue | function hasValue(value)
{
if (typeOf(value) === 'string') {
return value.length > 0;
} else {
return typeOf(value) !== 'undefined' && typeOf(value) !== 'nan';
}
} | javascript | function hasValue(value)
{
if (typeOf(value) === 'string') {
return value.length > 0;
} else {
return typeOf(value) !== 'undefined' && typeOf(value) !== 'nan';
}
} | [
"function",
"hasValue",
"(",
"value",
")",
"{",
"if",
"(",
"typeOf",
"(",
"value",
")",
"===",
"'string'",
")",
"{",
"return",
"value",
".",
"length",
">",
"0",
";",
"}",
"else",
"{",
"return",
"typeOf",
"(",
"value",
")",
"!==",
"'undefined'",
"&&",... | Checks if provided variable has value,
consider empty only if it's a string and has zero length, or it's NaN,
or it's `undefined` value, everything else consider a legit value
@param {mixed} value - string to check
@returns {boolean} - true is string is not empty, false otherwise | [
"Checks",
"if",
"provided",
"variable",
"has",
"value",
"consider",
"empty",
"only",
"if",
"it",
"s",
"a",
"string",
"and",
"has",
"zero",
"length",
"or",
"it",
"s",
"NaN",
"or",
"it",
"s",
"undefined",
"value",
"everything",
"else",
"consider",
"a",
"le... | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/has_value.js#L14-L21 | train |
andrewdavey/vogue | src/client/vogue-client.js | watchAllStylesheets | function watchAllStylesheets() {
var href;
for (href in stylesheets) {
if (hop.call(stylesheets, href)) {
socket.emit("watch", {
href: href
});
}
}
} | javascript | function watchAllStylesheets() {
var href;
for (href in stylesheets) {
if (hop.call(stylesheets, href)) {
socket.emit("watch", {
href: href
});
}
}
} | [
"function",
"watchAllStylesheets",
"(",
")",
"{",
"var",
"href",
";",
"for",
"(",
"href",
"in",
"stylesheets",
")",
"{",
"if",
"(",
"hop",
".",
"call",
"(",
"stylesheets",
",",
"href",
")",
")",
"{",
"socket",
".",
"emit",
"(",
"\"watch\"",
",",
"{",... | Watch for all available stylesheets. | [
"Watch",
"for",
"all",
"available",
"stylesheets",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L15-L24 | train |
andrewdavey/vogue | src/client/vogue-client.js | reloadStylesheet | function reloadStylesheet(href) {
var newHref = stylesheets[href].href +
(href.indexOf("?") >= 0 ? "&" : "?") +
"_vogue_nocache=" + (new Date).getTime(),
stylesheet;
// Check if the appropriate DOM Node is there.
if (!stylesheets[href].setAttribute) {
// Creat... | javascript | function reloadStylesheet(href) {
var newHref = stylesheets[href].href +
(href.indexOf("?") >= 0 ? "&" : "?") +
"_vogue_nocache=" + (new Date).getTime(),
stylesheet;
// Check if the appropriate DOM Node is there.
if (!stylesheets[href].setAttribute) {
// Creat... | [
"function",
"reloadStylesheet",
"(",
"href",
")",
"{",
"var",
"newHref",
"=",
"stylesheets",
"[",
"href",
"]",
".",
"href",
"+",
"(",
"href",
".",
"indexOf",
"(",
"\"?\"",
")",
">=",
"0",
"?",
"\"&\"",
":",
"\"?\"",
")",
"+",
"\"_vogue_nocache=\"",
"+"... | Reload a stylesheet.
@param {String} href The URL of the stylesheet to be reloaded. | [
"Reload",
"a",
"stylesheet",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L31-L50 | train |
andrewdavey/vogue | src/client/vogue-client.js | getLocalStylesheets | function getLocalStylesheets() {
/**
* Checks if the stylesheet is local.
*
* @param {Object} link The link to check for.
* @returns {Boolean}
*/
function isLocalStylesheet(link) {
var href, i, isExternal = true;
if (link.getAttribute("rel") !== "styleshee... | javascript | function getLocalStylesheets() {
/**
* Checks if the stylesheet is local.
*
* @param {Object} link The link to check for.
* @returns {Boolean}
*/
function isLocalStylesheet(link) {
var href, i, isExternal = true;
if (link.getAttribute("rel") !== "styleshee... | [
"function",
"getLocalStylesheets",
"(",
")",
"{",
"/**\n * Checks if the stylesheet is local.\n *\n * @param {Object} link The link to check for.\n * @returns {Boolean}\n */",
"function",
"isLocalStylesheet",
"(",
"link",
")",
"{",
"var",
"href",
",",
"i",... | Fetch all the local stylesheets from the page.
@returns {Object} The list of local stylesheets keyed by their base URL. | [
"Fetch",
"all",
"the",
"local",
"stylesheets",
"from",
"the",
"page",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L68-L162 | train |
andrewdavey/vogue | src/client/vogue-client.js | isLocalStylesheet | function isLocalStylesheet(link) {
var href, i, isExternal = true;
if (link.getAttribute("rel") !== "stylesheet") {
return false;
}
href = link.href;
for (i = 0; i < script.bases.length; i += 1) {
if (href.indexOf(script.bases[i]) > -1) {
isExtern... | javascript | function isLocalStylesheet(link) {
var href, i, isExternal = true;
if (link.getAttribute("rel") !== "stylesheet") {
return false;
}
href = link.href;
for (i = 0; i < script.bases.length; i += 1) {
if (href.indexOf(script.bases[i]) > -1) {
isExtern... | [
"function",
"isLocalStylesheet",
"(",
"link",
")",
"{",
"var",
"href",
",",
"i",
",",
"isExternal",
"=",
"true",
";",
"if",
"(",
"link",
".",
"getAttribute",
"(",
"\"rel\"",
")",
"!==",
"\"stylesheet\"",
")",
"{",
"return",
"false",
";",
"}",
"href",
"... | Checks if the stylesheet is local.
@param {Object} link The link to check for.
@returns {Boolean} | [
"Checks",
"if",
"the",
"stylesheet",
"is",
"local",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L76-L91 | train |
andrewdavey/vogue | src/client/vogue-client.js | getBase | function getBase(href) {
var base, j;
for (j = 0; j < script.bases.length; j += 1) {
base = script.bases[j];
if (href.indexOf(base) > -1) {
return href.substr(base.length);
}
}
return false;
} | javascript | function getBase(href) {
var base, j;
for (j = 0; j < script.bases.length; j += 1) {
base = script.bases[j];
if (href.indexOf(base) > -1) {
return href.substr(base.length);
}
}
return false;
} | [
"function",
"getBase",
"(",
"href",
")",
"{",
"var",
"base",
",",
"j",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"script",
".",
"bases",
".",
"length",
";",
"j",
"+=",
"1",
")",
"{",
"base",
"=",
"script",
".",
"bases",
"[",
"j",
"]",
... | Get the link's base URL.
@param {String} href The URL to check.
@returns {String|Boolean} The base URL, or false if no matches found. | [
"Get",
"the",
"link",
"s",
"base",
"URL",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L109-L118 | train |
andrewdavey/vogue | src/client/vogue-client.js | loadScript | function loadScript(src, loadedCallback) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", src);
// Call the callback when the script is loaded.
script.onload = loadedCallback;
script.onreadystatechange = function () {
... | javascript | function loadScript(src, loadedCallback) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("src", src);
// Call the callback when the script is loaded.
script.onload = loadedCallback;
script.onreadystatechange = function () {
... | [
"function",
"loadScript",
"(",
"src",
",",
"loadedCallback",
")",
"{",
"var",
"script",
"=",
"document",
".",
"createElement",
"(",
"\"script\"",
")",
";",
"script",
".",
"setAttribute",
"(",
"\"type\"",
",",
"\"text/javascript\"",
")",
";",
"script",
".",
"... | Load a script into the page, and call a callback when it is loaded.
@param {String} src The URL of the script to be loaded.
@param {Function} loadedCallback The function to be called when the script is loaded. | [
"Load",
"a",
"script",
"into",
"the",
"page",
"and",
"call",
"a",
"callback",
"when",
"it",
"is",
"loaded",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L175-L189 | train |
andrewdavey/vogue | src/client/vogue-client.js | loadScripts | function loadScripts(scripts, loadedCallback) {
var srcs = [], property, count, i, src,
countDown = function () {
count -= 1;
if (!count) {
loadedCallback();
}
};
for (property in scripts) {
if (!(property in window)) {
srcs.push(scripts[p... | javascript | function loadScripts(scripts, loadedCallback) {
var srcs = [], property, count, i, src,
countDown = function () {
count -= 1;
if (!count) {
loadedCallback();
}
};
for (property in scripts) {
if (!(property in window)) {
srcs.push(scripts[p... | [
"function",
"loadScripts",
"(",
"scripts",
",",
"loadedCallback",
")",
"{",
"var",
"srcs",
"=",
"[",
"]",
",",
"property",
",",
"count",
",",
"i",
",",
"src",
",",
"countDown",
"=",
"function",
"(",
")",
"{",
"count",
"-=",
"1",
";",
"if",
"(",
"!"... | Load scripts into the page, and call a callback when they are loaded.
@param {Array} scripts The scripts to be loaded.
@param {Function} loadedCallback The function to be called when all the scripts have loaded. | [
"Load",
"scripts",
"into",
"the",
"page",
"and",
"call",
"a",
"callback",
"when",
"they",
"are",
"loaded",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L197-L221 | train |
andrewdavey/vogue | src/client/vogue-client.js | getScriptInfo | function getScriptInfo() {
var bases = [ document.location.protocol + "//" + document.location.host ],
scripts, src, rootUrl, baseMatch;
if (typeof window.__vogue__ === "undefined") {
scripts = document.getElementsByTagName("script");
for (var i=0; i < scripts.length; i++) {
src = sc... | javascript | function getScriptInfo() {
var bases = [ document.location.protocol + "//" + document.location.host ],
scripts, src, rootUrl, baseMatch;
if (typeof window.__vogue__ === "undefined") {
scripts = document.getElementsByTagName("script");
for (var i=0; i < scripts.length; i++) {
src = sc... | [
"function",
"getScriptInfo",
"(",
")",
"{",
"var",
"bases",
"=",
"[",
"document",
".",
"location",
".",
"protocol",
"+",
"\"//\"",
"+",
"document",
".",
"location",
".",
"host",
"]",
",",
"scripts",
",",
"src",
",",
"rootUrl",
",",
"baseMatch",
";",
"i... | Fetches the info for the vogue client. | [
"Fetches",
"the",
"info",
"for",
"the",
"vogue",
"client",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L226-L250 | train |
andrewdavey/vogue | src/client/vogue-client.js | getPort | function getPort(url) {
// URL may contain the port number after the second colon.
// http://domain:1234/
var index = url.indexOf(":", 6); // skipping 6 characters to ignore first colon
return index < 0 ? 80 : parseInt(url.substr(index + 1), 10);
} | javascript | function getPort(url) {
// URL may contain the port number after the second colon.
// http://domain:1234/
var index = url.indexOf(":", 6); // skipping 6 characters to ignore first colon
return index < 0 ? 80 : parseInt(url.substr(index + 1), 10);
} | [
"function",
"getPort",
"(",
"url",
")",
"{",
"// URL may contain the port number after the second colon.",
"// http://domain:1234/",
"var",
"index",
"=",
"url",
".",
"indexOf",
"(",
"\":\"",
",",
"6",
")",
";",
"// skipping 6 characters to ignore first colon",
"return",
"... | Fetches the port from the URL.
@param {String} url URL to get the port from
@returns {Number} The port number, or 80 if no port number found or is invalid. | [
"Fetches",
"the",
"port",
"from",
"the",
"URL",
"."
] | 46e38b373c7a86bbbb15177822e1ea3ff1ecda6c | https://github.com/andrewdavey/vogue/blob/46e38b373c7a86bbbb15177822e1ea3ff1ecda6c/src/client/vogue-client.js#L258-L263 | train |
Tabcorp/injectmd | index.js | nodeInjectmd | function nodeInjectmd (opts) {
const inBuf = bl()
assert.equal(typeof opts, 'object', 'opts should be an object')
assert.equal(typeof opts.in, 'string', 'opts.in should be a string')
assert.equal(typeof opts.tag, 'string', 'opts.tag should be a string')
const inFile = opts.in
const tag = opts.tag
const ... | javascript | function nodeInjectmd (opts) {
const inBuf = bl()
assert.equal(typeof opts, 'object', 'opts should be an object')
assert.equal(typeof opts.in, 'string', 'opts.in should be a string')
assert.equal(typeof opts.tag, 'string', 'opts.tag should be a string')
const inFile = opts.in
const tag = opts.tag
const ... | [
"function",
"nodeInjectmd",
"(",
"opts",
")",
"{",
"const",
"inBuf",
"=",
"bl",
"(",
")",
"assert",
".",
"equal",
"(",
"typeof",
"opts",
",",
"'object'",
",",
"'opts should be an object'",
")",
"assert",
".",
"equal",
"(",
"typeof",
"opts",
".",
"in",
",... | Inject markdown into markdown obj -> null | [
"Inject",
"markdown",
"into",
"markdown",
"obj",
"-",
">",
"null"
] | 24bddd988777b5905abd76bbad0d70215e874af8 | https://github.com/Tabcorp/injectmd/blob/24bddd988777b5905abd76bbad0d70215e874af8/index.js#L13-L61 | train |
simov/xsql | lib/escape.js | wrap | function wrap (str, quote) {
if (this.typecheck) t.typecheck('wrap', [str, quote]);
if (!quote||quote=="'") return "'"+str+"'";
if (quote == '"') return '"'+str+'"';
return quote+str+quote;
} | javascript | function wrap (str, quote) {
if (this.typecheck) t.typecheck('wrap', [str, quote]);
if (!quote||quote=="'") return "'"+str+"'";
if (quote == '"') return '"'+str+'"';
return quote+str+quote;
} | [
"function",
"wrap",
"(",
"str",
",",
"quote",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'wrap'",
",",
"[",
"str",
",",
"quote",
"]",
")",
";",
"if",
"(",
"!",
"quote",
"||",
"quote",
"==",
"\"'\"",
")",
"r... | wrap string with quotes | [
"wrap",
"string",
"with",
"quotes"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/escape.js#L12-L17 | train |
simov/xsql | lib/escape.js | string | function string (str, quote) {
if (this.typecheck) t.typecheck('string', [str, quote]);
return this.wrap(this.escape(str), quote);
} | javascript | function string (str, quote) {
if (this.typecheck) t.typecheck('string', [str, quote]);
return this.wrap(this.escape(str), quote);
} | [
"function",
"string",
"(",
"str",
",",
"quote",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'string'",
",",
"[",
"str",
",",
"quote",
"]",
")",
";",
"return",
"this",
".",
"wrap",
"(",
"this",
".",
"escape",
"... | escape string quotes and wrap it with quotes | [
"escape",
"string",
"quotes",
"and",
"wrap",
"it",
"with",
"quotes"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/escape.js#L26-L29 | train |
sergeche/grunt-frontend | tasks/lib/css.js | function(files, config, catalog, env) {
var grunt = env.grunt;
var that = this;
files.forEach(function(f) {
var file = utils.fileInfo(f.dest, config);
grunt.log.write('Processing ' + file.catalogPath.cyan);
var src = f.src.map(function(src) {
return utils.fileInfo(src, {cwd: config.srcWebroot});
... | javascript | function(files, config, catalog, env) {
var grunt = env.grunt;
var that = this;
files.forEach(function(f) {
var file = utils.fileInfo(f.dest, config);
grunt.log.write('Processing ' + file.catalogPath.cyan);
var src = f.src.map(function(src) {
return utils.fileInfo(src, {cwd: config.srcWebroot});
... | [
"function",
"(",
"files",
",",
"config",
",",
"catalog",
",",
"env",
")",
"{",
"var",
"grunt",
"=",
"env",
".",
"grunt",
";",
"var",
"that",
"=",
"this",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"f",
")",
"{",
"var",
"file",
"=",
"util... | Processes given CSS files
@param {Array} files Normalized Grunt task file list
@param {Object} config Current task config
@param {Object} catalog Output catalog
@param {Object} env Task environment (`grunt` and `task` properties)
@return {Object} Updated catalog | [
"Processes",
"given",
"CSS",
"files"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/css.js#L61-L101 | train | |
wieden-kennedy/voyager | lib/task.js | Task | function Task(phase, name, func) {
if (typeof name === 'function') {
func = name;
name = 'anonymous';
}
if (phases.indexOf(phase) < 0) {
throw new Error('Phase ' + phase + ' is not valid.');
}
if (typeof func !== 'function') {
throw new TypeError('Expected function, got ' + typeof func);
}... | javascript | function Task(phase, name, func) {
if (typeof name === 'function') {
func = name;
name = 'anonymous';
}
if (phases.indexOf(phase) < 0) {
throw new Error('Phase ' + phase + ' is not valid.');
}
if (typeof func !== 'function') {
throw new TypeError('Expected function, got ' + typeof func);
}... | [
"function",
"Task",
"(",
"phase",
",",
"name",
",",
"func",
")",
"{",
"if",
"(",
"typeof",
"name",
"===",
"'function'",
")",
"{",
"func",
"=",
"name",
";",
"name",
"=",
"'anonymous'",
";",
"}",
"if",
"(",
"phases",
".",
"indexOf",
"(",
"phase",
")"... | Task constructor, wraps task function and stores information about the task
@constructor
@param {string} phase - The phase under which this task is to be run
@param {string} [name='anonymous'] - The unique identifier for this task
@param {Function} func - The task function to be called | [
"Task",
"constructor",
"wraps",
"task",
"function",
"and",
"stores",
"information",
"about",
"the",
"task"
] | 13b767b3fd6d562cd696fa36f2285c5ca38741a2 | https://github.com/wieden-kennedy/voyager/blob/13b767b3fd6d562cd696fa36f2285c5ca38741a2/lib/task.js#L22-L74 | train |
sergeche/grunt-frontend | tasks/lib/catalog.js | function(content) {
if (typeof content != 'string') {
content = JSON.stringify(content, null, '\t');
}
fs.writeFileSync(catalogFile, content);
} | javascript | function(content) {
if (typeof content != 'string') {
content = JSON.stringify(content, null, '\t');
}
fs.writeFileSync(catalogFile, content);
} | [
"function",
"(",
"content",
")",
"{",
"if",
"(",
"typeof",
"content",
"!=",
"'string'",
")",
"{",
"content",
"=",
"JSON",
".",
"stringify",
"(",
"content",
",",
"null",
",",
"'\\t'",
")",
";",
"}",
"fs",
".",
"writeFileSync",
"(",
"catalogFile",
",",
... | Saves given content in catalog file
@param {Object} content Catalog content | [
"Saves",
"given",
"content",
"in",
"catalog",
"file"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/catalog.js#L23-L29 | train | |
jhermsmeier/node-blockdevice | lib/blockdevice.js | function( callback ) {
var self = this
// Close a previously opened handle
if( this.fd != null ) {
return this.close( function( error ) {
if( error != null )
return callback.call( self, error )
self.open( callback )
})
}
// Open a new fd handle
debug( 'fs... | javascript | function( callback ) {
var self = this
// Close a previously opened handle
if( this.fd != null ) {
return this.close( function( error ) {
if( error != null )
return callback.call( self, error )
self.open( callback )
})
}
// Open a new fd handle
debug( 'fs... | [
"function",
"(",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
"// Close a previously opened handle",
"if",
"(",
"this",
".",
"fd",
"!=",
"null",
")",
"{",
"return",
"this",
".",
"close",
"(",
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
... | Opens a file descriptor for this device
@param {Function} callback
@return {BlockDevice} | [
"Opens",
"a",
"file",
"descriptor",
"for",
"this",
"device"
] | 10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d | https://github.com/jhermsmeier/node-blockdevice/blob/10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d/lib/blockdevice.js#L69-L107 | train | |
jhermsmeier/node-blockdevice | lib/blockdevice.js | function( size, step, limit, callback ) {
var args = [].slice.call( arguments )
callback = args.pop()
if( this.fd == null )
return callback.call( this, new Error( 'Invalid file descriptor' ) )
limit = args.pop() || 0x2000
step = args.pop() || 0x80
size = args.pop() || 0x200
var s... | javascript | function( size, step, limit, callback ) {
var args = [].slice.call( arguments )
callback = args.pop()
if( this.fd == null )
return callback.call( this, new Error( 'Invalid file descriptor' ) )
limit = args.pop() || 0x2000
step = args.pop() || 0x80
size = args.pop() || 0x200
var s... | [
"function",
"(",
"size",
",",
"step",
",",
"limit",
",",
"callback",
")",
"{",
"var",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
"callback",
"=",
"args",
".",
"pop",
"(",
")",
"if",
"(",
"this",
".",
"fd",
"==",
"n... | Primitive logical block size detection
@param {Number} [size=128]
@param {Number} [step=128]
@param {Number} [limit=8192]
@param {Function} callback( err, blockSize )
@return {BlockDevice} | [
"Primitive",
"logical",
"block",
"size",
"detection"
] | 10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d | https://github.com/jhermsmeier/node-blockdevice/blob/10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d/lib/blockdevice.js#L139-L200 | train | |
jhermsmeier/node-blockdevice | lib/blockdevice.js | function( cylinder, head, sector ) {
if( this.headsPerTrack < 0 || this.sectorsPerTrack < 0 )
throw new Error( 'Unspecified device geometry' )
return ( cylinder * this.headsPerTrack + head ) *
this.sectorsPerTrack + ( sector - 1 )
} | javascript | function( cylinder, head, sector ) {
if( this.headsPerTrack < 0 || this.sectorsPerTrack < 0 )
throw new Error( 'Unspecified device geometry' )
return ( cylinder * this.headsPerTrack + head ) *
this.sectorsPerTrack + ( sector - 1 )
} | [
"function",
"(",
"cylinder",
",",
"head",
",",
"sector",
")",
"{",
"if",
"(",
"this",
".",
"headsPerTrack",
"<",
"0",
"||",
"this",
".",
"sectorsPerTrack",
"<",
"0",
")",
"throw",
"new",
"Error",
"(",
"'Unspecified device geometry'",
")",
"return",
"(",
... | Converts a CHS address to an LBA
@param {Number} cylinder
@param {Number} head
@param {Number} sector
@return {BlockDevice} | [
"Converts",
"a",
"CHS",
"address",
"to",
"an",
"LBA"
] | 10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d | https://github.com/jhermsmeier/node-blockdevice/blob/10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d/lib/blockdevice.js#L289-L297 | train | |
jhermsmeier/node-blockdevice | lib/blockdevice.js | function( fromLBA, toLBA, buffer, callback ) {
fromLBA = fromLBA || 0
toLBA = toLBA || ( fromLBA + 1 )
if( fromLBA > toLBA ) {
var swap = fromLBA
fromLBA = toLBA
toLBA = swap
swap = void 0
}
if( typeof buffer === 'function' ) {
callback = buffer
buffer = null
... | javascript | function( fromLBA, toLBA, buffer, callback ) {
fromLBA = fromLBA || 0
toLBA = toLBA || ( fromLBA + 1 )
if( fromLBA > toLBA ) {
var swap = fromLBA
fromLBA = toLBA
toLBA = swap
swap = void 0
}
if( typeof buffer === 'function' ) {
callback = buffer
buffer = null
... | [
"function",
"(",
"fromLBA",
",",
"toLBA",
",",
"buffer",
",",
"callback",
")",
"{",
"fromLBA",
"=",
"fromLBA",
"||",
"0",
"toLBA",
"=",
"toLBA",
"||",
"(",
"fromLBA",
"+",
"1",
")",
"if",
"(",
"fromLBA",
">",
"toLBA",
")",
"{",
"var",
"swap",
"=",
... | Reads from one LBA to another
@param {Number} fromLBA
@param {Number} toLBA
@param {Buffer} buffer (optional)
@param {Function} callback( error, buffer, bytesRead )
@return {BlockDevice} | [
"Reads",
"from",
"one",
"LBA",
"to",
"another"
] | 10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d | https://github.com/jhermsmeier/node-blockdevice/blob/10fcfa6cc1c053fd72d7046ae0372ff275b4bf7d/lib/blockdevice.js#L330-L357 | train | |
alexindigo/configly | lib/env_vars.js | envVars | function envVars(config, backRef)
{
backRef = backRef || [];
Object.keys(config).forEach(function(key)
{
var value;
if (typeof config[key] == 'string')
{
// try simple match first, for non-empty value
value = getVar.call(this, config[key], process.env);
// if not, try parsing for ... | javascript | function envVars(config, backRef)
{
backRef = backRef || [];
Object.keys(config).forEach(function(key)
{
var value;
if (typeof config[key] == 'string')
{
// try simple match first, for non-empty value
value = getVar.call(this, config[key], process.env);
// if not, try parsing for ... | [
"function",
"envVars",
"(",
"config",
",",
"backRef",
")",
"{",
"backRef",
"=",
"backRef",
"||",
"[",
"]",
";",
"Object",
".",
"keys",
"(",
"config",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"value",
";",
"if",
"(",
"typeo... | Replaces object's elements with corresponding environment variables, if defined
@param {object} config - config object to process
@param {array} [backRef] - back reference to the parent element
@returns {object} - resolved object | [
"Replaces",
"object",
"s",
"elements",
"with",
"corresponding",
"environment",
"variables",
"if",
"defined"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/env_vars.js#L17-L59 | train |
simov/xsql | lib/primitive.js | name | function name (column, table, schema) {
if (this.typecheck) t.typecheck('name', [column, table, schema]);
var result = [];
schema && result.push(this.quotes(schema));
table && result.push(this.quotes(table));
column && result.push(this.quotes(column));
return result.join('.');
} | javascript | function name (column, table, schema) {
if (this.typecheck) t.typecheck('name', [column, table, schema]);
var result = [];
schema && result.push(this.quotes(schema));
table && result.push(this.quotes(table));
column && result.push(this.quotes(column));
return result.join('.');
} | [
"function",
"name",
"(",
"column",
",",
"table",
",",
"schema",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'name'",
",",
"[",
"column",
",",
"table",
",",
"schema",
"]",
")",
";",
"var",
"result",
"=",
"[",
"... | "name" | "table"."name" | "schema"."table"."name" | [
"name",
"|",
"table",
".",
"name",
"|",
"schema",
".",
"table",
".",
"name"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L6-L14 | train |
simov/xsql | lib/primitive.js | names | function names (columns, table, schema) {
if (this.typecheck) t.typecheck('names', [columns, table, schema]);
var result = [];
for (var i=0; i < columns.length; i++) {
result.push(this.name(columns[i],table,schema));
}
return result.join(',');
} | javascript | function names (columns, table, schema) {
if (this.typecheck) t.typecheck('names', [columns, table, schema]);
var result = [];
for (var i=0; i < columns.length; i++) {
result.push(this.name(columns[i],table,schema));
}
return result.join(',');
} | [
"function",
"names",
"(",
"columns",
",",
"table",
",",
"schema",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'names'",
",",
"[",
"columns",
",",
"table",
",",
"schema",
"]",
")",
";",
"var",
"result",
"=",
"[",... | name,name,... | [
"name",
"name",
"..."
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L17-L26 | train |
simov/xsql | lib/primitive.js | as | function as (column, name) {
if (this.typecheck) t.typecheck('as', [column, name]);
return [column,'as',name].join(' ');
} | javascript | function as (column, name) {
if (this.typecheck) t.typecheck('as', [column, name]);
return [column,'as',name].join(' ');
} | [
"function",
"as",
"(",
"column",
",",
"name",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'as'",
",",
"[",
"column",
",",
"name",
"]",
")",
";",
"return",
"[",
"column",
",",
"'as'",
",",
"name",
"]",
".",
"... | column as name | [
"column",
"as",
"name"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L36-L39 | train |
simov/xsql | lib/primitive.js | select | function select (args) {
if (this.typecheck) t.typecheck('select', [args]);
if ('string'===typeof args) args = [args];
return 'select '+args.join();
} | javascript | function select (args) {
if (this.typecheck) t.typecheck('select', [args]);
if ('string'===typeof args) args = [args];
return 'select '+args.join();
} | [
"function",
"select",
"(",
"args",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'select'",
",",
"[",
"args",
"]",
")",
";",
"if",
"(",
"'string'",
"===",
"typeof",
"args",
")",
"args",
"=",
"[",
"args",
"]",
";... | select col1,col2 | [
"select",
"col1",
"col2"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L55-L59 | train |
simov/xsql | lib/primitive.js | join | function join (table, args, type) {
this.typecheck && t.typecheck('join', [table, args, type]);
if ('string'===typeof args) args = [args];
var result = ['join',table,'on',args.join(' and ')];
if (type) result.splice(0,0,type);
return result.join(' ');
} | javascript | function join (table, args, type) {
this.typecheck && t.typecheck('join', [table, args, type]);
if ('string'===typeof args) args = [args];
var result = ['join',table,'on',args.join(' and ')];
if (type) result.splice(0,0,type);
return result.join(' ');
} | [
"function",
"join",
"(",
"table",
",",
"args",
",",
"type",
")",
"{",
"this",
".",
"typecheck",
"&&",
"t",
".",
"typecheck",
"(",
"'join'",
",",
"[",
"table",
",",
"args",
",",
"type",
"]",
")",
";",
"if",
"(",
"'string'",
"===",
"typeof",
"args",
... | left join table on pk1=fk1 and pk2=fk2 ... | [
"left",
"join",
"table",
"on",
"pk1",
"=",
"fk1",
"and",
"pk2",
"=",
"fk2",
"..."
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L68-L74 | train |
simov/xsql | lib/primitive.js | eq | function eq (a, b) {
if (this.typecheck) t.typecheck('eq', [a, b]);
return a+'='+b;
} | javascript | function eq (a, b) {
if (this.typecheck) t.typecheck('eq', [a, b]);
return a+'='+b;
} | [
"function",
"eq",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'eq'",
",",
"[",
"a",
",",
"b",
"]",
")",
";",
"return",
"a",
"+",
"'='",
"+",
"b",
";",
"}"
] | a = b | [
"a",
"=",
"b"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L77-L80 | train |
simov/xsql | lib/primitive.js | eqv | function eqv (column, value) {
if (this.typecheck) t.typecheck('eqv', [column, value]);
if (value===undefined||value===null) value = null;
if ('string'===typeof value) value = this.string(value);
if ('boolean'===typeof value)
value = (this.dialect == 'pg')
? ((value == false) ? this.... | javascript | function eqv (column, value) {
if (this.typecheck) t.typecheck('eqv', [column, value]);
if (value===undefined||value===null) value = null;
if ('string'===typeof value) value = this.string(value);
if ('boolean'===typeof value)
value = (this.dialect == 'pg')
? ((value == false) ? this.... | [
"function",
"eqv",
"(",
"column",
",",
"value",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'eqv'",
",",
"[",
"column",
",",
"value",
"]",
")",
";",
"if",
"(",
"value",
"===",
"undefined",
"||",
"value",
"===",
... | col = val | [
"col",
"=",
"val"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L83-L93 | train |
simov/xsql | lib/primitive.js | groupby | function groupby (args) {
if (this.typecheck) t.typecheck('groupby', [args]);
if ('string'===typeof args) args = [args];
return 'group by '+args.join();
} | javascript | function groupby (args) {
if (this.typecheck) t.typecheck('groupby', [args]);
if ('string'===typeof args) args = [args];
return 'group by '+args.join();
} | [
"function",
"groupby",
"(",
"args",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'groupby'",
",",
"[",
"args",
"]",
")",
";",
"if",
"(",
"'string'",
"===",
"typeof",
"args",
")",
"args",
"=",
"[",
"args",
"]",
... | group by arg1,arg2 ... | [
"group",
"by",
"arg1",
"arg2",
"..."
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L96-L100 | train |
simov/xsql | lib/primitive.js | orderby | function orderby (args, order) {
if (this.typecheck) t.typecheck('orderby', [args, order]);
var o = (order&&'string'===typeof order) ? order : '';
var result = [];
if ('string'===typeof args) {
result = o ? [args+' '+o] : [args];
}
else if (args instanceof Array) {
for (var... | javascript | function orderby (args, order) {
if (this.typecheck) t.typecheck('orderby', [args, order]);
var o = (order&&'string'===typeof order) ? order : '';
var result = [];
if ('string'===typeof args) {
result = o ? [args+' '+o] : [args];
}
else if (args instanceof Array) {
for (var... | [
"function",
"orderby",
"(",
"args",
",",
"order",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'orderby'",
",",
"[",
"args",
",",
"order",
"]",
")",
";",
"var",
"o",
"=",
"(",
"order",
"&&",
"'string'",
"===",
... | order by col1 asc, col2 desc ... | [
"order",
"by",
"col1",
"asc",
"col2",
"desc",
"..."
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L103-L129 | train |
simov/xsql | lib/primitive.js | limit | function limit (a, b) {
if (this.typecheck) t.typecheck('limit', [a, b]);
return (this.dialect == 'pg')
? ['limit',b,'offset',a].join(' ')
: 'limit '+[a,b].join();
} | javascript | function limit (a, b) {
if (this.typecheck) t.typecheck('limit', [a, b]);
return (this.dialect == 'pg')
? ['limit',b,'offset',a].join(' ')
: 'limit '+[a,b].join();
} | [
"function",
"limit",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'limit'",
",",
"[",
"a",
",",
"b",
"]",
")",
";",
"return",
"(",
"this",
".",
"dialect",
"==",
"'pg'",
")",
"?",
"[",
"'... | limit 1,2 | [
"limit",
"1",
"2"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L132-L137 | train |
simov/xsql | lib/primitive.js | between | function between (a, b) {
if (this.typecheck) t.typecheck('between', [a, b]);
return ['between',a,'and',b].join(' ');
} | javascript | function between (a, b) {
if (this.typecheck) t.typecheck('between', [a, b]);
return ['between',a,'and',b].join(' ');
} | [
"function",
"between",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'between'",
",",
"[",
"a",
",",
"b",
"]",
")",
";",
"return",
"[",
"'between'",
",",
"a",
",",
"'and'",
",",
"b",
"]",
... | between a and b | [
"between",
"a",
"and",
"b"
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L154-L157 | train |
simov/xsql | lib/primitive.js | where | function where (expr, operator) {
if (this.typecheck) t.typecheck('where', [expr, operator]);
if ('string'===typeof expr) return 'where '+expr;
return 'where ' + expr.join(' '+(operator||'and')+' ');
} | javascript | function where (expr, operator) {
if (this.typecheck) t.typecheck('where', [expr, operator]);
if ('string'===typeof expr) return 'where '+expr;
return 'where ' + expr.join(' '+(operator||'and')+' ');
} | [
"function",
"where",
"(",
"expr",
",",
"operator",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'where'",
",",
"[",
"expr",
",",
"operator",
"]",
")",
";",
"if",
"(",
"'string'",
"===",
"typeof",
"expr",
")",
"re... | where expr1 and expr2 ... | [
"where",
"expr1",
"and",
"expr2",
"..."
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L166-L170 | train |
simov/xsql | lib/primitive.js | update | function update (table, columns, values) {
if (this.typecheck) t.typecheck('update', [table, columns, values]);
if ('string'===typeof columns) {
columns = [columns];
values = [values];
}
var result = [];
for (var i=0; i < columns.length; i++) {
var value = ('string'===typeof ... | javascript | function update (table, columns, values) {
if (this.typecheck) t.typecheck('update', [table, columns, values]);
if ('string'===typeof columns) {
columns = [columns];
values = [values];
}
var result = [];
for (var i=0; i < columns.length; i++) {
var value = ('string'===typeof ... | [
"function",
"update",
"(",
"table",
",",
"columns",
",",
"values",
")",
"{",
"if",
"(",
"this",
".",
"typecheck",
")",
"t",
".",
"typecheck",
"(",
"'update'",
",",
"[",
"table",
",",
"columns",
",",
"values",
"]",
")",
";",
"if",
"(",
"'string'",
"... | update tbl set col1=val1,col2=val2 ... | [
"update",
"tbl",
"set",
"col1",
"=",
"val1",
"col2",
"=",
"val2",
"..."
] | 32ea619470aa0a42e10aacc4b30df19105038976 | https://github.com/simov/xsql/blob/32ea619470aa0a42e10aacc4b30df19105038976/lib/primitive.js#L208-L223 | train |
alexindigo/configly | lib/load_files.js | loadFiles | function loadFiles(directories, files)
{
// sort extensions to provide deterministic order of loading
var _instance = this
, extensions = resolveExts.call(this)
, layers = []
;
// treat all inputs as list of directories
directories = (typeOf(directories) == 'array') ? directories : [directorie... | javascript | function loadFiles(directories, files)
{
// sort extensions to provide deterministic order of loading
var _instance = this
, extensions = resolveExts.call(this)
, layers = []
;
// treat all inputs as list of directories
directories = (typeOf(directories) == 'array') ? directories : [directorie... | [
"function",
"loadFiles",
"(",
"directories",
",",
"files",
")",
"{",
"// sort extensions to provide deterministic order of loading",
"var",
"_instance",
"=",
"this",
",",
"extensions",
"=",
"resolveExts",
".",
"call",
"(",
"this",
")",
",",
"layers",
"=",
"[",
"]"... | Loads and parses config from available files
@param {array|string} directories - directories to search in
@param {array} files - list of files to search for
@returns {array} - list of loaded configs in order of provided files | [
"Loads",
"and",
"parses",
"config",
"from",
"available",
"files"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/lib/load_files.js#L19-L75 | train |
wieden-kennedy/voyager | lib/watch.js | Watch | function Watch(patterns, ids) {
if (typeof patterns === 'undefined') {
throw new Error('Watch constructor requires a patterns argument');
}
if (typeof ids === 'undefined') {
throw new Error('Watch constructor requires an ids argument');
}
patterns = Array.isArray(patterns) ? patterns : [patterns];
... | javascript | function Watch(patterns, ids) {
if (typeof patterns === 'undefined') {
throw new Error('Watch constructor requires a patterns argument');
}
if (typeof ids === 'undefined') {
throw new Error('Watch constructor requires an ids argument');
}
patterns = Array.isArray(patterns) ? patterns : [patterns];
... | [
"function",
"Watch",
"(",
"patterns",
",",
"ids",
")",
"{",
"if",
"(",
"typeof",
"patterns",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Watch constructor requires a patterns argument'",
")",
";",
"}",
"if",
"(",
"typeof",
"ids",
"===",
"... | Watch constructor, stores tasks to be run on given patterns
@constructor
@param {Array} patterns - The patterns/globs of this instance
@param {Array} ids - Array of tasks identifiers to be run on these patterns | [
"Watch",
"constructor",
"stores",
"tasks",
"to",
"be",
"run",
"on",
"given",
"patterns"
] | 13b767b3fd6d562cd696fa36f2285c5ca38741a2 | https://github.com/wieden-kennedy/voyager/blob/13b767b3fd6d562cd696fa36f2285c5ca38741a2/lib/watch.js#L20-L61 | train |
samthor/gulp-limiter | index.js | queue | function queue(runner) {
if (running < tasks) {
++running;
runner(release);
} else {
pending.push(runner);
}
} | javascript | function queue(runner) {
if (running < tasks) {
++running;
runner(release);
} else {
pending.push(runner);
}
} | [
"function",
"queue",
"(",
"runner",
")",
"{",
"if",
"(",
"running",
"<",
"tasks",
")",
"{",
"++",
"running",
";",
"runner",
"(",
"release",
")",
";",
"}",
"else",
"{",
"pending",
".",
"push",
"(",
"runner",
")",
";",
"}",
"}"
] | Queue an upcoming task, or run it immediately. | [
"Queue",
"an",
"upcoming",
"task",
"or",
"run",
"it",
"immediately",
"."
] | e7209ac6695a2cc2ba6b045202fded16716589e2 | https://github.com/samthor/gulp-limiter/blob/e7209ac6695a2cc2ba6b045202fded16716589e2/index.js#L48-L55 | train |
inadarei/tap-nirvana | tap-nirvana.js | removeUselessStackLines | function removeUselessStackLines(stack) {
let pretty = stack.split('\n');
pretty = pretty.filter((line) => {
return !line.includes('node_modules') && !line.includes('Error');
});
pretty = pretty.join('\n');
return pretty;
} | javascript | function removeUselessStackLines(stack) {
let pretty = stack.split('\n');
pretty = pretty.filter((line) => {
return !line.includes('node_modules') && !line.includes('Error');
});
pretty = pretty.join('\n');
return pretty;
} | [
"function",
"removeUselessStackLines",
"(",
"stack",
")",
"{",
"let",
"pretty",
"=",
"stack",
".",
"split",
"(",
"'\\n'",
")",
";",
"pretty",
"=",
"pretty",
".",
"filter",
"(",
"(",
"line",
")",
"=>",
"{",
"return",
"!",
"line",
".",
"includes",
"(",
... | Remove lines from error stack that belong to test runner. Nobody cares
@param {*String} stack | [
"Remove",
"lines",
"from",
"error",
"stack",
"that",
"belong",
"to",
"test",
"runner",
".",
"Nobody",
"cares"
] | 61e1785814f46c1f091c911a6c12912f0e79f729 | https://github.com/inadarei/tap-nirvana/blob/61e1785814f46c1f091c911a6c12912f0e79f729/tap-nirvana.js#L52-L59 | train |
inadarei/tap-nirvana | tap-nirvana.js | formatErrors | function formatErrors (results) {
return '';
var failCount = results.fail.length;
var past = (failCount === 1) ? 'was' : 'were';
var plural = (failCount === 1) ? 'failure' : 'failures';
var out = '\n' + pad(format.red.bold('Failed Tests:') + ' There ' + past + ' ' + format.red.bold(failCount) + '... | javascript | function formatErrors (results) {
return '';
var failCount = results.fail.length;
var past = (failCount === 1) ? 'was' : 'were';
var plural = (failCount === 1) ? 'failure' : 'failures';
var out = '\n' + pad(format.red.bold('Failed Tests:') + ' There ' + past + ' ' + format.red.bold(failCount) + '... | [
"function",
"formatErrors",
"(",
"results",
")",
"{",
"return",
"''",
";",
"var",
"failCount",
"=",
"results",
".",
"fail",
".",
"length",
";",
"var",
"past",
"=",
"(",
"failCount",
"===",
"1",
")",
"?",
"'was'",
":",
"'were'",
";",
"var",
"plural",
... | this duplicates errors that we already showd. @TODO : remove | [
"this",
"duplicates",
"errors",
"that",
"we",
"already",
"showd",
"."
] | 61e1785814f46c1f091c911a6c12912f0e79f729 | https://github.com/inadarei/tap-nirvana/blob/61e1785814f46c1f091c911a6c12912f0e79f729/tap-nirvana.js#L191-L202 | train |
Stamplay/stamplay-cli | lib/stamplay.js | _checkUpdate | function _checkUpdate(){
var notifier = updateNotifier({
pkg: pkg,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7
})
if (notifier.update)
notifier.notify()
} | javascript | function _checkUpdate(){
var notifier = updateNotifier({
pkg: pkg,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7
})
if (notifier.update)
notifier.notify()
} | [
"function",
"_checkUpdate",
"(",
")",
"{",
"var",
"notifier",
"=",
"updateNotifier",
"(",
"{",
"pkg",
":",
"pkg",
",",
"updateCheckInterval",
":",
"1000",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"7",
"}",
")",
"if",
"(",
"notifier",
".",
"update",
")",... | Check if there is new package version | [
"Check",
"if",
"there",
"is",
"new",
"package",
"version"
] | 5986d0163307102ce539e0a9f66c4b35f533d4a2 | https://github.com/Stamplay/stamplay-cli/blob/5986d0163307102ce539e0a9f66c4b35f533d4a2/lib/stamplay.js#L91-L98 | train |
Stamplay/stamplay-cli | lib/stamplay.js | _detectComment | function _detectComment(argv){
var comment = ''
if(argv._.length == 1){
if(argv.m && typeof argv.m == 'string') comment = argv.m
else if (argv.message && typeof argv.message == 'string') comment = argv.message
return comment
} else {
console.log(chalk.red.bold('Invalid command: use stamplay deploy... | javascript | function _detectComment(argv){
var comment = ''
if(argv._.length == 1){
if(argv.m && typeof argv.m == 'string') comment = argv.m
else if (argv.message && typeof argv.message == 'string') comment = argv.message
return comment
} else {
console.log(chalk.red.bold('Invalid command: use stamplay deploy... | [
"function",
"_detectComment",
"(",
"argv",
")",
"{",
"var",
"comment",
"=",
"''",
"if",
"(",
"argv",
".",
"_",
".",
"length",
"==",
"1",
")",
"{",
"if",
"(",
"argv",
".",
"m",
"&&",
"typeof",
"argv",
".",
"m",
"==",
"'string'",
")",
"comment",
"=... | Detect if the option -m is present in the command | [
"Detect",
"if",
"the",
"option",
"-",
"m",
"is",
"present",
"in",
"the",
"command"
] | 5986d0163307102ce539e0a9f66c4b35f533d4a2 | https://github.com/Stamplay/stamplay-cli/blob/5986d0163307102ce539e0a9f66c4b35f533d4a2/lib/stamplay.js#L104-L114 | train |
ConnorWiseman/koa-hbs-renderer | lib/index.js | renderView | function renderView(view, layout, partials, context) {
let options = {
partials: partials
};
// Handle dynamically-defined content tag
let renderedView = {};
renderedView[opts.contentTag] = view(context, options);
return layout(Object.assign({}, context, renderedView), options);
} | javascript | function renderView(view, layout, partials, context) {
let options = {
partials: partials
};
// Handle dynamically-defined content tag
let renderedView = {};
renderedView[opts.contentTag] = view(context, options);
return layout(Object.assign({}, context, renderedView), options);
} | [
"function",
"renderView",
"(",
"view",
",",
"layout",
",",
"partials",
",",
"context",
")",
"{",
"let",
"options",
"=",
"{",
"partials",
":",
"partials",
"}",
";",
"// Handle dynamically-defined content tag",
"let",
"renderedView",
"=",
"{",
"}",
";",
"rendere... | Renders the specified view using the specified layout, partials, and
context into a string.
Although another Handlebars environment may be provided to the underlying
renderer middleware, and partials manually registered with that environment
will be used when rendering templates, all partials loaded by this module
are... | [
"Renders",
"the",
"specified",
"view",
"using",
"the",
"specified",
"layout",
"partials",
"and",
"context",
"into",
"a",
"string",
"."
] | 94cd84585543e157bda40bdbf27c2b4cc3e1ee58 | https://github.com/ConnorWiseman/koa-hbs-renderer/blob/94cd84585543e157bda40bdbf27c2b4cc3e1ee58/lib/index.js#L97-L107 | train |
tlrobinson/xkcdplot | xkcd.js | function (nm) {
el = d3.select(nm).append("svg")
.attr("width", config.width + 2 * config.margin)
.attr("height", config.height + 2 * config.margin)
.append("g")
.attr("transform", "translate(" + config.margin + ", "
... | javascript | function (nm) {
el = d3.select(nm).append("svg")
.attr("width", config.width + 2 * config.margin)
.attr("height", config.height + 2 * config.margin)
.append("g")
.attr("transform", "translate(" + config.margin + ", "
... | [
"function",
"(",
"nm",
")",
"{",
"el",
"=",
"d3",
".",
"select",
"(",
"nm",
")",
".",
"append",
"(",
"\"svg\"",
")",
".",
"attr",
"(",
"\"width\"",
",",
"config",
".",
"width",
"+",
"2",
"*",
"config",
".",
"margin",
")",
".",
"attr",
"(",
"\"h... | The XKCD object itself. | [
"The",
"XKCD",
"object",
"itself",
"."
] | 4ed4426b1fd7370d162c6989d2cc103489e3d73a | https://github.com/tlrobinson/xkcdplot/blob/4ed4426b1fd7370d162c6989d2cc103489e3d73a/xkcd.js#L30-L38 | train | |
tlrobinson/xkcdplot | xkcd.js | makeGetterSetter | function makeGetterSetter(name) {
xkcd[name] = function (value) {
if (arguments.length === 0) {
return config[name];
}
config[name] = value;
return xkcd;
};
} | javascript | function makeGetterSetter(name) {
xkcd[name] = function (value) {
if (arguments.length === 0) {
return config[name];
}
config[name] = value;
return xkcd;
};
} | [
"function",
"makeGetterSetter",
"(",
"name",
")",
"{",
"xkcd",
"[",
"name",
"]",
"=",
"function",
"(",
"value",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"return",
"config",
"[",
"name",
"]",
";",
"}",
"config",
"[",
"n... | Getters and setters. | [
"Getters",
"and",
"setters",
"."
] | 4ed4426b1fd7370d162c6989d2cc103489e3d73a | https://github.com/tlrobinson/xkcdplot/blob/4ed4426b1fd7370d162c6989d2cc103489e3d73a/xkcd.js#L41-L49 | train |
tlrobinson/xkcdplot | xkcd.js | lineplot | function lineplot(data, x, y, opts) {
var line = d3.svg.line().x(x).y(y).interpolate(xinterp),
bgline = d3.svg.line().x(x).y(y),
strokeWidth = _get(opts, "stroke-width", 3),
color = _get(opts, "stroke", "steelblue");
el.append("svg:path").attr("d", bgline(data))
... | javascript | function lineplot(data, x, y, opts) {
var line = d3.svg.line().x(x).y(y).interpolate(xinterp),
bgline = d3.svg.line().x(x).y(y),
strokeWidth = _get(opts, "stroke-width", 3),
color = _get(opts, "stroke", "steelblue");
el.append("svg:path").attr("d", bgline(data))
... | [
"function",
"lineplot",
"(",
"data",
",",
"x",
",",
"y",
",",
"opts",
")",
"{",
"var",
"line",
"=",
"d3",
".",
"svg",
".",
"line",
"(",
")",
".",
"x",
"(",
"x",
")",
".",
"y",
"(",
"y",
")",
".",
"interpolate",
"(",
"xinterp",
")",
",",
"bg... | Plot styles. | [
"Plot",
"styles",
"."
] | 4ed4426b1fd7370d162c6989d2cc103489e3d73a | https://github.com/tlrobinson/xkcdplot/blob/4ed4426b1fd7370d162c6989d2cc103489e3d73a/xkcd.js#L151-L165 | train |
tlrobinson/xkcdplot | xkcd.js | _get | function _get(d, k, def) {
if (typeof d === "undefined") return def;
if (typeof d[k] === "undefined") return def;
return d[k];
} | javascript | function _get(d, k, def) {
if (typeof d === "undefined") return def;
if (typeof d[k] === "undefined") return def;
return d[k];
} | [
"function",
"_get",
"(",
"d",
",",
"k",
",",
"def",
")",
"{",
"if",
"(",
"typeof",
"d",
"===",
"\"undefined\"",
")",
"return",
"def",
";",
"if",
"(",
"typeof",
"d",
"[",
"k",
"]",
"===",
"\"undefined\"",
")",
"return",
"def",
";",
"return",
"d",
... | Get a value from an object or return a default if that doesn't work. | [
"Get",
"a",
"value",
"from",
"an",
"object",
"or",
"return",
"a",
"default",
"if",
"that",
"doesn",
"t",
"work",
"."
] | 4ed4426b1fd7370d162c6989d2cc103489e3d73a | https://github.com/tlrobinson/xkcdplot/blob/4ed4426b1fd7370d162c6989d2cc103489e3d73a/xkcd.js#L250-L254 | train |
thlorenz/stack-mapper | index.js | StackMapper | function StackMapper(sourcemap) {
if (!(this instanceof StackMapper)) return new StackMapper(sourcemap);
if (typeof sourcemap !== 'object')
throw new Error('sourcemap needs to be an object, please use convert-source-map module to convert it from any other format\n' +
'See: https://github.co... | javascript | function StackMapper(sourcemap) {
if (!(this instanceof StackMapper)) return new StackMapper(sourcemap);
if (typeof sourcemap !== 'object')
throw new Error('sourcemap needs to be an object, please use convert-source-map module to convert it from any other format\n' +
'See: https://github.co... | [
"function",
"StackMapper",
"(",
"sourcemap",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"StackMapper",
")",
")",
"return",
"new",
"StackMapper",
"(",
"sourcemap",
")",
";",
"if",
"(",
"typeof",
"sourcemap",
"!==",
"'object'",
")",
"throw",
"new",... | Creates a Stackmapper that will use the given source map to map error trace locations
@name StackMapper
@private
@constructor
@param {Object} sourcemap | [
"Creates",
"a",
"Stackmapper",
"that",
"will",
"use",
"the",
"given",
"source",
"map",
"to",
"map",
"error",
"trace",
"locations"
] | a95b4a6899cca4ac8715863fd580827efe30fd0f | https://github.com/thlorenz/stack-mapper/blob/a95b4a6899cca4ac8715863fd580827efe30fd0f/index.js#L35-L43 | train |
ConnorWiseman/koa-hbs-renderer | lib/template-manager.js | compileTemplate | function compileTemplate(baseDir, filePath, type) {
return new options.Promise((resolve, reject) => {
let now = timestamp();
let name = filePath.substring(baseDir.length + 1).replace(/\\/g, '/');
name = name.substring(0, name.indexOf('.'));
// A cached template is only invalidated if the ... | javascript | function compileTemplate(baseDir, filePath, type) {
return new options.Promise((resolve, reject) => {
let now = timestamp();
let name = filePath.substring(baseDir.length + 1).replace(/\\/g, '/');
name = name.substring(0, name.indexOf('.'));
// A cached template is only invalidated if the ... | [
"function",
"compileTemplate",
"(",
"baseDir",
",",
"filePath",
",",
"type",
")",
"{",
"return",
"new",
"options",
".",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"now",
"=",
"timestamp",
"(",
")",
";",
"let",
"name",
"=",
... | Compiles and caches the template stored at the specified file path, if it
exists. Cached templates will be stored in the in-memory cache belonging
to the specified template type.
@param {String} baseDir The base directory of the templates
@param {String} filePath The path of the template to compile
@param {String} ... | [
"Compiles",
"and",
"caches",
"the",
"template",
"stored",
"at",
"the",
"specified",
"file",
"path",
"if",
"it",
"exists",
".",
"Cached",
"templates",
"will",
"be",
"stored",
"in",
"the",
"in",
"-",
"memory",
"cache",
"belonging",
"to",
"the",
"specified",
... | 94cd84585543e157bda40bdbf27c2b4cc3e1ee58 | https://github.com/ConnorWiseman/koa-hbs-renderer/blob/94cd84585543e157bda40bdbf27c2b4cc3e1ee58/lib/template-manager.js#L61-L91 | train |
ConnorWiseman/koa-hbs-renderer | lib/template-manager.js | compileTemplates | function compileTemplates(dir, type) {
return getPaths(dir, ext, options).then(paths => {
return options.Promise.all(paths.map(filePath => {
return compileTemplate(dir, filePath, type);
})).then(templates => {
return templates.reduce((all, current) => {
all[current._name] = cur... | javascript | function compileTemplates(dir, type) {
return getPaths(dir, ext, options).then(paths => {
return options.Promise.all(paths.map(filePath => {
return compileTemplate(dir, filePath, type);
})).then(templates => {
return templates.reduce((all, current) => {
all[current._name] = cur... | [
"function",
"compileTemplates",
"(",
"dir",
",",
"type",
")",
"{",
"return",
"getPaths",
"(",
"dir",
",",
"ext",
",",
"options",
")",
".",
"then",
"(",
"paths",
"=>",
"{",
"return",
"options",
".",
"Promise",
".",
"all",
"(",
"paths",
".",
"map",
"("... | Compiles and caches all the templates in the specified directory, if it
exists. Returns a Promise for an object map of compiled Handlebars template
functions, mapped from the results of compileTemplate above.
@param {String} dir The directory to search in
@param {String} type The type of templates these are
@return ... | [
"Compiles",
"and",
"caches",
"all",
"the",
"templates",
"in",
"the",
"specified",
"directory",
"if",
"it",
"exists",
".",
"Returns",
"a",
"Promise",
"for",
"an",
"object",
"map",
"of",
"compiled",
"Handlebars",
"template",
"functions",
"mapped",
"from",
"the",... | 94cd84585543e157bda40bdbf27c2b4cc3e1ee58 | https://github.com/ConnorWiseman/koa-hbs-renderer/blob/94cd84585543e157bda40bdbf27c2b4cc3e1ee58/lib/template-manager.js#L103-L114 | train |
alexindigo/configly | parsers.js | jsCompile | function jsCompile(content, file)
{
// make it as a child of this module
// Would be nice to actually make it transparent
// and pretend it to be child of the caller module
// but there is no obvious way, yet
var jsMod = new Module(file, module);
// override parents to exclude configly from the chain
// ... | javascript | function jsCompile(content, file)
{
// make it as a child of this module
// Would be nice to actually make it transparent
// and pretend it to be child of the caller module
// but there is no obvious way, yet
var jsMod = new Module(file, module);
// override parents to exclude configly from the chain
// ... | [
"function",
"jsCompile",
"(",
"content",
",",
"file",
")",
"{",
"// make it as a child of this module",
"// Would be nice to actually make it transparent",
"// and pretend it to be child of the caller module",
"// but there is no obvious way, yet",
"var",
"jsMod",
"=",
"new",
"Module... | Compiles js content in the manner it's done
in the node itself
@param {string} content - file's content
@param {string} file - full path of the file
@returns {mixed} - result javascript object | [
"Compiles",
"js",
"content",
"in",
"the",
"manner",
"it",
"s",
"done",
"in",
"the",
"node",
"itself"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/parsers.js#L19-L45 | train |
sergeche/grunt-frontend | tasks/lib/utils.js | function(dt) {
dt = dt || new Date();
return [dt.getFullYear(),
padNumber(dt.getMonth() + 1),
padNumber(dt.getDate()),
padNumber(dt.getHours()),
padNumber(dt.getMinutes()),
padNumber(dt.getSeconds())
].join('');
} | javascript | function(dt) {
dt = dt || new Date();
return [dt.getFullYear(),
padNumber(dt.getMonth() + 1),
padNumber(dt.getDate()),
padNumber(dt.getHours()),
padNumber(dt.getMinutes()),
padNumber(dt.getSeconds())
].join('');
} | [
"function",
"(",
"dt",
")",
"{",
"dt",
"=",
"dt",
"||",
"new",
"Date",
"(",
")",
";",
"return",
"[",
"dt",
".",
"getFullYear",
"(",
")",
",",
"padNumber",
"(",
"dt",
".",
"getMonth",
"(",
")",
"+",
"1",
")",
",",
"padNumber",
"(",
"dt",
".",
... | Returns string timestamp of given date in "yyyymmddhhss" format
@param {Date} dt Source date. If not specified, current date is used
@return {String} | [
"Returns",
"string",
"timestamp",
"of",
"given",
"date",
"in",
"yyyymmddhhss",
"format"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/utils.js#L60-L69 | train | |
sergeche/grunt-frontend | tasks/lib/utils.js | function(file, options) {
file = this.absPath(file);
var cwd = (options && options.cwd) || '';
if (file.substring(0, cwd.length) == cwd) {
file = file.substring(cwd.length);
if (file.charAt(0) != '/') {
file = '/' + file;
}
}
return file;
} | javascript | function(file, options) {
file = this.absPath(file);
var cwd = (options && options.cwd) || '';
if (file.substring(0, cwd.length) == cwd) {
file = file.substring(cwd.length);
if (file.charAt(0) != '/') {
file = '/' + file;
}
}
return file;
} | [
"function",
"(",
"file",
",",
"options",
")",
"{",
"file",
"=",
"this",
".",
"absPath",
"(",
"file",
")",
";",
"var",
"cwd",
"=",
"(",
"options",
"&&",
"options",
".",
"cwd",
")",
"||",
"''",
";",
"if",
"(",
"file",
".",
"substring",
"(",
"0",
... | Returns file path suitable for storing in catalog
@param {String} file File path
@param {Object} options Options for transforming path
@return {String} | [
"Returns",
"file",
"path",
"suitable",
"for",
"storing",
"in",
"catalog"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/utils.js#L104-L115 | train | |
sergeche/grunt-frontend | tasks/lib/utils.js | function(grunt, task) {
var config = task.options(grunt.config.getRaw('frontend') || {});
if (!config.webroot) {
return grunt.fail.fatal('You should specify "webroot" property in frontend config', 100);
}
var cwd = this.absPath(config.cwd || config.webroot);
var force = false;
if ('force' in config) {
... | javascript | function(grunt, task) {
var config = task.options(grunt.config.getRaw('frontend') || {});
if (!config.webroot) {
return grunt.fail.fatal('You should specify "webroot" property in frontend config', 100);
}
var cwd = this.absPath(config.cwd || config.webroot);
var force = false;
if ('force' in config) {
... | [
"function",
"(",
"grunt",
",",
"task",
")",
"{",
"var",
"config",
"=",
"task",
".",
"options",
"(",
"grunt",
".",
"config",
".",
"getRaw",
"(",
"'frontend'",
")",
"||",
"{",
"}",
")",
";",
"if",
"(",
"!",
"config",
".",
"webroot",
")",
"{",
"retu... | Returns config for currently running grunt task
@param {Object} grunt
@param {Object} task
@return {Object} | [
"Returns",
"config",
"for",
"currently",
"running",
"grunt",
"task"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/utils.js#L133-L151 | train | |
sergeche/grunt-frontend | tasks/lib/utils.js | function(url, version, config) {
if (!config.rewriteScheme) {
return url;
}
var basename = path.basename(url);
var ext = path.extname(url).substr(1);
var filename = basename.replace(new RegExp('\\.' + ext + '$'), '');
var data = {
url: url,
dirname: path.dirname(url),
basename: basename,
ex... | javascript | function(url, version, config) {
if (!config.rewriteScheme) {
return url;
}
var basename = path.basename(url);
var ext = path.extname(url).substr(1);
var filename = basename.replace(new RegExp('\\.' + ext + '$'), '');
var data = {
url: url,
dirname: path.dirname(url),
basename: basename,
ex... | [
"function",
"(",
"url",
",",
"version",
",",
"config",
")",
"{",
"if",
"(",
"!",
"config",
".",
"rewriteScheme",
")",
"{",
"return",
"url",
";",
"}",
"var",
"basename",
"=",
"path",
".",
"basename",
"(",
"url",
")",
";",
"var",
"ext",
"=",
"path",
... | Creates versioned URL from original one
@param {String} url Original URL
@param {String} version Cache-busting token
@param {Object} config
@return {String} | [
"Creates",
"versioned",
"URL",
"from",
"original",
"one"
] | e6552c178651b40f20d4ff2e297bc3efa9446f33 | https://github.com/sergeche/grunt-frontend/blob/e6552c178651b40f20d4ff2e297bc3efa9446f33/tasks/lib/utils.js#L160-L183 | train | |
p1100i/quadtree2.js | index/vec2.js | function(x, y, silent) {
if('number' != typeof x) {
silent = y;
y = x.y;
x = x.x;
}
if(this.x === x && this.y === y)
return this;
this.x = Vec2.clean(x);
this.y = Vec2.clean(y);
if(silent !== false)
return this.change();
} | javascript | function(x, y, silent) {
if('number' != typeof x) {
silent = y;
y = x.y;
x = x.x;
}
if(this.x === x && this.y === y)
return this;
this.x = Vec2.clean(x);
this.y = Vec2.clean(y);
if(silent !== false)
return this.change();
} | [
"function",
"(",
"x",
",",
"y",
",",
"silent",
")",
"{",
"if",
"(",
"'number'",
"!=",
"typeof",
"x",
")",
"{",
"silent",
"=",
"y",
";",
"y",
"=",
"x",
".",
"y",
";",
"x",
"=",
"x",
".",
"x",
";",
"}",
"if",
"(",
"this",
".",
"x",
"===",
... | set x and y | [
"set",
"x",
"and",
"y"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L46-L60 | train | |
p1100i/quadtree2.js | index/vec2.js | function(vec2, returnNew) {
if (!returnNew) {
this.x += vec2.x; this.y += vec2.y;
return this.change();
} else {
// Return a new vector if `returnNew` is truthy
return new Vec2(
this.x + vec2.x,
this.y + vec2.y
);
}
} | javascript | function(vec2, returnNew) {
if (!returnNew) {
this.x += vec2.x; this.y += vec2.y;
return this.change();
} else {
// Return a new vector if `returnNew` is truthy
return new Vec2(
this.x + vec2.x,
this.y + vec2.y
);
}
} | [
"function",
"(",
"vec2",
",",
"returnNew",
")",
"{",
"if",
"(",
"!",
"returnNew",
")",
"{",
"this",
".",
"x",
"+=",
"vec2",
".",
"x",
";",
"this",
".",
"y",
"+=",
"vec2",
".",
"y",
";",
"return",
"this",
".",
"change",
"(",
")",
";",
"}",
"el... | Add the incoming `vec2` vector to this vector | [
"Add",
"the",
"incoming",
"vec2",
"vector",
"to",
"this",
"vector"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L83-L94 | train | |
p1100i/quadtree2.js | index/vec2.js | function(vec2, returnNew) {
var x,y;
if ('number' !== typeof vec2) { //.x !== undef) {
x = vec2.x;
y = vec2.y;
// Handle incoming scalars
} else {
x = y = vec2;
}
if (!returnNew) {
return this.set(this.x * x, this.y * y);
} else {
retur... | javascript | function(vec2, returnNew) {
var x,y;
if ('number' !== typeof vec2) { //.x !== undef) {
x = vec2.x;
y = vec2.y;
// Handle incoming scalars
} else {
x = y = vec2;
}
if (!returnNew) {
return this.set(this.x * x, this.y * y);
} else {
retur... | [
"function",
"(",
"vec2",
",",
"returnNew",
")",
"{",
"var",
"x",
",",
"y",
";",
"if",
"(",
"'number'",
"!==",
"typeof",
"vec2",
")",
"{",
"//.x !== undef) {",
"x",
"=",
"vec2",
".",
"x",
";",
"y",
"=",
"vec2",
".",
"y",
";",
"// Handle incoming scala... | Multiply this vector by the incoming `vec2` | [
"Multiply",
"this",
"vector",
"by",
"the",
"incoming",
"vec2"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L111-L130 | train | |
p1100i/quadtree2.js | index/vec2.js | function(r, inverse, returnNew) {
var
x = this.x,
y = this.y,
cos = Math.cos(r),
sin = Math.sin(r),
rx, ry;
inverse = (inverse) ? -1 : 1;
rx = cos * x - (inverse * sin) * y;
ry = (inverse * sin) * x + cos * y;
if (returnNew) {
return new Vec2(rx, ry... | javascript | function(r, inverse, returnNew) {
var
x = this.x,
y = this.y,
cos = Math.cos(r),
sin = Math.sin(r),
rx, ry;
inverse = (inverse) ? -1 : 1;
rx = cos * x - (inverse * sin) * y;
ry = (inverse * sin) * x + cos * y;
if (returnNew) {
return new Vec2(rx, ry... | [
"function",
"(",
"r",
",",
"inverse",
",",
"returnNew",
")",
"{",
"var",
"x",
"=",
"this",
".",
"x",
",",
"y",
"=",
"this",
".",
"y",
",",
"cos",
"=",
"Math",
".",
"cos",
"(",
"r",
")",
",",
"sin",
"=",
"Math",
".",
"sin",
"(",
"r",
")",
... | Rotate this vector. Accepts a `Rotation` or angle in radians. Passing a truthy `inverse` will cause the rotation to be reversed. If `returnNew` is truthy, a new `Vec2` will be created with the values resulting from the rotation. Otherwise the rotation will be applied to this vector directly, and this vector will be r... | [
"Rotate",
"this",
"vector",
".",
"Accepts",
"a",
"Rotation",
"or",
"angle",
"in",
"radians",
".",
"Passing",
"a",
"truthy",
"inverse",
"will",
"cause",
"the",
"rotation",
"to",
"be",
"reversed",
".",
"If",
"returnNew",
"is",
"truthy",
"a",
"new",
"Vec2",
... | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L141-L159 | train | |
p1100i/quadtree2.js | index/vec2.js | function(vec2) {
var x = this.x - vec2.x;
var y = this.y - vec2.y;
return Math.sqrt(x*x + y*y);
} | javascript | function(vec2) {
var x = this.x - vec2.x;
var y = this.y - vec2.y;
return Math.sqrt(x*x + y*y);
} | [
"function",
"(",
"vec2",
")",
"{",
"var",
"x",
"=",
"this",
".",
"x",
"-",
"vec2",
".",
"x",
";",
"var",
"y",
"=",
"this",
".",
"y",
"-",
"vec2",
".",
"y",
";",
"return",
"Math",
".",
"sqrt",
"(",
"x",
"*",
"x",
"+",
"y",
"*",
"y",
")",
... | Return the distance betwen this `Vec2` and the incoming vec2 vector and return a scalar | [
"Return",
"the",
"distance",
"betwen",
"this",
"Vec2",
"and",
"the",
"incoming",
"vec2",
"vector",
"and",
"return",
"a",
"scalar"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L175-L179 | train | |
p1100i/quadtree2.js | index/vec2.js | function(returnNew) {
var length = this.length();
// Collect a ratio to shrink the x and y coords
var invertedLength = (length < Number.MIN_VALUE) ? 0 : 1/length;
if (!returnNew) {
// Convert the coords to be greater than zero
// but smaller than or equal to 1.0
return ... | javascript | function(returnNew) {
var length = this.length();
// Collect a ratio to shrink the x and y coords
var invertedLength = (length < Number.MIN_VALUE) ? 0 : 1/length;
if (!returnNew) {
// Convert the coords to be greater than zero
// but smaller than or equal to 1.0
return ... | [
"function",
"(",
"returnNew",
")",
"{",
"var",
"length",
"=",
"this",
".",
"length",
"(",
")",
";",
"// Collect a ratio to shrink the x and y coords",
"var",
"invertedLength",
"=",
"(",
"length",
"<",
"Number",
".",
"MIN_VALUE",
")",
"?",
"0",
":",
"1",
"/",... | Convert this vector into a unit vector. Returns the length. | [
"Convert",
"this",
"vector",
"into",
"a",
"unit",
"vector",
".",
"Returns",
"the",
"length",
"."
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L183-L196 | train | |
p1100i/quadtree2.js | index/vec2.js | function(v, w) {
if (w === undef) {
w = v.y;
v = v.x;
}
return (Vec2.clean(v) === this.x && Vec2.clean(w) === this.y);
} | javascript | function(v, w) {
if (w === undef) {
w = v.y;
v = v.x;
}
return (Vec2.clean(v) === this.x && Vec2.clean(w) === this.y);
} | [
"function",
"(",
"v",
",",
"w",
")",
"{",
"if",
"(",
"w",
"===",
"undef",
")",
"{",
"w",
"=",
"v",
".",
"y",
";",
"v",
"=",
"v",
".",
"x",
";",
"}",
"return",
"(",
"Vec2",
".",
"clean",
"(",
"v",
")",
"===",
"this",
".",
"x",
"&&",
"Vec... | Determine if another `Vec2`'s components match this one's also accepts 2 scalars | [
"Determine",
"if",
"another",
"Vec2",
"s",
"components",
"match",
"this",
"one",
"s",
"also",
"accepts",
"2",
"scalars"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L200-L207 | train | |
p1100i/quadtree2.js | index/vec2.js | function(returnNew) {
var x = Math.abs(this.x), y = Math.abs(this.y);
if (returnNew) {
return new Vec2(x, y);
} else {
return this.set(x, y);
}
} | javascript | function(returnNew) {
var x = Math.abs(this.x), y = Math.abs(this.y);
if (returnNew) {
return new Vec2(x, y);
} else {
return this.set(x, y);
}
} | [
"function",
"(",
"returnNew",
")",
"{",
"var",
"x",
"=",
"Math",
".",
"abs",
"(",
"this",
".",
"x",
")",
",",
"y",
"=",
"Math",
".",
"abs",
"(",
"this",
".",
"y",
")",
";",
"if",
"(",
"returnNew",
")",
"{",
"return",
"new",
"Vec2",
"(",
"x",
... | Return a new `Vec2` that contains the absolute value of each of this vector's parts | [
"Return",
"a",
"new",
"Vec2",
"that",
"contains",
"the",
"absolute",
"value",
"of",
"each",
"of",
"this",
"vector",
"s",
"parts"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L211-L219 | train | |
p1100i/quadtree2.js | index/vec2.js | function(v, returnNew) {
var
tx = this.x,
ty = this.y,
vx = v.x,
vy = v.y,
x = tx < vx ? tx : vx,
y = ty < vy ? ty : vy;
if (returnNew) {
return new Vec2(x, y);
} else {
return this.set(x, y);
}
} | javascript | function(v, returnNew) {
var
tx = this.x,
ty = this.y,
vx = v.x,
vy = v.y,
x = tx < vx ? tx : vx,
y = ty < vy ? ty : vy;
if (returnNew) {
return new Vec2(x, y);
} else {
return this.set(x, y);
}
} | [
"function",
"(",
"v",
",",
"returnNew",
")",
"{",
"var",
"tx",
"=",
"this",
".",
"x",
",",
"ty",
"=",
"this",
".",
"y",
",",
"vx",
"=",
"v",
".",
"x",
",",
"vy",
"=",
"v",
".",
"y",
",",
"x",
"=",
"tx",
"<",
"vx",
"?",
"tx",
":",
"vx",
... | Return a new `Vec2` consisting of the smallest values from this vector and the incoming When returnNew is truthy, a new `Vec2` will be returned otherwise the minimum values in either this or `v` will be applied to this vector. | [
"Return",
"a",
"new",
"Vec2",
"consisting",
"of",
"the",
"smallest",
"values",
"from",
"this",
"vector",
"and",
"the",
"incoming",
"When",
"returnNew",
"is",
"truthy",
"a",
"new",
"Vec2",
"will",
"be",
"returned",
"otherwise",
"the",
"minimum",
"values",
"in... | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L227-L241 | train | |
p1100i/quadtree2.js | index/vec2.js | function(low, high, returnNew) {
var ret = this.min(high, true).max(low);
if (returnNew) {
return ret;
} else {
return this.set(ret.x, ret.y);
}
} | javascript | function(low, high, returnNew) {
var ret = this.min(high, true).max(low);
if (returnNew) {
return ret;
} else {
return this.set(ret.x, ret.y);
}
} | [
"function",
"(",
"low",
",",
"high",
",",
"returnNew",
")",
"{",
"var",
"ret",
"=",
"this",
".",
"min",
"(",
"high",
",",
"true",
")",
".",
"max",
"(",
"low",
")",
";",
"if",
"(",
"returnNew",
")",
"{",
"return",
"ret",
";",
"}",
"else",
"{",
... | Clamp values into a range. If this vector's values are lower than the `low`'s values, then raise them. If they are higher than `high`'s then lower them. Passing returnNew as true will cause a new Vec2 to be returned. Otherwise, this vector's values will be clamped | [
"Clamp",
"values",
"into",
"a",
"range",
".",
"If",
"this",
"vector",
"s",
"values",
"are",
"lower",
"than",
"the",
"low",
"s",
"values",
"then",
"raise",
"them",
".",
"If",
"they",
"are",
"higher",
"than",
"high",
"s",
"then",
"lower",
"them",
".",
... | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L272-L279 | train | |
p1100i/quadtree2.js | index/vec2.js | function(vec2, returnNew) {
var x,y;
if ('number' !== typeof vec2) {
x = vec2.x;
y = vec2.y;
// Handle incoming scalars
} else {
x = y = vec2;
}
if (x === 0 || y === 0) {
throw new Error('division by zero')
}
if (isNaN(x) || isNaN(y)) {
... | javascript | function(vec2, returnNew) {
var x,y;
if ('number' !== typeof vec2) {
x = vec2.x;
y = vec2.y;
// Handle incoming scalars
} else {
x = y = vec2;
}
if (x === 0 || y === 0) {
throw new Error('division by zero')
}
if (isNaN(x) || isNaN(y)) {
... | [
"function",
"(",
"vec2",
",",
"returnNew",
")",
"{",
"var",
"x",
",",
"y",
";",
"if",
"(",
"'number'",
"!==",
"typeof",
"vec2",
")",
"{",
"x",
"=",
"vec2",
".",
"x",
";",
"y",
"=",
"vec2",
".",
"y",
";",
"// Handle incoming scalars",
"}",
"else",
... | Divide this vector's components by a scalar | [
"Divide",
"this",
"vector",
"s",
"components",
"by",
"a",
"scalar"
] | c44dc648a7cb5a0dd98d5e8240ef423f10135445 | https://github.com/p1100i/quadtree2.js/blob/c44dc648a7cb5a0dd98d5e8240ef423f10135445/index/vec2.js#L311-L335 | train | |
alexindigo/configly | modifiers.js | json | function json(value) {
var parsedPojo;
try {
parsedPojo = JSON.parse(value);
} catch(e) {
return throwModifierError('json', value, e);
}
return parsedPojo;
} | javascript | function json(value) {
var parsedPojo;
try {
parsedPojo = JSON.parse(value);
} catch(e) {
return throwModifierError('json', value, e);
}
return parsedPojo;
} | [
"function",
"json",
"(",
"value",
")",
"{",
"var",
"parsedPojo",
";",
"try",
"{",
"parsedPojo",
"=",
"JSON",
".",
"parse",
"(",
"value",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"throwModifierError",
"(",
"'json'",
",",
"value",
",",
"e"... | Parses provided string as JSON string
@param {string} value - Date string to parse
@returns {object} - Parsed JSON POJO | [
"Parses",
"provided",
"string",
"as",
"JSON",
"string"
] | 026423ba0e036cf8ca33cd2fd160df519715272d | https://github.com/alexindigo/configly/blob/026423ba0e036cf8ca33cd2fd160df519715272d/modifiers.js#L44-L54 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.