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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
myndzi/should-eventually | index.js | function (resolved, val) {
var should = (negate ?
(new Assertion(val)).not :
(new Assertion(val))
);
if (storedAssertions[0][0] !== 'throw' && !resolved) {
throw val;
}
... | javascript | function (resolved, val) {
var should = (negate ?
(new Assertion(val)).not :
(new Assertion(val))
);
if (storedAssertions[0][0] !== 'throw' && !resolved) {
throw val;
}
... | [
"function",
"(",
"resolved",
",",
"val",
")",
"{",
"var",
"should",
"=",
"(",
"negate",
"?",
"(",
"new",
"Assertion",
"(",
"val",
")",
")",
".",
"not",
":",
"(",
"new",
"Assertion",
"(",
"val",
")",
")",
")",
";",
"if",
"(",
"storedAssertions",
"... | this function will kick off the new chain of assertions on the setttled result of the promise | [
"this",
"function",
"will",
"kick",
"off",
"the",
"new",
"chain",
"of",
"assertions",
"on",
"the",
"setttled",
"result",
"of",
"the",
"promise"
] | 96abbae69f4ee46cda5864b0c59c1a570984ad42 | https://github.com/myndzi/should-eventually/blob/96abbae69f4ee46cda5864b0c59c1a570984ad42/index.js#L88-L146 | train | |
thommeo/generator-fe | app/templates/foundation/js/foundation/foundation.clearing.js | function () {
var self = this;
$(this.scope)
.on('click.fndtn.clearing', 'ul[data-clearing] li',
function (e, current, target) {
var current = current || $(this),
target = target || current,
next = current.next('li'),
settings = ... | javascript | function () {
var self = this;
$(this.scope)
.on('click.fndtn.clearing', 'ul[data-clearing] li',
function (e, current, target) {
var current = current || $(this),
target = target || current,
next = current.next('li'),
settings = ... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"$",
"(",
"this",
".",
"scope",
")",
".",
"on",
"(",
"'click.fndtn.clearing'",
",",
"'ul[data-clearing] li'",
",",
"function",
"(",
"e",
",",
"current",
",",
"target",
")",
"{",
"var",
"curren... | event binding and initial setup | [
"event",
"binding",
"and",
"initial",
"setup"
] | 186d1464fcf628604ecb7f39e56312ee1b08415f | https://github.com/thommeo/generator-fe/blob/186d1464fcf628604ecb7f39e56312ee1b08415f/app/templates/foundation/js/foundation/foundation.clearing.js#L65-L108 | train | |
mattdesl/kami-mesh-buffer | index.js | Mesh | function Mesh(context, isStatic, numVerts, numIndices, vertexAttribs) {
//TODO: use options here...
if (!numVerts)
throw "numVerts not specified, must be > 0";
BaseObject.call(this, context);
this.gl = this.context.gl;
this.numVerts = null;
this.numIndices = null;
this.vertices = null;
this.i... | javascript | function Mesh(context, isStatic, numVerts, numIndices, vertexAttribs) {
//TODO: use options here...
if (!numVerts)
throw "numVerts not specified, must be > 0";
BaseObject.call(this, context);
this.gl = this.context.gl;
this.numVerts = null;
this.numIndices = null;
this.vertices = null;
this.i... | [
"function",
"Mesh",
"(",
"context",
",",
"isStatic",
",",
"numVerts",
",",
"numIndices",
",",
"vertexAttribs",
")",
"{",
"//TODO: use options here...",
"if",
"(",
"!",
"numVerts",
")",
"throw",
"\"numVerts not specified, must be > 0\"",
";",
"BaseObject",
".",
"call... | Creates a new Mesh with the provided parameters.
If numIndices is 0 or falsy, no index buffer will be used
and indices will be an empty ArrayBuffer and a null indexBuffer.
If isStatic is true, then vertexUsage and indexUsage will
be set to gl.STATIC_DRAW. Otherwise they will use gl.DYNAMIC_DRAW.
You may want to adjus... | [
"Creates",
"a",
"new",
"Mesh",
"with",
"the",
"provided",
"parameters",
"."
] | b9b486eaba215728df31d1c1d2a5bf94c83a1337 | https://github.com/mattdesl/kami-mesh-buffer/blob/b9b486eaba215728df31d1c1d2a5bf94c83a1337/index.js#L51-L108 | train |
mattdesl/kami-mesh-buffer | index.js | function() {
this.gl = this.context.gl;
var gl = this.gl;
this.vertexBuffer = gl.createBuffer();
//ignore index buffer if we haven't specified any
this.indexBuffer = this.numIndices > 0
? gl.createBuffer()
: null;
this.dirty = true;
} | javascript | function() {
this.gl = this.context.gl;
var gl = this.gl;
this.vertexBuffer = gl.createBuffer();
//ignore index buffer if we haven't specified any
this.indexBuffer = this.numIndices > 0
? gl.createBuffer()
: null;
this.dirty = true;
} | [
"function",
"(",
")",
"{",
"this",
".",
"gl",
"=",
"this",
".",
"context",
".",
"gl",
";",
"var",
"gl",
"=",
"this",
".",
"gl",
";",
"this",
".",
"vertexBuffer",
"=",
"gl",
".",
"createBuffer",
"(",
")",
";",
"//ignore index buffer if we haven't specifie... | recreates the buffers on context loss | [
"recreates",
"the",
"buffers",
"on",
"context",
"loss"
] | b9b486eaba215728df31d1c1d2a5bf94c83a1337 | https://github.com/mattdesl/kami-mesh-buffer/blob/b9b486eaba215728df31d1c1d2a5bf94c83a1337/index.js#L111-L122 | train | |
mattdesl/kami-mesh-buffer | index.js | function(shader) {
var gl = this.gl;
var offset = 0;
var stride = this.vertexStride;
//bind and update our vertex data before binding attributes
this._updateBuffers();
//for each attribtue
for (var i=0; i<this._vertexAttribs.length; i++) {
var a = this._vertexAttribs[i];
//location of the attrib... | javascript | function(shader) {
var gl = this.gl;
var offset = 0;
var stride = this.vertexStride;
//bind and update our vertex data before binding attributes
this._updateBuffers();
//for each attribtue
for (var i=0; i<this._vertexAttribs.length; i++) {
var a = this._vertexAttribs[i];
//location of the attrib... | [
"function",
"(",
"shader",
")",
"{",
"var",
"gl",
"=",
"this",
".",
"gl",
";",
"var",
"offset",
"=",
"0",
";",
"var",
"stride",
"=",
"this",
".",
"vertexStride",
";",
"//bind and update our vertex data before binding attributes",
"this",
".",
"_updateBuffers",
... | binds this mesh's vertex attributes for the given shader | [
"binds",
"this",
"mesh",
"s",
"vertex",
"attributes",
"for",
"the",
"given",
"shader"
] | b9b486eaba215728df31d1c1d2a5bf94c83a1337 | https://github.com/mattdesl/kami-mesh-buffer/blob/b9b486eaba215728df31d1c1d2a5bf94c83a1337/index.js#L193-L225 | train | |
mattdesl/kami-mesh-buffer | index.js | function(name, numComponents, location, type, normalize, offsetCount) {
this.name = name;
this.numComponents = numComponents;
this.location = typeof location === "number" ? location : null;
this.type = type;
this.normalize = Boolean(normalize);
this.offsetCount = typeof offsetCount === "number" ? offsetCoun... | javascript | function(name, numComponents, location, type, normalize, offsetCount) {
this.name = name;
this.numComponents = numComponents;
this.location = typeof location === "number" ? location : null;
this.type = type;
this.normalize = Boolean(normalize);
this.offsetCount = typeof offsetCount === "number" ? offsetCoun... | [
"function",
"(",
"name",
",",
"numComponents",
",",
"location",
",",
"type",
",",
"normalize",
",",
"offsetCount",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"numComponents",
"=",
"numComponents",
";",
"this",
".",
"location",
"=",
"ty... | Mesh vertex attribute holder.
Location is optional and for advanced users that
want vertex arrays to match across shaders. Any non-numerical
value will be converted to null, and ignored. If a numerical
value is given, it will override the position of this attribute
when given to a mesh.
@class Mesh.Attrib
@construct... | [
"Mesh",
"vertex",
"attribute",
"holder",
"."
] | b9b486eaba215728df31d1c1d2a5bf94c83a1337 | https://github.com/mattdesl/kami-mesh-buffer/blob/b9b486eaba215728df31d1c1d2a5bf94c83a1337/index.js#L269-L276 | train | |
HarryStevens/fsz | index.js | writeJSON | function writeJSON(file, json){
var s = file.split(".");
if (s.length > 0) {
var ext = s[s.length - 1];
if (ext != "json"){
file = file + ".json";
}
}
fs.writeFileSync(file, JSON.stringify(json));
} | javascript | function writeJSON(file, json){
var s = file.split(".");
if (s.length > 0) {
var ext = s[s.length - 1];
if (ext != "json"){
file = file + ".json";
}
}
fs.writeFileSync(file, JSON.stringify(json));
} | [
"function",
"writeJSON",
"(",
"file",
",",
"json",
")",
"{",
"var",
"s",
"=",
"file",
".",
"split",
"(",
"\".\"",
")",
";",
"if",
"(",
"s",
".",
"length",
">",
"0",
")",
"{",
"var",
"ext",
"=",
"s",
"[",
"s",
".",
"length",
"-",
"1",
"]",
"... | Writes a JSON file
@param {string} file Name of the output file (.json extension will be added)
@param {string} json The JSON variable | [
"Writes",
"a",
"JSON",
"file"
] | 2b87d0de824c4270f8cb311ccc34a44ef36a6d33 | https://github.com/HarryStevens/fsz/blob/2b87d0de824c4270f8cb311ccc34a44ef36a6d33/index.js#L49-L58 | train |
HarryStevens/fsz | index.js | getDirectories | function getDirectories(path){
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path + "/" + file).isDirectory();
});
} | javascript | function getDirectories(path){
return fs.readdirSync(path).filter(function (file) {
return fs.statSync(path + "/" + file).isDirectory();
});
} | [
"function",
"getDirectories",
"(",
"path",
")",
"{",
"return",
"fs",
".",
"readdirSync",
"(",
"path",
")",
".",
"filter",
"(",
"function",
"(",
"file",
")",
"{",
"return",
"fs",
".",
"statSync",
"(",
"path",
"+",
"\"/\"",
"+",
"file",
")",
".",
"isDi... | Returns a list of all directories in a parent directory
@param {string} path The path of the parent directory
@return {array} An array with a list of directories | [
"Returns",
"a",
"list",
"of",
"all",
"directories",
"in",
"a",
"parent",
"directory"
] | 2b87d0de824c4270f8cb311ccc34a44ef36a6d33 | https://github.com/HarryStevens/fsz/blob/2b87d0de824c4270f8cb311ccc34a44ef36a6d33/index.js#L67-L71 | train |
wilmoore/knex-pg-middleware | lib/knex.js | create | function create(options) {
return knex(extend({
client: "pg",
debug: debug(),
connection: connection(),
pool: pool()
}, options));
} | javascript | function create(options) {
return knex(extend({
client: "pg",
debug: debug(),
connection: connection(),
pool: pool()
}, options));
} | [
"function",
"create",
"(",
"options",
")",
"{",
"return",
"knex",
"(",
"extend",
"(",
"{",
"client",
":",
"\"pg\"",
",",
"debug",
":",
"debug",
"(",
")",
",",
"connection",
":",
"connection",
"(",
")",
",",
"pool",
":",
"pool",
"(",
")",
"}",
",",
... | Create and return a knex connection.
@param {Object} options
@api public | [
"Create",
"and",
"return",
"a",
"knex",
"connection",
"."
] | 615c391b87d4f60a7ed18518f3dd5d69bb396911 | https://github.com/wilmoore/knex-pg-middleware/blob/615c391b87d4f60a7ed18518f3dd5d69bb396911/lib/knex.js#L23-L30 | train |
wilmoore/knex-pg-middleware | lib/knex.js | connection | function connection() {
return {
ssl: JSON.parse(JSON.stringify(process.env.DATABASE_SSL || "")),
host: process.env.DATABASE_HOST || "localhost",
user: process.env.DATABASE_USER || "",
charset: process.env.DATABASE_CHARSET || "utf8",
password: process.env.DATABASE_PASS || "",
database: process... | javascript | function connection() {
return {
ssl: JSON.parse(JSON.stringify(process.env.DATABASE_SSL || "")),
host: process.env.DATABASE_HOST || "localhost",
user: process.env.DATABASE_USER || "",
charset: process.env.DATABASE_CHARSET || "utf8",
password: process.env.DATABASE_PASS || "",
database: process... | [
"function",
"connection",
"(",
")",
"{",
"return",
"{",
"ssl",
":",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"process",
".",
"env",
".",
"DATABASE_SSL",
"||",
"\"\"",
")",
")",
",",
"host",
":",
"process",
".",
"env",
".",
"DATABASE_... | Return connection configuration. | [
"Return",
"connection",
"configuration",
"."
] | 615c391b87d4f60a7ed18518f3dd5d69bb396911 | https://github.com/wilmoore/knex-pg-middleware/blob/615c391b87d4f60a7ed18518f3dd5d69bb396911/lib/knex.js#L36-L45 | train |
bredele/salute | index.js | type | function type (response) {
return value => {
if (!(value instanceof Error)) {
response.setHeader(
'Content-Type',
lookup(typeof value === 'object' ? 'json' : 'text')
)
}
return value instanceof Array ? JSON.stringify(value) : value
}
} | javascript | function type (response) {
return value => {
if (!(value instanceof Error)) {
response.setHeader(
'Content-Type',
lookup(typeof value === 'object' ? 'json' : 'text')
)
}
return value instanceof Array ? JSON.stringify(value) : value
}
} | [
"function",
"type",
"(",
"response",
")",
"{",
"return",
"value",
"=>",
"{",
"if",
"(",
"!",
"(",
"value",
"instanceof",
"Error",
")",
")",
"{",
"response",
".",
"setHeader",
"(",
"'Content-Type'",
",",
"lookup",
"(",
"typeof",
"value",
"===",
"'object'"... | Set response content type header.
@param {Object} response
@return {Function}
@api private | [
"Set",
"response",
"content",
"type",
"header",
"."
] | 6a14a9001a97917e93230adc1145e84300b6edc2 | https://github.com/bredele/salute/blob/6a14a9001a97917e93230adc1145e84300b6edc2/index.js#L50-L60 | train |
bredele/salute | index.js | status | function status (res) {
return err => {
const code = err.statusCode
error(res, code || 500)
if (!code) console.log(err)
}
} | javascript | function status (res) {
return err => {
const code = err.statusCode
error(res, code || 500)
if (!code) console.log(err)
}
} | [
"function",
"status",
"(",
"res",
")",
"{",
"return",
"err",
"=>",
"{",
"const",
"code",
"=",
"err",
".",
"statusCode",
"error",
"(",
"res",
",",
"code",
"||",
"500",
")",
"if",
"(",
"!",
"code",
")",
"console",
".",
"log",
"(",
"err",
")",
"}",
... | Set response status code and message.
@param {Object} response
@return {Function}
@api private | [
"Set",
"response",
"status",
"code",
"and",
"message",
"."
] | 6a14a9001a97917e93230adc1145e84300b6edc2 | https://github.com/bredele/salute/blob/6a14a9001a97917e93230adc1145e84300b6edc2/index.js#L71-L77 | train |
jakobmattsson/jscov | spec/scaffolding/oss/express 3.0.6/router/index.js | callbacks | function callbacks(err) {
var fn = route.callbacks[i++];
try {
if ('route' == err) {
nextRoute();
} else if (err && fn) {
if (fn.length < 4) return callbacks(err);
fn(err, req, res, callbacks);
} else if (fn) {
if (fn.length < 4) return fn(req,... | javascript | function callbacks(err) {
var fn = route.callbacks[i++];
try {
if ('route' == err) {
nextRoute();
} else if (err && fn) {
if (fn.length < 4) return callbacks(err);
fn(err, req, res, callbacks);
} else if (fn) {
if (fn.length < 4) return fn(req,... | [
"function",
"callbacks",
"(",
"err",
")",
"{",
"var",
"fn",
"=",
"route",
".",
"callbacks",
"[",
"i",
"++",
"]",
";",
"try",
"{",
"if",
"(",
"'route'",
"==",
"err",
")",
"{",
"nextRoute",
"(",
")",
";",
"}",
"else",
"if",
"(",
"err",
"&&",
"fn"... | invoke route callbacks | [
"invoke",
"route",
"callbacks"
] | ff9f5dd9e720ea0dd00e8d0607f0f1ae84d99b78 | https://github.com/jakobmattsson/jscov/blob/ff9f5dd9e720ea0dd00e8d0607f0f1ae84d99b78/spec/scaffolding/oss/express 3.0.6/router/index.js#L152-L169 | train |
punchcard-cms/input-plugin-file | lib/script.js | clear | function clear (node) {
const replace = node.cloneNode(false);
node.parentNode.replaceChild(replace, node);
return replace;
} | javascript | function clear (node) {
const replace = node.cloneNode(false);
node.parentNode.replaceChild(replace, node);
return replace;
} | [
"function",
"clear",
"(",
"node",
")",
"{",
"const",
"replace",
"=",
"node",
".",
"cloneNode",
"(",
"false",
")",
";",
"node",
".",
"parentNode",
".",
"replaceChild",
"(",
"replace",
",",
"node",
")",
";",
"return",
"replace",
";",
"}"
] | Clear a node's contents
@param {object} node - obj to be emptied | [
"Clear",
"a",
"node",
"s",
"contents"
] | 31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96 | https://github.com/punchcard-cms/input-plugin-file/blob/31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96/lib/script.js#L35-L39 | train |
punchcard-cms/input-plugin-file | lib/script.js | loadHandler | function loadHandler (event) {
const target = event.target;
// change the link to the new file
link.setAttribute('href', target.result);
// make sure checkbox is no longer checked
checkbox.checked = false;
// make link not hidden
link.style.display = '';
// make delete checkbox not h... | javascript | function loadHandler (event) {
const target = event.target;
// change the link to the new file
link.setAttribute('href', target.result);
// make sure checkbox is no longer checked
checkbox.checked = false;
// make link not hidden
link.style.display = '';
// make delete checkbox not h... | [
"function",
"loadHandler",
"(",
"event",
")",
"{",
"const",
"target",
"=",
"event",
".",
"target",
";",
"// change the link to the new file",
"link",
".",
"setAttribute",
"(",
"'href'",
",",
"target",
".",
"result",
")",
";",
"// make sure checkbox is no longer chec... | Load handler for FileReader
@param {[type]} event - handler executed when the load event is fired | [
"Load",
"handler",
"for",
"FileReader"
] | 31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96 | https://github.com/punchcard-cms/input-plugin-file/blob/31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96/lib/script.js#L45-L75 | train |
punchcard-cms/input-plugin-file | lib/script.js | uploadHandler | function uploadHandler (event) {
const target = event.target;
if (target.files && target.files[0]) {
file = target.files[0];
const reader = new FileReader();
reader.addEventListener('load', loadHandler);
reader.readAsDataURL(file);
}
} | javascript | function uploadHandler (event) {
const target = event.target;
if (target.files && target.files[0]) {
file = target.files[0];
const reader = new FileReader();
reader.addEventListener('load', loadHandler);
reader.readAsDataURL(file);
}
} | [
"function",
"uploadHandler",
"(",
"event",
")",
"{",
"const",
"target",
"=",
"event",
".",
"target",
";",
"if",
"(",
"target",
".",
"files",
"&&",
"target",
".",
"files",
"[",
"0",
"]",
")",
"{",
"file",
"=",
"target",
".",
"files",
"[",
"0",
"]",
... | Upload handler for file upload element
@param {[type]} event - handler executed when the load event is fired | [
"Upload",
"handler",
"for",
"file",
"upload",
"element"
] | 31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96 | https://github.com/punchcard-cms/input-plugin-file/blob/31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96/lib/script.js#L81-L92 | train |
punchcard-cms/input-plugin-file | lib/script.js | checkboxHandler | function checkboxHandler (event) {
const target = event.target;
if (target.checked) {
link.style.display = 'none';
if (upload.value) {
upload.value = '';
link = clear(link);
}
}
else {
link.style.display = '';
}
} | javascript | function checkboxHandler (event) {
const target = event.target;
if (target.checked) {
link.style.display = 'none';
if (upload.value) {
upload.value = '';
link = clear(link);
}
}
else {
link.style.display = '';
}
} | [
"function",
"checkboxHandler",
"(",
"event",
")",
"{",
"const",
"target",
"=",
"event",
".",
"target",
";",
"if",
"(",
"target",
".",
"checked",
")",
"{",
"link",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"if",
"(",
"upload",
".",
"value",
")... | Checkbox handler for file delete checkbox
@param {[type]} event - handler executed when the load event is fired | [
"Checkbox",
"handler",
"for",
"file",
"delete",
"checkbox"
] | 31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96 | https://github.com/punchcard-cms/input-plugin-file/blob/31ac6f170ad4c8022b5dc28fffb3ebc9bf266f96/lib/script.js#L98-L111 | train |
scisco/yaml-files | index.js | construct | function construct(data) {
const basepath = process.cwd();
const files = data.map((f) => {
const fullpath = p.join(basepath, f);
const src = fs.readFileSync(fullpath, 'utf8');
const t = yaml.load(src, {
schema: YAML_FILES_SCHEMA,
filename: fullpath
});
return t;
});
const t = ... | javascript | function construct(data) {
const basepath = process.cwd();
const files = data.map((f) => {
const fullpath = p.join(basepath, f);
const src = fs.readFileSync(fullpath, 'utf8');
const t = yaml.load(src, {
schema: YAML_FILES_SCHEMA,
filename: fullpath
});
return t;
});
const t = ... | [
"function",
"construct",
"(",
"data",
")",
"{",
"const",
"basepath",
"=",
"process",
".",
"cwd",
"(",
")",
";",
"const",
"files",
"=",
"data",
".",
"map",
"(",
"(",
"f",
")",
"=>",
"{",
"const",
"fullpath",
"=",
"p",
".",
"join",
"(",
"basepath",
... | Construct function for the yaml schema that reads a list of files
parse them and then merge them
@param {Object} data - input to the schema marker
@returns {Object} a parsed yaml object | [
"Construct",
"function",
"for",
"the",
"yaml",
"schema",
"that",
"reads",
"a",
"list",
"of",
"files",
"parse",
"them",
"and",
"then",
"merge",
"them"
] | 71de1364800a24a5cf86b12264fb6345eaf8f283 | https://github.com/scisco/yaml-files/blob/71de1364800a24a5cf86b12264fb6345eaf8f283/index.js#L42-L58 | train |
2createStudio/postcss-bad-selectors | lib/index.js | plugin | function plugin(cb) {
return function(css) {
if (lodash.isFunction(cb)) {
var token = cb(css.source.input.file);
if (!lodash.isNull(token)) {
css.eachRule(function(rule) {
if (!areSelectorsValid(rule.selectors, token)) {
throw rule.error('Wrong selector');
}
});
}
}
}
} | javascript | function plugin(cb) {
return function(css) {
if (lodash.isFunction(cb)) {
var token = cb(css.source.input.file);
if (!lodash.isNull(token)) {
css.eachRule(function(rule) {
if (!areSelectorsValid(rule.selectors, token)) {
throw rule.error('Wrong selector');
}
});
}
}
}
} | [
"function",
"plugin",
"(",
"cb",
")",
"{",
"return",
"function",
"(",
"css",
")",
"{",
"if",
"(",
"lodash",
".",
"isFunction",
"(",
"cb",
")",
")",
"{",
"var",
"token",
"=",
"cb",
"(",
"css",
".",
"source",
".",
"input",
".",
"file",
")",
";",
... | PostCSS plugin definition.
@param {Function} cb
@return {Function} | [
"PostCSS",
"plugin",
"definition",
"."
] | 9c5cf7f32d21fd0cd172785a92db714457feb076 | https://github.com/2createStudio/postcss-bad-selectors/blob/9c5cf7f32d21fd0cd172785a92db714457feb076/lib/index.js#L20-L34 | train |
2createStudio/postcss-bad-selectors | lib/index.js | areSelectorsValid | function areSelectorsValid(selectors, token) {
return lodash.every(selectors, function(selector) {
if (lodash.isRegExp(token)) {
return token.test(lodash.trim(selector));
} else {
return lodash.startsWith(lodash.trim(selector), token);
}
});
} | javascript | function areSelectorsValid(selectors, token) {
return lodash.every(selectors, function(selector) {
if (lodash.isRegExp(token)) {
return token.test(lodash.trim(selector));
} else {
return lodash.startsWith(lodash.trim(selector), token);
}
});
} | [
"function",
"areSelectorsValid",
"(",
"selectors",
",",
"token",
")",
"{",
"return",
"lodash",
".",
"every",
"(",
"selectors",
",",
"function",
"(",
"selector",
")",
"{",
"if",
"(",
"lodash",
".",
"isRegExp",
"(",
"token",
")",
")",
"{",
"return",
"token... | Checks if all selectors in collection are valid.
@param {Array} selectors
@param {String} token
@return {Boolean} | [
"Checks",
"if",
"all",
"selectors",
"in",
"collection",
"are",
"valid",
"."
] | 9c5cf7f32d21fd0cd172785a92db714457feb076 | https://github.com/2createStudio/postcss-bad-selectors/blob/9c5cf7f32d21fd0cd172785a92db714457feb076/lib/index.js#L43-L51 | train |
lmammino/indexed-string-variation | lib/index.js | cleanAlphabet | function cleanAlphabet(alphabet) {
return alphabet.split('').filter(function (item, pos, self) {
return self.indexOf(item) === pos;
}).join('');
} | javascript | function cleanAlphabet(alphabet) {
return alphabet.split('').filter(function (item, pos, self) {
return self.indexOf(item) === pos;
}).join('');
} | [
"function",
"cleanAlphabet",
"(",
"alphabet",
")",
"{",
"return",
"alphabet",
".",
"split",
"(",
"''",
")",
".",
"filter",
"(",
"function",
"(",
"item",
",",
"pos",
",",
"self",
")",
"{",
"return",
"self",
".",
"indexOf",
"(",
"item",
")",
"===",
"po... | remove duplicates from alphabets | [
"remove",
"duplicates",
"from",
"alphabets"
] | 52fb6b5b05940138fb58f9a1c937531ad90adda5 | https://github.com/lmammino/indexed-string-variation/blob/52fb6b5b05940138fb58f9a1c937531ad90adda5/lib/index.js#L26-L30 | train |
lmammino/indexed-string-variation | lib/index.js | generate | function generate(index) {
return index instanceof _bigInteger2.default ? (0, _generateBigInt2.default)(index, alphabet) : (0, _generateInt2.default)(index, alphabet);
} | javascript | function generate(index) {
return index instanceof _bigInteger2.default ? (0, _generateBigInt2.default)(index, alphabet) : (0, _generateInt2.default)(index, alphabet);
} | [
"function",
"generate",
"(",
"index",
")",
"{",
"return",
"index",
"instanceof",
"_bigInteger2",
".",
"default",
"?",
"(",
"0",
",",
"_generateBigInt2",
".",
"default",
")",
"(",
"index",
",",
"alphabet",
")",
":",
"(",
"0",
",",
"_generateInt2",
".",
"d... | string generation function | [
"string",
"generation",
"function"
] | 52fb6b5b05940138fb58f9a1c937531ad90adda5 | https://github.com/lmammino/indexed-string-variation/blob/52fb6b5b05940138fb58f9a1c937531ad90adda5/lib/index.js#L39-L41 | train |
davidfig/settingspanel | docs/code.js | number | function number()
{
const number = document.createElement('div')
document.body.appendChild(number)
number.innerHTML = rand(1000)
number.style.fontSize = '300%'
number.style.position = 'fixed'
number.style.left = number.style.top = '50%'
number.style.color = 'r... | javascript | function number()
{
const number = document.createElement('div')
document.body.appendChild(number)
number.innerHTML = rand(1000)
number.style.fontSize = '300%'
number.style.position = 'fixed'
number.style.left = number.style.top = '50%'
number.style.color = 'r... | [
"function",
"number",
"(",
")",
"{",
"const",
"number",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
"document",
".",
"body",
".",
"appendChild",
"(",
"number",
")",
"number",
".",
"innerHTML",
"=",
"rand",
"(",
"1000",
")",
"number",
".",
... | create and style test text | [
"create",
"and",
"style",
"test",
"text"
] | d9ba20d9b6d398e9dc5ba199d81dfc4fb08b9cfe | https://github.com/davidfig/settingspanel/blob/d9ba20d9b6d398e9dc5ba199d81dfc4fb08b9cfe/docs/code.js#L55-L66 | train |
rohithpr/ipc-messenger | ipc-messenger.js | function(message) {
var pack = {
toMaster: true,
toWorkers: false,
toSource: false,
message: message,
source: process.pid
}
dispatch(pack)
} | javascript | function(message) {
var pack = {
toMaster: true,
toWorkers: false,
toSource: false,
message: message,
source: process.pid
}
dispatch(pack)
} | [
"function",
"(",
"message",
")",
"{",
"var",
"pack",
"=",
"{",
"toMaster",
":",
"true",
",",
"toWorkers",
":",
"false",
",",
"toSource",
":",
"false",
",",
"message",
":",
"message",
",",
"source",
":",
"process",
".",
"pid",
"}",
"dispatch",
"(",
"p... | This function can be used by workers to send a message to the master | [
"This",
"function",
"can",
"be",
"used",
"by",
"workers",
"to",
"send",
"a",
"message",
"to",
"the",
"master"
] | 46fd7471bb4e99367b7da6d23f93ff4eecd43d04 | https://github.com/rohithpr/ipc-messenger/blob/46fd7471bb4e99367b7da6d23f93ff4eecd43d04/ipc-messenger.js#L10-L19 | train | |
rohithpr/ipc-messenger | ipc-messenger.js | function(pack) {
if (pack.toSource !== false || pack.source !== process.pid) {
CALLBACK(pack.message)
}
} | javascript | function(pack) {
if (pack.toSource !== false || pack.source !== process.pid) {
CALLBACK(pack.message)
}
} | [
"function",
"(",
"pack",
")",
"{",
"if",
"(",
"pack",
".",
"toSource",
"!==",
"false",
"||",
"pack",
".",
"source",
"!==",
"process",
".",
"pid",
")",
"{",
"CALLBACK",
"(",
"pack",
".",
"message",
")",
"}",
"}"
] | Message receiver of the workers | [
"Message",
"receiver",
"of",
"the",
"workers"
] | 46fd7471bb4e99367b7da6d23f93ff4eecd43d04 | https://github.com/rohithpr/ipc-messenger/blob/46fd7471bb4e99367b7da6d23f93ff4eecd43d04/ipc-messenger.js#L55-L59 | train | |
rohithpr/ipc-messenger | ipc-messenger.js | function(pack) {
if (cluster.isMaster) {
if (pack.toWorkers === true) {
for (var key in cluster.workers) {
cluster.workers[key].send(pack)
}
}
}
else {
if (pack.toMaster === true || pack.toWorkers === true) {
process.send(pack)
}
}
} | javascript | function(pack) {
if (cluster.isMaster) {
if (pack.toWorkers === true) {
for (var key in cluster.workers) {
cluster.workers[key].send(pack)
}
}
}
else {
if (pack.toMaster === true || pack.toWorkers === true) {
process.send(pack)
}
}
} | [
"function",
"(",
"pack",
")",
"{",
"if",
"(",
"cluster",
".",
"isMaster",
")",
"{",
"if",
"(",
"pack",
".",
"toWorkers",
"===",
"true",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"cluster",
".",
"workers",
")",
"{",
"cluster",
".",
"workers",
"[",
... | Common function called to send messages to other processes | [
"Common",
"function",
"called",
"to",
"send",
"messages",
"to",
"other",
"processes"
] | 46fd7471bb4e99367b7da6d23f93ff4eecd43d04 | https://github.com/rohithpr/ipc-messenger/blob/46fd7471bb4e99367b7da6d23f93ff4eecd43d04/ipc-messenger.js#L62-L75 | train | |
rohithpr/ipc-messenger | ipc-messenger.js | function(process, callback) {
if (callback !== undefined && typeof callback === 'function') {
CALLBACK = callback
}
if (cluster.isMaster) {
process.on('message', masterHandler)
}
else {
process.on('message', workerHandler)
}
} | javascript | function(process, callback) {
if (callback !== undefined && typeof callback === 'function') {
CALLBACK = callback
}
if (cluster.isMaster) {
process.on('message', masterHandler)
}
else {
process.on('message', workerHandler)
}
} | [
"function",
"(",
"process",
",",
"callback",
")",
"{",
"if",
"(",
"callback",
"!==",
"undefined",
"&&",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"CALLBACK",
"=",
"callback",
"}",
"if",
"(",
"cluster",
".",
"isMaster",
")",
"{",
"process",
"."... | Used to register processes and custom callback functions | [
"Used",
"to",
"register",
"processes",
"and",
"custom",
"callback",
"functions"
] | 46fd7471bb4e99367b7da6d23f93ff4eecd43d04 | https://github.com/rohithpr/ipc-messenger/blob/46fd7471bb4e99367b7da6d23f93ff4eecd43d04/ipc-messenger.js#L78-L88 | train | |
reworkcss/rework-plugin-function | index.js | func | function func(declarations, functions, functionMatcher, parseArgs) {
if (!declarations) return;
if (false !== parseArgs) parseArgs = true;
declarations.forEach(function(decl){
if ('comment' == decl.type) return;
var generatedFuncs = [], result, generatedFunc;
while (decl.value.match(functionMatcher)... | javascript | function func(declarations, functions, functionMatcher, parseArgs) {
if (!declarations) return;
if (false !== parseArgs) parseArgs = true;
declarations.forEach(function(decl){
if ('comment' == decl.type) return;
var generatedFuncs = [], result, generatedFunc;
while (decl.value.match(functionMatcher)... | [
"function",
"func",
"(",
"declarations",
",",
"functions",
",",
"functionMatcher",
",",
"parseArgs",
")",
"{",
"if",
"(",
"!",
"declarations",
")",
"return",
";",
"if",
"(",
"false",
"!==",
"parseArgs",
")",
"parseArgs",
"=",
"true",
";",
"declarations",
"... | Visit declarations and apply functions.
@param {Array} declarations
@param {Object} functions
@param {RegExp} functionMatcher
@param {Boolean} [parseArgs]
@api private | [
"Visit",
"declarations",
"and",
"apply",
"functions",
"."
] | a5b83c1e3a103bad7ec21afba44c7aa015151e30 | https://github.com/reworkcss/rework-plugin-function/blob/a5b83c1e3a103bad7ec21afba44c7aa015151e30/index.js#L33-L70 | train |
iolo/express-toybox | error500.js | error500 | function error500(options) {
options = _.merge({}, DEF_CONFIG, options);
// pre-compile underscore template if available
if (typeof options.template === 'string' && options.template.length > 0) {
options.template = _.template(options.template);
}
return function (err, req, res, next) {
... | javascript | function error500(options) {
options = _.merge({}, DEF_CONFIG, options);
// pre-compile underscore template if available
if (typeof options.template === 'string' && options.template.length > 0) {
options.template = _.template(options.template);
}
return function (err, req, res, next) {
... | [
"function",
"error500",
"(",
"options",
")",
"{",
"options",
"=",
"_",
".",
"merge",
"(",
"{",
"}",
",",
"DEF_CONFIG",
",",
"options",
")",
";",
"// pre-compile underscore template if available",
"if",
"(",
"typeof",
"options",
".",
"template",
"===",
"'string... | express uncaught error handler.
@param {*} options
@param {Number} [options.status=500]
@param {Number} [options.code=8500]
@param {*} [options.mappings={}] map err.name/err.code to error response.
@param {Boolean} [options.stack=false]
@param {String|Function} [options.template] lodash(underscore) micro template for ... | [
"express",
"uncaught",
"error",
"handler",
"."
] | c375a1388cfc167017e8dcd2325e71ca86ccb994 | https://github.com/iolo/express-toybox/blob/c375a1388cfc167017e8dcd2325e71ca86ccb994/error500.js#L33-L70 | train |
pd4d10/userscript-meta | index.js | parse | function parse(meta) {
if (typeof meta !== 'string') {
throw new Error('`Parse`\'s first argument should be a string')
}
return meta.split(/[\r\n]/)
.filter(function (line) { // remove blank line
return /\S+/.test(line) &&
line.indexOf('==UserScript==') === -1 &&
line.indexOf('==/Us... | javascript | function parse(meta) {
if (typeof meta !== 'string') {
throw new Error('`Parse`\'s first argument should be a string')
}
return meta.split(/[\r\n]/)
.filter(function (line) { // remove blank line
return /\S+/.test(line) &&
line.indexOf('==UserScript==') === -1 &&
line.indexOf('==/Us... | [
"function",
"parse",
"(",
"meta",
")",
"{",
"if",
"(",
"typeof",
"meta",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'`Parse`\\'s first argument should be a string'",
")",
"}",
"return",
"meta",
".",
"split",
"(",
"/",
"[\\r\\n]",
"/",
")",
... | Parse metadata to an object | [
"Parse",
"metadata",
"to",
"an",
"object"
] | f5592b55ff40e782a91020cc7e9560594493f39a | https://github.com/pd4d10/userscript-meta/blob/f5592b55ff40e782a91020cc7e9560594493f39a/index.js#L12-L38 | train |
pd4d10/userscript-meta | index.js | stringify | function stringify(obj) {
if (!isObject(obj)) {
throw new Error('`Stringify`\'s first argument should be an object')
}
var meta = Object.keys(obj)
.map(function (key) {
return getLine(key, obj[key])
}).join('')
return '// ==UserScript==\n' + meta + '// ==/UserScript==\n'
} | javascript | function stringify(obj) {
if (!isObject(obj)) {
throw new Error('`Stringify`\'s first argument should be an object')
}
var meta = Object.keys(obj)
.map(function (key) {
return getLine(key, obj[key])
}).join('')
return '// ==UserScript==\n' + meta + '// ==/UserScript==\n'
} | [
"function",
"stringify",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"obj",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'`Stringify`\\'s first argument should be an object'",
")",
"}",
"var",
"meta",
"=",
"Object",
".",
"keys",
"(",
"obj",
")"... | Stringify metadata from an object | [
"Stringify",
"metadata",
"from",
"an",
"object"
] | f5592b55ff40e782a91020cc7e9560594493f39a | https://github.com/pd4d10/userscript-meta/blob/f5592b55ff40e782a91020cc7e9560594493f39a/index.js#L52-L63 | train |
haasz/laravel-mix-ext | src/index.js | addOutProperty | function addOutProperty(out, directory, extensions) {
out[directory] = {
extensions: extensions
};
Object.defineProperty(
out[directory],
'directory',
{
get: function () {
return Config.fileLoaderDirs[directory];
},
set: function (value) {
Config.fileLoaderDirs[directory] = value;
},
e... | javascript | function addOutProperty(out, directory, extensions) {
out[directory] = {
extensions: extensions
};
Object.defineProperty(
out[directory],
'directory',
{
get: function () {
return Config.fileLoaderDirs[directory];
},
set: function (value) {
Config.fileLoaderDirs[directory] = value;
},
e... | [
"function",
"addOutProperty",
"(",
"out",
",",
"directory",
",",
"extensions",
")",
"{",
"out",
"[",
"directory",
"]",
"=",
"{",
"extensions",
":",
"extensions",
"}",
";",
"Object",
".",
"defineProperty",
"(",
"out",
"[",
"directory",
"]",
",",
"'directory... | Add an output directory settings to the configuration.
@param {Object} out The output configuration.
@param {string} directory The directory setting key and default name.
@param {string[]} extensions The file extensions. | [
"Add",
"an",
"output",
"directory",
"settings",
"to",
"the",
"configuration",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L232-L251 | train |
haasz/laravel-mix-ext | src/index.js | arraySubtraction | function arraySubtraction(arrA, arrB) {
arrA = arrA.slice();
for (let i = 0; i < arrB.length; ++i) {
arrA = arrA.filter(function (value) {
return value !== arrB[i];
});
}
return arrA;
} | javascript | function arraySubtraction(arrA, arrB) {
arrA = arrA.slice();
for (let i = 0; i < arrB.length; ++i) {
arrA = arrA.filter(function (value) {
return value !== arrB[i];
});
}
return arrA;
} | [
"function",
"arraySubtraction",
"(",
"arrA",
",",
"arrB",
")",
"{",
"arrA",
"=",
"arrA",
".",
"slice",
"(",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"arrB",
".",
"length",
";",
"++",
"i",
")",
"{",
"arrA",
"=",
"arrA",
".",
... | Array subtraction.
@param {Array} arrA The minuend array.
@param {Array} arrB The subtrahend array.
@return {Array} The difference array. | [
"Array",
"subtraction",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L336-L344 | train |
haasz/laravel-mix-ext | src/index.js | getDirFromPublicPath | function getDirFromPublicPath(file) {
return path.posix.dirname(
path.posix.normalize(
path.posix.sep
+ file.path().replace(
new RegExp(
'^' + escapeStringRegExp(path.resolve(Config.publicPath))
),
''
).split(path.sep).join(path.posix.sep)
)
);
} | javascript | function getDirFromPublicPath(file) {
return path.posix.dirname(
path.posix.normalize(
path.posix.sep
+ file.path().replace(
new RegExp(
'^' + escapeStringRegExp(path.resolve(Config.publicPath))
),
''
).split(path.sep).join(path.posix.sep)
)
);
} | [
"function",
"getDirFromPublicPath",
"(",
"file",
")",
"{",
"return",
"path",
".",
"posix",
".",
"dirname",
"(",
"path",
".",
"posix",
".",
"normalize",
"(",
"path",
".",
"posix",
".",
"sep",
"+",
"file",
".",
"path",
"(",
")",
".",
"replace",
"(",
"n... | Get the directory of file from public path.
@param {Object} file The file.
@return {string} The directory of file from public path. | [
"Get",
"the",
"directory",
"of",
"file",
"from",
"public",
"path",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L499-L511 | train |
haasz/laravel-mix-ext | src/index.js | replaceTplTag | function replaceTplTag(dirFromPublicPath, tag, replacements, templateFileLog) {
let tagPath = tag.replace(new RegExp(tplTagPathRegExpStr), '$1');
let tagPathFromPublicPath = path.posix.resolve(dirFromPublicPath, tagPath);
if (
tagPathFromPublicPath in replacements
&&
replacements.hasOwnProperty(tagPathFromPubl... | javascript | function replaceTplTag(dirFromPublicPath, tag, replacements, templateFileLog) {
let tagPath = tag.replace(new RegExp(tplTagPathRegExpStr), '$1');
let tagPathFromPublicPath = path.posix.resolve(dirFromPublicPath, tagPath);
if (
tagPathFromPublicPath in replacements
&&
replacements.hasOwnProperty(tagPathFromPubl... | [
"function",
"replaceTplTag",
"(",
"dirFromPublicPath",
",",
"tag",
",",
"replacements",
",",
"templateFileLog",
")",
"{",
"let",
"tagPath",
"=",
"tag",
".",
"replace",
"(",
"new",
"RegExp",
"(",
"tplTagPathRegExpStr",
")",
",",
"'$1'",
")",
";",
"let",
"tagP... | Replace a template tag.
@param {string} dirFromPublicPath The directory of the file that contains the template tag.
@param {string} tag The template tag.
@param {Object} replacements The replacements.
@param {Object} templateFileLog The template file log.
@return {string} Th... | [
"Replace",
"a",
"template",
"tag",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L524-L545 | train |
haasz/laravel-mix-ext | src/index.js | getCompiledContent | function getCompiledContent(file, fragments, tags, replacements, templateFileLog) {
let content = '';
let fragmentStep = numberOfTplTagRegExpParts + 1;
let dirFromPublicPath = getDirFromPublicPath(file);
let i = 0;
for (; i < tags.length; ++i) {
content += fragments[i * fragmentStep];
content += replaceTplTag(... | javascript | function getCompiledContent(file, fragments, tags, replacements, templateFileLog) {
let content = '';
let fragmentStep = numberOfTplTagRegExpParts + 1;
let dirFromPublicPath = getDirFromPublicPath(file);
let i = 0;
for (; i < tags.length; ++i) {
content += fragments[i * fragmentStep];
content += replaceTplTag(... | [
"function",
"getCompiledContent",
"(",
"file",
",",
"fragments",
",",
"tags",
",",
"replacements",
",",
"templateFileLog",
")",
"{",
"let",
"content",
"=",
"''",
";",
"let",
"fragmentStep",
"=",
"numberOfTplTagRegExpParts",
"+",
"1",
";",
"let",
"dirFromPublicPa... | Get the compiled content of template file.
@param {Object} file The template file.
@param {string[]} fragments The content fragments.
@param {string[]} tags The template tags in original content.
@param {Object} replacements The replacements.
@param {Object} templateFileLog Th... | [
"Get",
"the",
"compiled",
"content",
"of",
"template",
"file",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L559-L575 | train |
haasz/laravel-mix-ext | src/index.js | compileTemplate | function compileTemplate(file, replacements, templateFileLog) {
file = File.find(path.resolve(file));
let content = file.read();
let tags = content.match(new RegExp(tplTagRegExpStr, 'g'));
if (tags && tags.length) {
content = getCompiledContent(
file,
content.split(new RegExp(tplTagRegExpStr)),
tags,
... | javascript | function compileTemplate(file, replacements, templateFileLog) {
file = File.find(path.resolve(file));
let content = file.read();
let tags = content.match(new RegExp(tplTagRegExpStr, 'g'));
if (tags && tags.length) {
content = getCompiledContent(
file,
content.split(new RegExp(tplTagRegExpStr)),
tags,
... | [
"function",
"compileTemplate",
"(",
"file",
",",
"replacements",
",",
"templateFileLog",
")",
"{",
"file",
"=",
"File",
".",
"find",
"(",
"path",
".",
"resolve",
"(",
"file",
")",
")",
";",
"let",
"content",
"=",
"file",
".",
"read",
"(",
")",
";",
"... | Compile the template file.
@param {string} file The template file.
@param {Object} replacements The replacements.
@param {Object} templateFileLog The template file log. | [
"Compile",
"the",
"template",
"file",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L585-L599 | train |
haasz/laravel-mix-ext | src/index.js | processTemplates | function processTemplates(templates) {
var templateProcessingLog = logger.createTemplateProcessingLog();
var replacements = Mix.manifest.get();
for (let template in templates) {
if (templates.hasOwnProperty(template)) {
// Copy to target
fs.copySync(template, templates[template]);
// Compile
compileTem... | javascript | function processTemplates(templates) {
var templateProcessingLog = logger.createTemplateProcessingLog();
var replacements = Mix.manifest.get();
for (let template in templates) {
if (templates.hasOwnProperty(template)) {
// Copy to target
fs.copySync(template, templates[template]);
// Compile
compileTem... | [
"function",
"processTemplates",
"(",
"templates",
")",
"{",
"var",
"templateProcessingLog",
"=",
"logger",
".",
"createTemplateProcessingLog",
"(",
")",
";",
"var",
"replacements",
"=",
"Mix",
".",
"manifest",
".",
"get",
"(",
")",
";",
"for",
"(",
"let",
"t... | Process the template files.
@param {Object} templates The templates. | [
"Process",
"the",
"template",
"files",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L607-L626 | train |
haasz/laravel-mix-ext | src/index.js | watchFile | function watchFile(file, callback) {
let absolutePath = File.find(file).path();
let watcher = chokidar
.watch(
absolutePath,
{
persistent: true
}
)
.on(
'change',
function () {
if (typeof callback === 'function') {
callback(file);
}
watcher.unwatch(absolutePath);
watchFil... | javascript | function watchFile(file, callback) {
let absolutePath = File.find(file).path();
let watcher = chokidar
.watch(
absolutePath,
{
persistent: true
}
)
.on(
'change',
function () {
if (typeof callback === 'function') {
callback(file);
}
watcher.unwatch(absolutePath);
watchFil... | [
"function",
"watchFile",
"(",
"file",
",",
"callback",
")",
"{",
"let",
"absolutePath",
"=",
"File",
".",
"find",
"(",
"file",
")",
".",
"path",
"(",
")",
";",
"let",
"watcher",
"=",
"chokidar",
".",
"watch",
"(",
"absolutePath",
",",
"{",
"persistent"... | Watch the file's changes.
@param {string} file The file.
@param {Function} callback The callback function. | [
"Watch",
"the",
"file",
"s",
"changes",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L635-L655 | train |
haasz/laravel-mix-ext | src/index.js | notify | function notify(message) {
if (Mix.isUsing('notifications')) {
let contentImage = path.join(__dirname, '../img/sunshine.png');
notifier.notify({
title: 'The Extension of Laravel Mix',
message: message,
contentImage: contentImage,
icon: (os.platform() === 'win32' || os.platform() === 'linux') ? contentI... | javascript | function notify(message) {
if (Mix.isUsing('notifications')) {
let contentImage = path.join(__dirname, '../img/sunshine.png');
notifier.notify({
title: 'The Extension of Laravel Mix',
message: message,
contentImage: contentImage,
icon: (os.platform() === 'win32' || os.platform() === 'linux') ? contentI... | [
"function",
"notify",
"(",
"message",
")",
"{",
"if",
"(",
"Mix",
".",
"isUsing",
"(",
"'notifications'",
")",
")",
"{",
"let",
"contentImage",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'../img/sunshine.png'",
")",
";",
"notifier",
".",
"notify",
... | Send a cross platform native notification.
@param {string} message The message. | [
"Send",
"a",
"cross",
"platform",
"native",
"notification",
"."
] | bd1c794bdbf934dae233ab697dc5d5593d4b1124 | https://github.com/haasz/laravel-mix-ext/blob/bd1c794bdbf934dae233ab697dc5d5593d4b1124/src/index.js#L663-L673 | train |
NumminorihSF/bramqp-wrapper | domain/tx.js | TX | function TX(client, channel){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
return this;
} | javascript | function TX(client, channel){
EE.call(this);
this.client = client;
this.channel = channel;
this.id = channel.$getId();
return this;
} | [
"function",
"TX",
"(",
"client",
",",
"channel",
")",
"{",
"EE",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"channel",
"=",
"channel",
";",
"this",
".",
"id",
"=",
"channel",
".",
"$getId",
"(",
")... | Work with transactions.
The Tx class allows publish and ack operations to be batched into atomic units of work.
The intention is that all publish and ack requests issued within a transaction will
complete successfully or none of them will.
Servers SHOULD implement atomic transactions at least where all publish or ack ... | [
"Work",
"with",
"transactions",
"."
] | 3e2bd769a2828f7592eba79556c9ef1491177781 | https://github.com/NumminorihSF/bramqp-wrapper/blob/3e2bd769a2828f7592eba79556c9ef1491177781/domain/tx.js#L23-L30 | train |
fresheneesz/asyncFuture | asyncFuture.js | executeCallback | function executeCallback(cb, arg) {
var r = cb(arg)
if(r !== undefined && !isLikeAFuture(r) )
throw Error("Value returned from then or catch ("+r+") is *not* a Future. Callback: "+cb.toString())
return r
} | javascript | function executeCallback(cb, arg) {
var r = cb(arg)
if(r !== undefined && !isLikeAFuture(r) )
throw Error("Value returned from then or catch ("+r+") is *not* a Future. Callback: "+cb.toString())
return r
} | [
"function",
"executeCallback",
"(",
"cb",
",",
"arg",
")",
"{",
"var",
"r",
"=",
"cb",
"(",
"arg",
")",
"if",
"(",
"r",
"!==",
"undefined",
"&&",
"!",
"isLikeAFuture",
"(",
"r",
")",
")",
"throw",
"Error",
"(",
"\"Value returned from then or catch (\"",
... | executes a callback and ensures that it returns a future | [
"executes",
"a",
"callback",
"and",
"ensures",
"that",
"it",
"returns",
"a",
"future"
] | 312d8732db06b15455b844934b5b3ca5dd2debb5 | https://github.com/fresheneesz/asyncFuture/blob/312d8732db06b15455b844934b5b3ca5dd2debb5/asyncFuture.js#L352-L358 | train |
fallanic/node-squad | lib/node-squad.js | batchLoop | function batchLoop(){
var promisesArray = createBatchJobs();
Q[qFunction](promisesArray).then(function(batchResult){
if(qFunction === "allSettled"){
batchResult = batchResult.filter(function(res){return res.state === "fulfilled"}).map(function(i... | javascript | function batchLoop(){
var promisesArray = createBatchJobs();
Q[qFunction](promisesArray).then(function(batchResult){
if(qFunction === "allSettled"){
batchResult = batchResult.filter(function(res){return res.state === "fulfilled"}).map(function(i... | [
"function",
"batchLoop",
"(",
")",
"{",
"var",
"promisesArray",
"=",
"createBatchJobs",
"(",
")",
";",
"Q",
"[",
"qFunction",
"]",
"(",
"promisesArray",
")",
".",
"then",
"(",
"function",
"(",
"batchResult",
")",
"{",
"if",
"(",
"qFunction",
"===",
"\"al... | the main loop creating batches of jobs | [
"the",
"main",
"loop",
"creating",
"batches",
"of",
"jobs"
] | 142afe88a8859d273c421cd7598792250224e2be | https://github.com/fallanic/node-squad/blob/142afe88a8859d273c421cd7598792250224e2be/lib/node-squad.js#L54-L81 | train |
fallanic/node-squad | lib/node-squad.js | createBatchJobs | function createBatchJobs(){
var promises = [];
for(var i=0;i<squadSize && dataCopy.length > 0;i++){
var item = dataCopy.shift();
promises.push(worker(item));
}
return promises;
} | javascript | function createBatchJobs(){
var promises = [];
for(var i=0;i<squadSize && dataCopy.length > 0;i++){
var item = dataCopy.shift();
promises.push(worker(item));
}
return promises;
} | [
"function",
"createBatchJobs",
"(",
")",
"{",
"var",
"promises",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"squadSize",
"&&",
"dataCopy",
".",
"length",
">",
"0",
";",
"i",
"++",
")",
"{",
"var",
"item",
"=",
"dataCopy"... | this will create a batch of up to squadSize jobs | [
"this",
"will",
"create",
"a",
"batch",
"of",
"up",
"to",
"squadSize",
"jobs"
] | 142afe88a8859d273c421cd7598792250224e2be | https://github.com/fallanic/node-squad/blob/142afe88a8859d273c421cd7598792250224e2be/lib/node-squad.js#L84-L92 | train |
AndiDittrich/Node.mysql-magic | lib/fetch-all.js | fetchAll | async function fetchAll(connection, query, params){
// execute query
const [result] = await _query(connection, query, params);
// entry found ?
return result || [];
} | javascript | async function fetchAll(connection, query, params){
// execute query
const [result] = await _query(connection, query, params);
// entry found ?
return result || [];
} | [
"async",
"function",
"fetchAll",
"(",
"connection",
",",
"query",
",",
"params",
")",
"{",
"// execute query",
"const",
"[",
"result",
"]",
"=",
"await",
"_query",
"(",
"connection",
",",
"query",
",",
"params",
")",
";",
"// entry found ?",
"return",
"resul... | fetch multiple rows in once | [
"fetch",
"multiple",
"rows",
"in",
"once"
] | f9783ac93f4a5744407781d7875ae68cad58cc48 | https://github.com/AndiDittrich/Node.mysql-magic/blob/f9783ac93f4a5744407781d7875ae68cad58cc48/lib/fetch-all.js#L4-L11 | train |
jtheriault/code-copter | examples/analyzer-plugin/code-copter-analyzer-hell-no-world/index.js | analyze | function analyze (fileSourceData) {
var analysis = new Analysis();
for (let sample of fileSourceData) {
if (saysHelloWorld(sample.text)) {
analysis.addError({
line: sample.line,
message: 'At least try to look like you didn\'t copy the demo code!'
... | javascript | function analyze (fileSourceData) {
var analysis = new Analysis();
for (let sample of fileSourceData) {
if (saysHelloWorld(sample.text)) {
analysis.addError({
line: sample.line,
message: 'At least try to look like you didn\'t copy the demo code!'
... | [
"function",
"analyze",
"(",
"fileSourceData",
")",
"{",
"var",
"analysis",
"=",
"new",
"Analysis",
"(",
")",
";",
"for",
"(",
"let",
"sample",
"of",
"fileSourceData",
")",
"{",
"if",
"(",
"saysHelloWorld",
"(",
"sample",
".",
"text",
")",
")",
"{",
"an... | Analyze file source data for the case-insensitive phrase "Hello world".
@param {FileSourceData} fileSourceData - The file source data to analyze.
@returns {Analysis} - The analysis of the file source data. | [
"Analyze",
"file",
"source",
"data",
"for",
"the",
"case",
"-",
"insensitive",
"phrase",
"Hello",
"world",
"."
] | e69f22e1c9de5d59d15958a09d732ce8d8b519fb | https://github.com/jtheriault/code-copter/blob/e69f22e1c9de5d59d15958a09d732ce8d8b519fb/examples/analyzer-plugin/code-copter-analyzer-hell-no-world/index.js#L18-L31 | train |
Galiaf47/lib3d | src/controls.js | onMouseDown | function onMouseDown(event, env, isSideEffectsDisabled) {
mouse.down(event, env ? env.camera : null);
if (!env || isSideEffectsDisabled) {
return;
}
if (mouse.keys[1] && !mouse.keys[3]) {
let focusedObject = focusObject(env.library, env.camera, env.selector);
if (env.selector.... | javascript | function onMouseDown(event, env, isSideEffectsDisabled) {
mouse.down(event, env ? env.camera : null);
if (!env || isSideEffectsDisabled) {
return;
}
if (mouse.keys[1] && !mouse.keys[3]) {
let focusedObject = focusObject(env.library, env.camera, env.selector);
if (env.selector.... | [
"function",
"onMouseDown",
"(",
"event",
",",
"env",
",",
"isSideEffectsDisabled",
")",
"{",
"mouse",
".",
"down",
"(",
"event",
",",
"env",
"?",
"env",
".",
"camera",
":",
"null",
")",
";",
"if",
"(",
"!",
"env",
"||",
"isSideEffectsDisabled",
")",
"{... | Triggers object select
@alias module:lib3d.onMouseDown
@param {Object} event - mouse event
@param {Environment} env - affected environment
@param {Boolean} isSideEffectsDisabled - disable side effects like focusing, selecting, moving objects | [
"Triggers",
"object",
"select"
] | dccbb862fc23d8d7dd67a84761cc4012702a7d96 | https://github.com/Galiaf47/lib3d/blob/dccbb862fc23d8d7dd67a84761cc4012702a7d96/src/controls.js#L17-L31 | train |
Galiaf47/lib3d | src/controls.js | onMouseUp | function onMouseUp(event, env, isSideEffectsDisabled) {
mouse.up(event);
if (!env || isSideEffectsDisabled) {
return;
}
if (objectMoved) {
if(env.selector.isSelectedEditable()) {
events.triggerObjectChange(env.selector.getSelectedObject());
}
objectMoved = ... | javascript | function onMouseUp(event, env, isSideEffectsDisabled) {
mouse.up(event);
if (!env || isSideEffectsDisabled) {
return;
}
if (objectMoved) {
if(env.selector.isSelectedEditable()) {
events.triggerObjectChange(env.selector.getSelectedObject());
}
objectMoved = ... | [
"function",
"onMouseUp",
"(",
"event",
",",
"env",
",",
"isSideEffectsDisabled",
")",
"{",
"mouse",
".",
"up",
"(",
"event",
")",
";",
"if",
"(",
"!",
"env",
"||",
"isSideEffectsDisabled",
")",
"{",
"return",
";",
"}",
"if",
"(",
"objectMoved",
")",
"{... | Triggers object change
@alias module:lib3d.onMouseUp
@param {Object} event - mouse event
@param {Environment} env - affected environment
@param {Boolean} isSideEffectsDisabled - disable side effects like focusing, selecting, moving objects | [
"Triggers",
"object",
"change"
] | dccbb862fc23d8d7dd67a84761cc4012702a7d96 | https://github.com/Galiaf47/lib3d/blob/dccbb862fc23d8d7dd67a84761cc4012702a7d96/src/controls.js#L39-L53 | train |
Galiaf47/lib3d | src/controls.js | onMouseMove | function onMouseMove(event, env, isSideEffectsDisabled) {
event.preventDefault();
mouse.move(event, env ? env.camera : null);
if (!env || isSideEffectsDisabled) {
return;
}
if(mouse.keys[1] && !mouse.keys[3]) {
moveObject(env.library, env.camera, env.selector);
} else {
... | javascript | function onMouseMove(event, env, isSideEffectsDisabled) {
event.preventDefault();
mouse.move(event, env ? env.camera : null);
if (!env || isSideEffectsDisabled) {
return;
}
if(mouse.keys[1] && !mouse.keys[3]) {
moveObject(env.library, env.camera, env.selector);
} else {
... | [
"function",
"onMouseMove",
"(",
"event",
",",
"env",
",",
"isSideEffectsDisabled",
")",
"{",
"event",
".",
"preventDefault",
"(",
")",
";",
"mouse",
".",
"move",
"(",
"event",
",",
"env",
"?",
"env",
".",
"camera",
":",
"null",
")",
";",
"if",
"(",
"... | Triggers object focus
@alias module:lib3d.onMouseMove
@param {Object} event - mouse event
@param {Environment} env - affected environment
@param {Boolean} isSideEffectsDisabled - disable side effects like focusing, selecting, moving objects | [
"Triggers",
"object",
"focus"
] | dccbb862fc23d8d7dd67a84761cc4012702a7d96 | https://github.com/Galiaf47/lib3d/blob/dccbb862fc23d8d7dd67a84761cc4012702a7d96/src/controls.js#L61-L74 | train |
Galiaf47/lib3d | src/controls.js | rotateObject | function rotateObject(obj, rotation, order) {
let originRotation = obj.rotation.clone();
obj.rotation.setFromVector3(originRotation.toVector3().add(rotation), order);
if (obj.isCollided()) {
obj.rotation.setFromVector3(originRotation.toVector3(), originRotation.order);
return false;
}
... | javascript | function rotateObject(obj, rotation, order) {
let originRotation = obj.rotation.clone();
obj.rotation.setFromVector3(originRotation.toVector3().add(rotation), order);
if (obj.isCollided()) {
obj.rotation.setFromVector3(originRotation.toVector3(), originRotation.order);
return false;
}
... | [
"function",
"rotateObject",
"(",
"obj",
",",
"rotation",
",",
"order",
")",
"{",
"let",
"originRotation",
"=",
"obj",
".",
"rotation",
".",
"clone",
"(",
")",
";",
"obj",
".",
"rotation",
".",
"setFromVector3",
"(",
"originRotation",
".",
"toVector3",
"(",... | Rotate an object with avoiiding collisions and triggering objectChangeEvent
@alias module:lib3d.rotateObject
@param {BaseObject} obj - Object to rotate
@param {THREE.Vector3} rotation - A vector with rotation angles in radians
@param {String} order - Euler angles order (optional) | [
"Rotate",
"an",
"object",
"with",
"avoiiding",
"collisions",
"and",
"triggering",
"objectChangeEvent"
] | dccbb862fc23d8d7dd67a84761cc4012702a7d96 | https://github.com/Galiaf47/lib3d/blob/dccbb862fc23d8d7dd67a84761cc4012702a7d96/src/controls.js#L133-L146 | train |
ApsisInternational/gulp-config-apsis | src/taskMaker.js | taskMaker | function taskMaker(gulp) {
if (!gulp) {
throw new Error('Task maker: No gulp instance provided.');
}
const maker = {
createTask,
};
return maker;
function createTask(task) {
gulp.task(
task.name,
task.desc || false,
task.fn,
... | javascript | function taskMaker(gulp) {
if (!gulp) {
throw new Error('Task maker: No gulp instance provided.');
}
const maker = {
createTask,
};
return maker;
function createTask(task) {
gulp.task(
task.name,
task.desc || false,
task.fn,
... | [
"function",
"taskMaker",
"(",
"gulp",
")",
"{",
"if",
"(",
"!",
"gulp",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Task maker: No gulp instance provided.'",
")",
";",
"}",
"const",
"maker",
"=",
"{",
"createTask",
",",
"}",
";",
"return",
"maker",
";",
"f... | Create a gulp task
@param {object} task configuration for the task
@return {} | [
"Create",
"a",
"gulp",
"task"
] | 700ae59ca09e3a0e7787886531c7336bdf7491e8 | https://github.com/ApsisInternational/gulp-config-apsis/blob/700ae59ca09e3a0e7787886531c7336bdf7491e8/src/taskMaker.js#L6-L27 | train |
ironboy/warp-core | html-to-render.js | getFiles | function getFiles(folder = srcFolder){
let all = [];
let f = fs.readdirSync(folder);
for(file of f){
all.push(path.join(folder,file))
if(fs.lstatSync(path.join(folder,file)).isDirectory()){
all = all.concat(getFiles(path.join(folder,file)));
}
}
return all;
} | javascript | function getFiles(folder = srcFolder){
let all = [];
let f = fs.readdirSync(folder);
for(file of f){
all.push(path.join(folder,file))
if(fs.lstatSync(path.join(folder,file)).isDirectory()){
all = all.concat(getFiles(path.join(folder,file)));
}
}
return all;
} | [
"function",
"getFiles",
"(",
"folder",
"=",
"srcFolder",
")",
"{",
"let",
"all",
"=",
"[",
"]",
";",
"let",
"f",
"=",
"fs",
".",
"readdirSync",
"(",
"folder",
")",
";",
"for",
"(",
"file",
"of",
"f",
")",
"{",
"all",
".",
"push",
"(",
"path",
"... | get all file paths in a folder recursively | [
"get",
"all",
"file",
"paths",
"in",
"a",
"folder",
"recursively"
] | 0e3556e41e40cdfc0dafdfd4d9e02662010e9379 | https://github.com/ironboy/warp-core/blob/0e3556e41e40cdfc0dafdfd4d9e02662010e9379/html-to-render.js#L32-L42 | train |
ariatemplates/noder-js | src/modules/resolver.js | function(map, terms) {
for (var i = 0, l = terms.length; i < l; i++) {
var curTerm = terms[i];
map = map[curTerm];
if (!map || curTerm === map) {
return false; // no change
} else if (isString(map)) {
applyChange(terms, map, i);
return true;
... | javascript | function(map, terms) {
for (var i = 0, l = terms.length; i < l; i++) {
var curTerm = terms[i];
map = map[curTerm];
if (!map || curTerm === map) {
return false; // no change
} else if (isString(map)) {
applyChange(terms, map, i);
return true;
... | [
"function",
"(",
"map",
",",
"terms",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"terms",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"curTerm",
"=",
"terms",
"[",
"i",
"]",
";",
"map",
"=",
"map",
... | Apply a module map iteration.
@param {Object} map
@param {Array} terms Note that this array is changed by this function.
@return {Boolean} | [
"Apply",
"a",
"module",
"map",
"iteration",
"."
] | c2db684299d907b2035fa427f030cf08da8ceb57 | https://github.com/ariatemplates/noder-js/blob/c2db684299d907b2035fa427f030cf08da8ceb57/src/modules/resolver.js#L65-L79 | train | |
molnarg/node-http2-protocol | example/server.js | onConnection | function onConnection(socket) {
var endpoint = new http2.Endpoint(log, 'SERVER', {});
endpoint.pipe(socket).pipe(endpoint);
endpoint.on('stream', function(stream) {
stream.on('headers', function(headers) {
var path = headers[':path'];
var filename = join(__dirname, path);
// Serving server... | javascript | function onConnection(socket) {
var endpoint = new http2.Endpoint(log, 'SERVER', {});
endpoint.pipe(socket).pipe(endpoint);
endpoint.on('stream', function(stream) {
stream.on('headers', function(headers) {
var path = headers[':path'];
var filename = join(__dirname, path);
// Serving server... | [
"function",
"onConnection",
"(",
"socket",
")",
"{",
"var",
"endpoint",
"=",
"new",
"http2",
".",
"Endpoint",
"(",
"log",
",",
"'SERVER'",
",",
"{",
"}",
")",
";",
"endpoint",
".",
"pipe",
"(",
"socket",
")",
".",
"pipe",
"(",
"endpoint",
")",
";",
... | Handling incoming connections | [
"Handling",
"incoming",
"connections"
] | a03dff630a33771d045ac0362023afb84b441aa4 | https://github.com/molnarg/node-http2-protocol/blob/a03dff630a33771d045ac0362023afb84b441aa4/example/server.js#L30-L71 | train |
dpjanes/iotdb-upnp | upnp/upnp-service.js | function (device, desc) {
EventEmitter.call(this);
if (TRACE && DETAIL) {
logger.info({
method: "UpnpService",
device: device,
desc: desc,
}, "called");
}
this.device = device;
this.ok = true;
this.forgotten = false
try {
this.s... | javascript | function (device, desc) {
EventEmitter.call(this);
if (TRACE && DETAIL) {
logger.info({
method: "UpnpService",
device: device,
desc: desc,
}, "called");
}
this.device = device;
this.ok = true;
this.forgotten = false
try {
this.s... | [
"function",
"(",
"device",
",",
"desc",
")",
"{",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"TRACE",
"&&",
"DETAIL",
")",
"{",
"logger",
".",
"info",
"(",
"{",
"method",
":",
"\"UpnpService\"",
",",
"device",
":",
"device",
",",
... | A UPnP service. | [
"A",
"UPnP",
"service",
"."
] | 514d6253eca4c6440105e48aa940a07778187e43 | https://github.com/dpjanes/iotdb-upnp/blob/514d6253eca4c6440105e48aa940a07778187e43/upnp/upnp-service.js#L28-L73 | train | |
marcelomf/graojs | modeling/assets/WebGL/matrix4x4.js | function () {
var tmp = this.elements[0*4+1];
this.elements[0*4+1] = this.elements[1*4+0];
this.elements[1*4+0] = tmp;
tmp = this.elements[0*4+2];
this.elements[0*4+2] = this.elements[2*4+0];
this.elements[2*4+0] = tmp;
tmp = this.elements[0*4+3];
this.elements[0*4+3] = this.elements[3... | javascript | function () {
var tmp = this.elements[0*4+1];
this.elements[0*4+1] = this.elements[1*4+0];
this.elements[1*4+0] = tmp;
tmp = this.elements[0*4+2];
this.elements[0*4+2] = this.elements[2*4+0];
this.elements[2*4+0] = tmp;
tmp = this.elements[0*4+3];
this.elements[0*4+3] = this.elements[3... | [
"function",
"(",
")",
"{",
"var",
"tmp",
"=",
"this",
".",
"elements",
"[",
"0",
"*",
"4",
"+",
"1",
"]",
";",
"this",
".",
"elements",
"[",
"0",
"*",
"4",
"+",
"1",
"]",
"=",
"this",
".",
"elements",
"[",
"1",
"*",
"4",
"+",
"0",
"]",
";... | In-place transpose | [
"In",
"-",
"place",
"transpose"
] | f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f | https://github.com/marcelomf/graojs/blob/f8fd9e5ed9406c6266c30777eb4f77474fe6ac4f/modeling/assets/WebGL/matrix4x4.js#L336-L362 | train | |
clubajax/on | dist/on.js | function (node, callback) {
return on.makeMultiHandle([
on(node, 'click', callback),
on(node, 'keyup:Enter', callback)
]);
} | javascript | function (node, callback) {
return on.makeMultiHandle([
on(node, 'click', callback),
on(node, 'keyup:Enter', callback)
]);
} | [
"function",
"(",
"node",
",",
"callback",
")",
"{",
"return",
"on",
".",
"makeMultiHandle",
"(",
"[",
"on",
"(",
"node",
",",
"'click'",
",",
"callback",
")",
",",
"on",
"(",
"node",
",",
"'keyup:Enter'",
",",
"callback",
")",
"]",
")",
";",
"}"
] | handle click and Enter | [
"handle",
"click",
"and",
"Enter"
] | a0472362dbab5928fcd70c12d420557db01f68fd | https://github.com/clubajax/on/blob/a0472362dbab5928fcd70c12d420557db01f68fd/dist/on.js#L84-L89 | train | |
clubajax/on | dist/on.js | function (node, callback) {
// important note!
// starts paused
//
var bHandle = on(node.ownerDocument.documentElement, 'click', function (e) {
var target = e.target;
if (target.nodeType !== 1) {
target = target.parentNode;
}
if (target && !node.contains(target)) {
callback(e);
... | javascript | function (node, callback) {
// important note!
// starts paused
//
var bHandle = on(node.ownerDocument.documentElement, 'click', function (e) {
var target = e.target;
if (target.nodeType !== 1) {
target = target.parentNode;
}
if (target && !node.contains(target)) {
callback(e);
... | [
"function",
"(",
"node",
",",
"callback",
")",
"{",
"// important note!",
"// starts paused",
"//",
"var",
"bHandle",
"=",
"on",
"(",
"node",
".",
"ownerDocument",
".",
"documentElement",
",",
"'click'",
",",
"function",
"(",
"e",
")",
"{",
"var",
"target",
... | custom - used for popups 'n stuff | [
"custom",
"-",
"used",
"for",
"popups",
"n",
"stuff"
] | a0472362dbab5928fcd70c12d420557db01f68fd | https://github.com/clubajax/on/blob/a0472362dbab5928fcd70c12d420557db01f68fd/dist/on.js#L92-L126 | train | |
clubajax/on | dist/on.js | onDomEvent | function onDomEvent (node, eventName, callback) {
node.addEventListener(eventName, callback, false);
return {
remove: function () {
node.removeEventListener(eventName, callback, false);
node = callback = null;
this.remove = this.pause = this.resume = function () {};
},
pause: function () {
... | javascript | function onDomEvent (node, eventName, callback) {
node.addEventListener(eventName, callback, false);
return {
remove: function () {
node.removeEventListener(eventName, callback, false);
node = callback = null;
this.remove = this.pause = this.resume = function () {};
},
pause: function () {
... | [
"function",
"onDomEvent",
"(",
"node",
",",
"eventName",
",",
"callback",
")",
"{",
"node",
".",
"addEventListener",
"(",
"eventName",
",",
"callback",
",",
"false",
")",
";",
"return",
"{",
"remove",
":",
"function",
"(",
")",
"{",
"node",
".",
"removeE... | internal event handlers | [
"internal",
"event",
"handlers"
] | a0472362dbab5928fcd70c12d420557db01f68fd | https://github.com/clubajax/on/blob/a0472362dbab5928fcd70c12d420557db01f68fd/dist/on.js#L131-L146 | train |
opencolor-tools/opencolor-js | lib/entry.js | rename | function rename(newName) {
newName = newName.replace(/[\.\/]/g, '');
if (this.isRoot()) {
this._name = newName;
} else {
var newPath = [this.parent.path(), newName].filter(function (e) {
return e !== '';
}).join('.');
this.moveTo(newPath);
}
} | javascript | function rename(newName) {
newName = newName.replace(/[\.\/]/g, '');
if (this.isRoot()) {
this._name = newName;
} else {
var newPath = [this.parent.path(), newName].filter(function (e) {
return e !== '';
}).join('.');
this.moveTo(newPath);
}
} | [
"function",
"rename",
"(",
"newName",
")",
"{",
"newName",
"=",
"newName",
".",
"replace",
"(",
"/",
"[\\.\\/]",
"/",
"g",
",",
"''",
")",
";",
"if",
"(",
"this",
".",
"isRoot",
"(",
")",
")",
"{",
"this",
".",
"_name",
"=",
"newName",
";",
"}",
... | Rename an Entry. This can also mean to move the entry from one point to another in the tree
@param {string} newName the new name/path for the renamed entry | [
"Rename",
"an",
"Entry",
".",
"This",
"can",
"also",
"mean",
"to",
"move",
"the",
"entry",
"from",
"one",
"point",
"to",
"another",
"in",
"the",
"tree"
] | c0a5832bba60ce1d3ece24bc72ee8b4e169c69ac | https://github.com/opencolor-tools/opencolor-js/blob/c0a5832bba60ce1d3ece24bc72ee8b4e169c69ac/lib/entry.js#L67-L77 | train |
KanoComputing/routy.js | lib/index.js | getHrefRec | function getHrefRec(element) {
var href = element.getAttribute('href');
if (href) {
return href.replace(location.origin, '');
}
if (element.parentElement && element.parentElement !== document.body) {
return getHrefRec(element.parentElement);
}
return null;
} | javascript | function getHrefRec(element) {
var href = element.getAttribute('href');
if (href) {
return href.replace(location.origin, '');
}
if (element.parentElement && element.parentElement !== document.body) {
return getHrefRec(element.parentElement);
}
return null;
} | [
"function",
"getHrefRec",
"(",
"element",
")",
"{",
"var",
"href",
"=",
"element",
".",
"getAttribute",
"(",
"'href'",
")",
";",
"if",
"(",
"href",
")",
"{",
"return",
"href",
".",
"replace",
"(",
"location",
".",
"origin",
",",
"''",
")",
";",
"}",
... | Search recursively href attribute value between given element and parents | [
"Search",
"recursively",
"href",
"attribute",
"value",
"between",
"given",
"element",
"and",
"parents"
] | ff659d35d2ff882158e2c04d94a67d2307ed04f7 | https://github.com/KanoComputing/routy.js/blob/ff659d35d2ff882158e2c04d94a67d2307ed04f7/lib/index.js#L190-L202 | train |
cliffano/cmdt | lib/reporters/console.js | _segment | function _segment(file) {
console.log();
process.stdout.write(util.format('%s ', file));
} | javascript | function _segment(file) {
console.log();
process.stdout.write(util.format('%s ', file));
} | [
"function",
"_segment",
"(",
"file",
")",
"{",
"console",
".",
"log",
"(",
")",
";",
"process",
".",
"stdout",
".",
"write",
"(",
"util",
".",
"format",
"(",
"'%s '",
",",
"file",
")",
")",
";",
"}"
] | Segment event handler, log a new line and test file name.
@param {String} file: test file name | [
"Segment",
"event",
"handler",
"log",
"a",
"new",
"line",
"and",
"test",
"file",
"name",
"."
] | 8b8de56a23994a02117069c9c6da5fa1a3176fe5 | https://github.com/cliffano/cmdt/blob/8b8de56a23994a02117069c9c6da5fa1a3176fe5/lib/reporters/console.js#L12-L15 | train |
cliffano/cmdt | lib/reporters/console.js | _success | function _success(test, result) {
process.stdout.write('.'.green);
successes.push({ test: test, result: result });
} | javascript | function _success(test, result) {
process.stdout.write('.'.green);
successes.push({ test: test, result: result });
} | [
"function",
"_success",
"(",
"test",
",",
"result",
")",
"{",
"process",
".",
"stdout",
".",
"write",
"(",
"'.'",
".",
"green",
")",
";",
"successes",
".",
"push",
"(",
"{",
"test",
":",
"test",
",",
"result",
":",
"result",
"}",
")",
";",
"}"
] | Success event handler, displays a green dot and register success.
@param {Object} test: test expectation (exitcode, output)
@param {Object} result: command execution result (exitcode, output) | [
"Success",
"event",
"handler",
"displays",
"a",
"green",
"dot",
"and",
"register",
"success",
"."
] | 8b8de56a23994a02117069c9c6da5fa1a3176fe5 | https://github.com/cliffano/cmdt/blob/8b8de56a23994a02117069c9c6da5fa1a3176fe5/lib/reporters/console.js#L23-L26 | train |
cliffano/cmdt | lib/reporters/console.js | _failure | function _failure(errors, test, result) {
process.stdout.write('.'.red);
failures.push({ errors: errors, test: test, result: result });
} | javascript | function _failure(errors, test, result) {
process.stdout.write('.'.red);
failures.push({ errors: errors, test: test, result: result });
} | [
"function",
"_failure",
"(",
"errors",
",",
"test",
",",
"result",
")",
"{",
"process",
".",
"stdout",
".",
"write",
"(",
"'.'",
".",
"red",
")",
";",
"failures",
".",
"push",
"(",
"{",
"errors",
":",
"errors",
",",
"test",
":",
"test",
",",
"resul... | Failure event handler, displays a red dot and register failure.
@param {Array} check errors
@param {Object} test: test expectation (exitcode, output)
@param {Object} result: command execution result (exitcode, output) | [
"Failure",
"event",
"handler",
"displays",
"a",
"red",
"dot",
"and",
"register",
"failure",
"."
] | 8b8de56a23994a02117069c9c6da5fa1a3176fe5 | https://github.com/cliffano/cmdt/blob/8b8de56a23994a02117069c9c6da5fa1a3176fe5/lib/reporters/console.js#L35-L38 | train |
cliffano/cmdt | lib/reporters/console.js | _end | function _end(debug) {
const DEBUG_FIELDS = ['exitcode', 'output', 'stdout', 'stderr'];
var summary = util.format(
'%d test%s, %d success%s, %d failure%s',
successes.length + failures.length,
(successes.length + failures.length > 1) ? 's' : '',
successes.length,
(successes.length > 1) ? 'es' :... | javascript | function _end(debug) {
const DEBUG_FIELDS = ['exitcode', 'output', 'stdout', 'stderr'];
var summary = util.format(
'%d test%s, %d success%s, %d failure%s',
successes.length + failures.length,
(successes.length + failures.length > 1) ? 's' : '',
successes.length,
(successes.length > 1) ? 'es' :... | [
"function",
"_end",
"(",
"debug",
")",
"{",
"const",
"DEBUG_FIELDS",
"=",
"[",
"'exitcode'",
",",
"'output'",
",",
"'stdout'",
",",
"'stderr'",
"]",
";",
"var",
"summary",
"=",
"util",
".",
"format",
"(",
"'%d test%s, %d success%s, %d failure%s'",
",",
"succes... | End event handler, displays test summary and optional debug message.
@param {Boolean} debug: if true, displays result output and exit code | [
"End",
"event",
"handler",
"displays",
"test",
"summary",
"and",
"optional",
"debug",
"message",
"."
] | 8b8de56a23994a02117069c9c6da5fa1a3176fe5 | https://github.com/cliffano/cmdt/blob/8b8de56a23994a02117069c9c6da5fa1a3176fe5/lib/reporters/console.js#L45-L93 | train |
Adam4lexander/aframe-event-decorators | event-binder.js | BindToEventDecorator | function BindToEventDecorator(_event, _target, _listenIn, _removeIn) {
return function(propertyName, func) {
const scope = this;
const event = _event || propertyName;
const target = !_target ? this.el : document.querySelector(_target);
if (!target) {
console.warn("Couldn't subscribe "+this.name+... | javascript | function BindToEventDecorator(_event, _target, _listenIn, _removeIn) {
return function(propertyName, func) {
const scope = this;
const event = _event || propertyName;
const target = !_target ? this.el : document.querySelector(_target);
if (!target) {
console.warn("Couldn't subscribe "+this.name+... | [
"function",
"BindToEventDecorator",
"(",
"_event",
",",
"_target",
",",
"_listenIn",
",",
"_removeIn",
")",
"{",
"return",
"function",
"(",
"propertyName",
",",
"func",
")",
"{",
"const",
"scope",
"=",
"this",
";",
"const",
"event",
"=",
"_event",
"||",
"p... | Implements the automatic binding and unbinding of the chosen function. Wraps its listenIn and removeIn functions to add and remove the event listener at the correct times. | [
"Implements",
"the",
"automatic",
"binding",
"and",
"unbinding",
"of",
"the",
"chosen",
"function",
".",
"Wraps",
"its",
"listenIn",
"and",
"removeIn",
"functions",
"to",
"add",
"and",
"remove",
"the",
"event",
"listener",
"at",
"the",
"correct",
"times",
"."
... | ddd2a11041ab6e5551fa21c861b8a6c4af5a26ab | https://github.com/Adam4lexander/aframe-event-decorators/blob/ddd2a11041ab6e5551fa21c861b8a6c4af5a26ab/event-binder.js#L41-L74 | train |
spacemaus/postvox | vox-common/authentication.js | checkStanza | function checkStanza(hubClient, stanza, fields, author, opt_sigValue) {
var sig = opt_sigValue === undefined ? stanza.sig : opt_sigValue;
if (!sig) {
throw new errors.AuthenticationError('No `sig` field in stanza');
}
if (!stanza.updatedAt || typeof(stanza.updatedAt) != 'number') {
throw new errors.Auth... | javascript | function checkStanza(hubClient, stanza, fields, author, opt_sigValue) {
var sig = opt_sigValue === undefined ? stanza.sig : opt_sigValue;
if (!sig) {
throw new errors.AuthenticationError('No `sig` field in stanza');
}
if (!stanza.updatedAt || typeof(stanza.updatedAt) != 'number') {
throw new errors.Auth... | [
"function",
"checkStanza",
"(",
"hubClient",
",",
"stanza",
",",
"fields",
",",
"author",
",",
"opt_sigValue",
")",
"{",
"var",
"sig",
"=",
"opt_sigValue",
"===",
"undefined",
"?",
"stanza",
".",
"sig",
":",
"opt_sigValue",
";",
"if",
"(",
"!",
"sig",
")... | Verifies that the stanza's signature matches the author's public key on file
at the Hub.
May fetch updated user profile information from the Hub.
@param {HubClient} hubClient A HubClient instance used to fetch user profile
information.
@param {Object} stanza The stanza to check
@param {String} stanza.sig The stanza's... | [
"Verifies",
"that",
"the",
"stanza",
"s",
"signature",
"matches",
"the",
"author",
"s",
"public",
"key",
"on",
"file",
"at",
"the",
"Hub",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-common/authentication.js#L181-L229 | train |
spacemaus/postvox | vox-common/authentication.js | signStanza | function signStanza(stanza, fields, privkey) {
stanza.sig = generateStanzaSig(stanza, fields, privkey);
return stanza;
} | javascript | function signStanza(stanza, fields, privkey) {
stanza.sig = generateStanzaSig(stanza, fields, privkey);
return stanza;
} | [
"function",
"signStanza",
"(",
"stanza",
",",
"fields",
",",
"privkey",
")",
"{",
"stanza",
".",
"sig",
"=",
"generateStanzaSig",
"(",
"stanza",
",",
"fields",
",",
"privkey",
")",
";",
"return",
"stanza",
";",
"}"
] | Signs a stanza with the given private key.
@param {Object} stanza The object to sign.
@param {Array<String>} fields The name of the fields to include in the
signature.
@param {String} privkey The private key to use to sign, in PEM format.
@returns {Object} The given stanza, with `sig` set to the signature. | [
"Signs",
"a",
"stanza",
"with",
"the",
"given",
"private",
"key",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-common/authentication.js#L241-L244 | train |
vphantom/docblox2md | docblox2md.js | srcToMarkdown | function srcToMarkdown(src, level, threshold) {
var blocks = srcToBlocks(src);
return blocksToMarkdown(blocks, level, threshold);
} | javascript | function srcToMarkdown(src, level, threshold) {
var blocks = srcToBlocks(src);
return blocksToMarkdown(blocks, level, threshold);
} | [
"function",
"srcToMarkdown",
"(",
"src",
",",
"level",
",",
"threshold",
")",
"{",
"var",
"blocks",
"=",
"srcToBlocks",
"(",
"src",
")",
";",
"return",
"blocksToMarkdown",
"(",
"blocks",
",",
"level",
",",
"threshold",
")",
";",
"}"
] | Generate Markdown from doc-commented source
Visibility threshold can be:
0: public only
1: public and protected
2: public, protected and private
@param {String} src Source code
@param {Number} level Header starting level (1-6)
@param {Number} threshold Visibility threshold
@return {String} Markdown text | [
"Generate",
"Markdown",
"from",
"doc",
"-",
"commented",
"source"
] | a3524e7188546dc93f93c3e5b9b822f73cec8267 | https://github.com/vphantom/docblox2md/blob/a3524e7188546dc93f93c3e5b9b822f73cec8267/docblox2md.js#L369-L373 | train |
vphantom/docblox2md | docblox2md.js | loadFile | function loadFile(filename, level, threshold) {
var out = [];
var file;
out.push('<!-- BEGIN DOC-COMMENT H' + level + ' ' + filename + ' -->\n');
try {
file = fs.readFileSync(filename, {encoding: 'utf-8'});
out.push(srcToMarkdown(file, level, threshold));
} catch (e) {
// I don't see how we can ... | javascript | function loadFile(filename, level, threshold) {
var out = [];
var file;
out.push('<!-- BEGIN DOC-COMMENT H' + level + ' ' + filename + ' -->\n');
try {
file = fs.readFileSync(filename, {encoding: 'utf-8'});
out.push(srcToMarkdown(file, level, threshold));
} catch (e) {
// I don't see how we can ... | [
"function",
"loadFile",
"(",
"filename",
",",
"level",
",",
"threshold",
")",
"{",
"var",
"out",
"=",
"[",
"]",
";",
"var",
"file",
";",
"out",
".",
"push",
"(",
"'<!-- BEGIN DOC-COMMENT H'",
"+",
"level",
"+",
"' '",
"+",
"filename",
"+",
"' -->\\n'",
... | Load file from disk and process to Markdown
Visibility threshold can be:
0: public only
1: public and protected
2: public, protected and private
@param {String} filename File name
@param {Number} level Header starting level (1-6)
@param {Number} threshold Visibility threshold
@return {String} Markdown text wit... | [
"Load",
"file",
"from",
"disk",
"and",
"process",
"to",
"Markdown"
] | a3524e7188546dc93f93c3e5b9b822f73cec8267 | https://github.com/vphantom/docblox2md/blob/a3524e7188546dc93f93c3e5b9b822f73cec8267/docblox2md.js#L390-L406 | train |
vphantom/docblox2md | docblox2md.js | filterDocument | function filterDocument(doc, threshold) {
var sections = doc.split(re.mdSplit);
var out = [];
var i = 0;
for (i = 0; i < sections.length; i++) {
// 1. Raw input to preserve
out.push(sections[i]);
// Iterate
i++;
if (i >= sections.length) {
break;
}
// 2. Header level
let... | javascript | function filterDocument(doc, threshold) {
var sections = doc.split(re.mdSplit);
var out = [];
var i = 0;
for (i = 0; i < sections.length; i++) {
// 1. Raw input to preserve
out.push(sections[i]);
// Iterate
i++;
if (i >= sections.length) {
break;
}
// 2. Header level
let... | [
"function",
"filterDocument",
"(",
"doc",
",",
"threshold",
")",
"{",
"var",
"sections",
"=",
"doc",
".",
"split",
"(",
"re",
".",
"mdSplit",
")",
";",
"var",
"out",
"=",
"[",
"]",
";",
"var",
"i",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",... | Filter Markdown document for our placeholders
Visibility threshold can be:
0: public only
1: public and protected
2: public, protected and private
@param {String} doc Input document
@param {Number} threshold Visibility threshold
@return {String} Updated document | [
"Filter",
"Markdown",
"document",
"for",
"our",
"placeholders"
] | a3524e7188546dc93f93c3e5b9b822f73cec8267 | https://github.com/vphantom/docblox2md/blob/a3524e7188546dc93f93c3e5b9b822f73cec8267/docblox2md.js#L422-L455 | train |
xiaoyann/smart-ui | src/index.js | install | function install(Vue) {
for (const name in components) {
const component = components[name].component || components[name]
Vue.component(name, component)
}
Vue.prototype.$actionSheet = $actionSheet
Vue.prototype.$loading = $loading
Vue.prototype.$toast = $toast
Vue.prototype.$dialog = $dialog
} | javascript | function install(Vue) {
for (const name in components) {
const component = components[name].component || components[name]
Vue.component(name, component)
}
Vue.prototype.$actionSheet = $actionSheet
Vue.prototype.$loading = $loading
Vue.prototype.$toast = $toast
Vue.prototype.$dialog = $dialog
} | [
"function",
"install",
"(",
"Vue",
")",
"{",
"for",
"(",
"const",
"name",
"in",
"components",
")",
"{",
"const",
"component",
"=",
"components",
"[",
"name",
"]",
".",
"component",
"||",
"components",
"[",
"name",
"]",
"Vue",
".",
"component",
"(",
"na... | register globally all components | [
"register",
"globally",
"all",
"components"
] | f5e1d70717eec062434d4cfe2998329880d2ecc4 | https://github.com/xiaoyann/smart-ui/blob/f5e1d70717eec062434d4cfe2998329880d2ecc4/src/index.js#L45-L54 | train |
xiaoyann/smart-ui | src/index.js | config | function config(name) {
const args = [].slice.call(arguments, 1)
const modules = {
ActionSheet: $actionSheet,
Loading: $loading,
Toast: $toast,
Dialog: $dialog
}
const module = components[name] || modules[name]
if (typeof module.config === 'function') {
module.config.apply(null, args)
}
... | javascript | function config(name) {
const args = [].slice.call(arguments, 1)
const modules = {
ActionSheet: $actionSheet,
Loading: $loading,
Toast: $toast,
Dialog: $dialog
}
const module = components[name] || modules[name]
if (typeof module.config === 'function') {
module.config.apply(null, args)
}
... | [
"function",
"config",
"(",
"name",
")",
"{",
"const",
"args",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
"const",
"modules",
"=",
"{",
"ActionSheet",
":",
"$actionSheet",
",",
"Loading",
":",
"$loading",
",",
"Toast",
... | Components can export a function named config to customize some options for user | [
"Components",
"can",
"export",
"a",
"function",
"named",
"config",
"to",
"customize",
"some",
"options",
"for",
"user"
] | f5e1d70717eec062434d4cfe2998329880d2ecc4 | https://github.com/xiaoyann/smart-ui/blob/f5e1d70717eec062434d4cfe2998329880d2ecc4/src/index.js#L58-L73 | train |
AndiDittrich/Node.mysql-magic | lib/fetch-row.js | fetchRow | async function fetchRow(connection, query, params){
// execute query
const [result] = await _query(connection, query, params);
// entry found ?
if (result.length >= 1){
// extract data
return result[0];
}else{
return null;
}
} | javascript | async function fetchRow(connection, query, params){
// execute query
const [result] = await _query(connection, query, params);
// entry found ?
if (result.length >= 1){
// extract data
return result[0];
}else{
return null;
}
} | [
"async",
"function",
"fetchRow",
"(",
"connection",
",",
"query",
",",
"params",
")",
"{",
"// execute query",
"const",
"[",
"result",
"]",
"=",
"await",
"_query",
"(",
"connection",
",",
"query",
",",
"params",
")",
";",
"// entry found ?",
"if",
"(",
"re... | fetch a single row and handle errors | [
"fetch",
"a",
"single",
"row",
"and",
"handle",
"errors"
] | f9783ac93f4a5744407781d7875ae68cad58cc48 | https://github.com/AndiDittrich/Node.mysql-magic/blob/f9783ac93f4a5744407781d7875ae68cad58cc48/lib/fetch-row.js#L4-L16 | train |
thlorenz/node-traceur | src/semantics/symbols/Project.js | getStandardModule | function getStandardModule(url) {
if (!(url in standardModuleCache)) {
var symbol = new ModuleSymbol(null, null, null, url);
var moduleInstance = traceur.runtime.modules[url];
Object.keys(moduleInstance).forEach((name) => {
symbol.addExport(name, new ExportSymbol(null, name, null));
});
stan... | javascript | function getStandardModule(url) {
if (!(url in standardModuleCache)) {
var symbol = new ModuleSymbol(null, null, null, url);
var moduleInstance = traceur.runtime.modules[url];
Object.keys(moduleInstance).forEach((name) => {
symbol.addExport(name, new ExportSymbol(null, name, null));
});
stan... | [
"function",
"getStandardModule",
"(",
"url",
")",
"{",
"if",
"(",
"!",
"(",
"url",
"in",
"standardModuleCache",
")",
")",
"{",
"var",
"symbol",
"=",
"new",
"ModuleSymbol",
"(",
"null",
",",
"null",
",",
"null",
",",
"url",
")",
";",
"var",
"moduleInsta... | Gets a ModuleSymbol for a standard module. We cache the Symbol so that
future accesses to this returns the same symbol.
@param {string} url
@return {ModuleSymbol} | [
"Gets",
"a",
"ModuleSymbol",
"for",
"a",
"standard",
"module",
".",
"We",
"cache",
"the",
"Symbol",
"so",
"that",
"future",
"accesses",
"to",
"this",
"returns",
"the",
"same",
"symbol",
"."
] | 79a21ad03831ba36df504988b05022404ad8f9c3 | https://github.com/thlorenz/node-traceur/blob/79a21ad03831ba36df504988b05022404ad8f9c3/src/semantics/symbols/Project.js#L43-L53 | train |
kaelzhang/node-semver-stable | index.js | desc | function desc (array) {
// Simply clone
array = [].concat(array);
// Ordered by version DESC
array.sort(semver.rcompare);
return array;
} | javascript | function desc (array) {
// Simply clone
array = [].concat(array);
// Ordered by version DESC
array.sort(semver.rcompare);
return array;
} | [
"function",
"desc",
"(",
"array",
")",
"{",
"// Simply clone",
"array",
"=",
"[",
"]",
".",
"concat",
"(",
"array",
")",
";",
"// Ordered by version DESC ",
"array",
".",
"sort",
"(",
"semver",
".",
"rcompare",
")",
";",
"return",
"array",
";",
"}"
] | Sort by DESC | [
"Sort",
"by",
"DESC"
] | 34dd29842409295d49889d45871bec55a992b7f6 | https://github.com/kaelzhang/node-semver-stable/blob/34dd29842409295d49889d45871bec55a992b7f6/index.js#L38-L44 | train |
spacemaus/postvox | vox-common/level-index.js | scan | function scan(leveldb, options) {
return new P(function(resolve, reject) {
var datas = [];
var resolved = false;
function fin() {
if (resolved) {
return;
}
resolve(P.all(datas));
resolved = true;
}
leveldb.createReadStream(options)
.on('data', function(data) {... | javascript | function scan(leveldb, options) {
return new P(function(resolve, reject) {
var datas = [];
var resolved = false;
function fin() {
if (resolved) {
return;
}
resolve(P.all(datas));
resolved = true;
}
leveldb.createReadStream(options)
.on('data', function(data) {... | [
"function",
"scan",
"(",
"leveldb",
",",
"options",
")",
"{",
"return",
"new",
"P",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"datas",
"=",
"[",
"]",
";",
"var",
"resolved",
"=",
"false",
";",
"function",
"fin",
"(",
")",
"{"... | Starts a LevelDB scan and returns a Promise for the list of results.
@param {LevelDB} leveldb The DB to scan.
@param {Object} options An options object passed verbatim to
leveldb.createReadStream().
@return {Promise<Object[]>} The scan results. | [
"Starts",
"a",
"LevelDB",
"scan",
"and",
"returns",
"a",
"Promise",
"for",
"the",
"list",
"of",
"results",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-common/level-index.js#L177-L198 | train |
spacemaus/postvox | vox-common/level-index.js | scanIndex | function scanIndex(leveldb, options) {
return new P(function(resolve, reject) {
var datas = [];
var resolved = false;
function fin() {
if (resolved) {
return;
}
resolve(P.all(datas));
resolved = true;
}
leveldb.createKeyStream(options)
.on('data', function(key... | javascript | function scanIndex(leveldb, options) {
return new P(function(resolve, reject) {
var datas = [];
var resolved = false;
function fin() {
if (resolved) {
return;
}
resolve(P.all(datas));
resolved = true;
}
leveldb.createKeyStream(options)
.on('data', function(key... | [
"function",
"scanIndex",
"(",
"leveldb",
",",
"options",
")",
"{",
"return",
"new",
"P",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"datas",
"=",
"[",
"]",
";",
"var",
"resolved",
"=",
"false",
";",
"function",
"fin",
"(",
")",
... | Starts a LevelDB index scan and returns a Promise for the list of results.
@param {LevelDB} leveldb The DB to scan.
@param {Object} options An options object passed verbatim to
leveldb.createKeyStream().
@return {Promise<Object[]>} The scan results. | [
"Starts",
"a",
"LevelDB",
"index",
"scan",
"and",
"returns",
"a",
"Promise",
"for",
"the",
"list",
"of",
"results",
"."
] | de98e5ed37edaee1b1edadf93e15eb8f8d21f457 | https://github.com/spacemaus/postvox/blob/de98e5ed37edaee1b1edadf93e15eb8f8d21f457/vox-common/level-index.js#L209-L232 | train |
SilentCicero/wafr | src/index.js | wafr | function wafr(options, callback) {
const contractsPath = options.path;
const optimizeCompiler = options.optimize;
const sourcesExclude = options.exclude;
const sourcesInclude = options.include;
const focusContract = options.focus;
const reportLogs = {
contracts: {},
status: 'success',
failure: 0... | javascript | function wafr(options, callback) {
const contractsPath = options.path;
const optimizeCompiler = options.optimize;
const sourcesExclude = options.exclude;
const sourcesInclude = options.include;
const focusContract = options.focus;
const reportLogs = {
contracts: {},
status: 'success',
failure: 0... | [
"function",
"wafr",
"(",
"options",
",",
"callback",
")",
"{",
"const",
"contractsPath",
"=",
"options",
".",
"path",
";",
"const",
"optimizeCompiler",
"=",
"options",
".",
"optimize",
";",
"const",
"sourcesExclude",
"=",
"options",
".",
"exclude",
";",
"con... | run the main solTest export | [
"run",
"the",
"main",
"solTest",
"export"
] | 2c7483feec5df346d8903cab5badc17143c3876d | https://github.com/SilentCicero/wafr/blob/2c7483feec5df346d8903cab5badc17143c3876d/src/index.js#L530-L621 | train |
Wiredcraft/handle-http-error | lib/parseError.js | parseError | function parseError(res, body) {
// Res is optional.
if (body == null) {
body = res;
}
// Status code is required.
const status = parseError.findErrorCode(sliced(arguments));
if (!status) {
return false;
}
// Body can have an error-like object, in which case the attributes will be used.
const ... | javascript | function parseError(res, body) {
// Res is optional.
if (body == null) {
body = res;
}
// Status code is required.
const status = parseError.findErrorCode(sliced(arguments));
if (!status) {
return false;
}
// Body can have an error-like object, in which case the attributes will be used.
const ... | [
"function",
"parseError",
"(",
"res",
",",
"body",
")",
"{",
"// Res is optional.",
"if",
"(",
"body",
"==",
"null",
")",
"{",
"body",
"=",
"res",
";",
"}",
"// Status code is required.",
"const",
"status",
"=",
"parseError",
".",
"findErrorCode",
"(",
"slic... | See if the response has a status error code, and if the error message has an error-like object. | [
"See",
"if",
"the",
"response",
"has",
"a",
"status",
"error",
"code",
"and",
"if",
"the",
"error",
"message",
"has",
"an",
"error",
"-",
"like",
"object",
"."
] | 2054c1ade9f5e4b11fd64c432317c815cb97063a | https://github.com/Wiredcraft/handle-http-error/blob/2054c1ade9f5e4b11fd64c432317c815cb97063a/lib/parseError.js#L18-L34 | train |
teabyii/qa | lib/tty.js | function (len) {
_.isNumber(len) || (len = 1)
while (len--) {
readline.moveCursor(this.rl.output, -cliWidth(), 0)
readline.clearLine(this.rl.output, 0)
if (len) {
readline.moveCursor(this.rl.output, 0, -1)
}
}
return this
} | javascript | function (len) {
_.isNumber(len) || (len = 1)
while (len--) {
readline.moveCursor(this.rl.output, -cliWidth(), 0)
readline.clearLine(this.rl.output, 0)
if (len) {
readline.moveCursor(this.rl.output, 0, -1)
}
}
return this
} | [
"function",
"(",
"len",
")",
"{",
"_",
".",
"isNumber",
"(",
"len",
")",
"||",
"(",
"len",
"=",
"1",
")",
"while",
"(",
"len",
"--",
")",
"{",
"readline",
".",
"moveCursor",
"(",
"this",
".",
"rl",
".",
"output",
",",
"-",
"cliWidth",
"(",
")",... | Remove the line.
@params {number} len Lines to remove.
@returns {Object} Self. | [
"Remove",
"the",
"line",
"."
] | 9224180dcb9e6b57c021f83b259316e84ebc573e | https://github.com/teabyii/qa/blob/9224180dcb9e6b57c021f83b259316e84ebc573e/lib/tty.js#L17-L28 | train | |
teabyii/qa | lib/tty.js | function (x) {
_.isNumber(x) || (x = 1)
readline.moveCursor(this.rl.output, 0, -x)
return this
} | javascript | function (x) {
_.isNumber(x) || (x = 1)
readline.moveCursor(this.rl.output, 0, -x)
return this
} | [
"function",
"(",
"x",
")",
"{",
"_",
".",
"isNumber",
"(",
"x",
")",
"||",
"(",
"x",
"=",
"1",
")",
"readline",
".",
"moveCursor",
"(",
"this",
".",
"rl",
".",
"output",
",",
"0",
",",
"-",
"x",
")",
"return",
"this",
"}"
] | Move cursor up.
@param {number} x How far to go up (default to 1).
@return {Object} Self. | [
"Move",
"cursor",
"up",
"."
] | 9224180dcb9e6b57c021f83b259316e84ebc573e | https://github.com/teabyii/qa/blob/9224180dcb9e6b57c021f83b259316e84ebc573e/lib/tty.js#L64-L68 | train | |
teabyii/qa | lib/tty.js | function () {
if (!this.cursorPos) {
return this
}
var line = this.rl._prompt + this.rl.line
readline.moveCursor(this.rl.output, -line.length, 0)
readline.moveCursor(this.rl.output, this.cursorPos.cols, 0)
this.cursorPos = null
return this
} | javascript | function () {
if (!this.cursorPos) {
return this
}
var line = this.rl._prompt + this.rl.line
readline.moveCursor(this.rl.output, -line.length, 0)
readline.moveCursor(this.rl.output, this.cursorPos.cols, 0)
this.cursorPos = null
return this
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"cursorPos",
")",
"{",
"return",
"this",
"}",
"var",
"line",
"=",
"this",
".",
"rl",
".",
"_prompt",
"+",
"this",
".",
"rl",
".",
"line",
"readline",
".",
"moveCursor",
"(",
"this",
".",
"rl... | Restore the cursor position to where it has been previously stored.
@return {Object} Self. | [
"Restore",
"the",
"cursor",
"position",
"to",
"where",
"it",
"has",
"been",
"previously",
"stored",
"."
] | 9224180dcb9e6b57c021f83b259316e84ebc573e | https://github.com/teabyii/qa/blob/9224180dcb9e6b57c021f83b259316e84ebc573e/lib/tty.js#L142-L151 | train | |
cahilfoley/snowfall | lib/utils.js | random | function random(min, max) {
var randomNumber = Math.random() * (max - min + 1) + min;
if (!Number.isInteger(min) || !Number.isInteger(max)) {
return randomNumber;
} else {
return Math.floor(randomNumber);
}
} | javascript | function random(min, max) {
var randomNumber = Math.random() * (max - min + 1) + min;
if (!Number.isInteger(min) || !Number.isInteger(max)) {
return randomNumber;
} else {
return Math.floor(randomNumber);
}
} | [
"function",
"random",
"(",
"min",
",",
"max",
")",
"{",
"var",
"randomNumber",
"=",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"max",
"-",
"min",
"+",
"1",
")",
"+",
"min",
";",
"if",
"(",
"!",
"Number",
".",
"isInteger",
"(",
"min",
")",
"||",... | Enhanced random function, selects a random value between a minimum and maximum. If the values provided are both
integers then the number returned will be an integer, otherwise the return number will be a decimal.
@param min The minimum value
@param max The maximum value | [
"Enhanced",
"random",
"function",
"selects",
"a",
"random",
"value",
"between",
"a",
"minimum",
"and",
"maximum",
".",
"If",
"the",
"values",
"provided",
"are",
"both",
"integers",
"then",
"the",
"number",
"returned",
"will",
"be",
"an",
"integer",
"otherwise"... | d16b7e913ffb9999521fbfc4054e7b6154712711 | https://github.com/cahilfoley/snowfall/blob/d16b7e913ffb9999521fbfc4054e7b6154712711/lib/utils.js#L15-L23 | train |
mjhasbach/MS-Task | lib/ms-task.js | pidOf | function pidOf( procName, callback ){
if ( isString( procName )){
var pids = [];
procStat( procName, function( err, processes ){
processes.object.forEach( function( proc ){
pids.push( proc.pid )
});
callback( err, pids )
})
} else cal... | javascript | function pidOf( procName, callback ){
if ( isString( procName )){
var pids = [];
procStat( procName, function( err, processes ){
processes.object.forEach( function( proc ){
pids.push( proc.pid )
});
callback( err, pids )
})
} else cal... | [
"function",
"pidOf",
"(",
"procName",
",",
"callback",
")",
"{",
"if",
"(",
"isString",
"(",
"procName",
")",
")",
"{",
"var",
"pids",
"=",
"[",
"]",
";",
"procStat",
"(",
"procName",
",",
"function",
"(",
"err",
",",
"processes",
")",
"{",
"processe... | Search for one or more PIDs that match a give process name | [
"Search",
"for",
"one",
"or",
"more",
"PIDs",
"that",
"match",
"a",
"give",
"process",
"name"
] | f91fe301024a31d02a4c56f3886cc783fc5eda30 | https://github.com/mjhasbach/MS-Task/blob/f91fe301024a31d02a4c56f3886cc783fc5eda30/lib/ms-task.js#L17-L29 | train |
mjhasbach/MS-Task | lib/ms-task.js | nameOf | function nameOf( pid, callback ){
if( isNumber( pid )){
procStat( pid, function( err, proc ){
callback( err, proc.object[ 0 ].name );
})
} else callback( new Error( 'A non-numeric PID was supplied' ), null )
} | javascript | function nameOf( pid, callback ){
if( isNumber( pid )){
procStat( pid, function( err, proc ){
callback( err, proc.object[ 0 ].name );
})
} else callback( new Error( 'A non-numeric PID was supplied' ), null )
} | [
"function",
"nameOf",
"(",
"pid",
",",
"callback",
")",
"{",
"if",
"(",
"isNumber",
"(",
"pid",
")",
")",
"{",
"procStat",
"(",
"pid",
",",
"function",
"(",
"err",
",",
"proc",
")",
"{",
"callback",
"(",
"err",
",",
"proc",
".",
"object",
"[",
"0... | Search for the process name that corresponds with the supplied PID | [
"Search",
"for",
"the",
"process",
"name",
"that",
"corresponds",
"with",
"the",
"supplied",
"PID"
] | f91fe301024a31d02a4c56f3886cc783fc5eda30 | https://github.com/mjhasbach/MS-Task/blob/f91fe301024a31d02a4c56f3886cc783fc5eda30/lib/ms-task.js#L32-L38 | train |
mjhasbach/MS-Task | lib/ms-task.js | procStat | function procStat( proc, callback ){
var type = isNumber( proc ) ? 'PID' : 'IMAGENAME',
arg = '/fi \"' + type + ' eq ' + proc + '\" /fo CSV',
row = null,
processes = {
array: [],
object: []
};
taskList( arg, function( err, stdout ){
csv.parse( std... | javascript | function procStat( proc, callback ){
var type = isNumber( proc ) ? 'PID' : 'IMAGENAME',
arg = '/fi \"' + type + ' eq ' + proc + '\" /fo CSV',
row = null,
processes = {
array: [],
object: []
};
taskList( arg, function( err, stdout ){
csv.parse( std... | [
"function",
"procStat",
"(",
"proc",
",",
"callback",
")",
"{",
"var",
"type",
"=",
"isNumber",
"(",
"proc",
")",
"?",
"'PID'",
":",
"'IMAGENAME'",
",",
"arg",
"=",
"'/fi \\\"'",
"+",
"type",
"+",
"' eq '",
"+",
"proc",
"+",
"'\\\" /fo CSV'",
",",
"row... | Search for a given process name or PID | [
"Search",
"for",
"a",
"given",
"process",
"name",
"or",
"PID"
] | f91fe301024a31d02a4c56f3886cc783fc5eda30 | https://github.com/mjhasbach/MS-Task/blob/f91fe301024a31d02a4c56f3886cc783fc5eda30/lib/ms-task.js#L41-L73 | train |
mjhasbach/MS-Task | lib/ms-task.js | kill | function kill( proc, callback ){
var arg = isNumber( proc ) ? '/F /PID ' + proc : '/F /IM ' + proc;
if ( isNumber( proc ) || isString( proc )){
exec( taskKillPath + arg, function( err ){
if( callback ) callback( err )
})
} else {
callback( new Error( 'The first kill() ar... | javascript | function kill( proc, callback ){
var arg = isNumber( proc ) ? '/F /PID ' + proc : '/F /IM ' + proc;
if ( isNumber( proc ) || isString( proc )){
exec( taskKillPath + arg, function( err ){
if( callback ) callback( err )
})
} else {
callback( new Error( 'The first kill() ar... | [
"function",
"kill",
"(",
"proc",
",",
"callback",
")",
"{",
"var",
"arg",
"=",
"isNumber",
"(",
"proc",
")",
"?",
"'/F /PID '",
"+",
"proc",
":",
"'/F /IM '",
"+",
"proc",
";",
"if",
"(",
"isNumber",
"(",
"proc",
")",
"||",
"isString",
"(",
"proc",
... | Kill a given process name or PID | [
"Kill",
"a",
"given",
"process",
"name",
"or",
"PID"
] | f91fe301024a31d02a4c56f3886cc783fc5eda30 | https://github.com/mjhasbach/MS-Task/blob/f91fe301024a31d02a4c56f3886cc783fc5eda30/lib/ms-task.js#L76-L86 | train |
Everyplay/sear | lib/stringutils.js | escapeStringForJavascript | function escapeStringForJavascript(content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
.replace(/[\u2028]/g, "\\u2028")
.replace(/[\u2029]/g, "\\u2029");
} | javascript | function escapeStringForJavascript(content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
.replace(/[\u2028]/g, "\\u2028")
.replace(/[\u2029]/g, "\\u2029");
} | [
"function",
"escapeStringForJavascript",
"(",
"content",
")",
"{",
"return",
"content",
".",
"replace",
"(",
"/",
"(['\\\\])",
"/",
"g",
",",
"'\\\\$1'",
")",
".",
"replace",
"(",
"/",
"[\\f]",
"/",
"g",
",",
"\"\\\\f\"",
")",
".",
"replace",
"(",
"/",
... | Escape string so it can be inlined in javascript
@param content {String} input to be escaped
@return {String} escaped string | [
"Escape",
"string",
"so",
"it",
"can",
"be",
"inlined",
"in",
"javascript"
] | b3ab97e8452b4df7caa72252559144812fbfef1c | https://github.com/Everyplay/sear/blob/b3ab97e8452b4df7caa72252559144812fbfef1c/lib/stringutils.js#L7-L16 | train |
windmaomao/ng-admin-restify | src/provider.js | function(nga, options) {
// create an admin application
var app = ngAdmin.create(nga, options);
// app.dashboard(nga.dashboard().template('<dashboard-page></dashboard-page>'));
// create custom header
if (options.auth) {
app.header('<header-partial></header-part... | javascript | function(nga, options) {
// create an admin application
var app = ngAdmin.create(nga, options);
// app.dashboard(nga.dashboard().template('<dashboard-page></dashboard-page>'));
// create custom header
if (options.auth) {
app.header('<header-partial></header-part... | [
"function",
"(",
"nga",
",",
"options",
")",
"{",
"// create an admin application\r",
"var",
"app",
"=",
"ngAdmin",
".",
"create",
"(",
"nga",
",",
"options",
")",
";",
"// app.dashboard(nga.dashboard().template('<dashboard-page></dashboard-page>'));\r",
"// create custom h... | Given ng-admin provider and options Return an application instance | [
"Given",
"ng",
"-",
"admin",
"provider",
"and",
"options",
"Return",
"an",
"application",
"instance"
] | d86d8c12eb07e1b23def2f5de0832aa357c2a731 | https://github.com/windmaomao/ng-admin-restify/blob/d86d8c12eb07e1b23def2f5de0832aa357c2a731/src/provider.js#L18-L30 | train | |
NumminorihSF/bramqp-wrapper | domain/channel.js | Channel | function Channel(client, id){
EE.call(this);
this.client = client;
this.id = id;
this.opened = false;
this.confirmMode = false;
var work = (id, method, err) => {
this.opened = false;
var error = new RabbitClientError(err);
this.emit('close', error, this.id);
if (error) {
this.emit('err... | javascript | function Channel(client, id){
EE.call(this);
this.client = client;
this.id = id;
this.opened = false;
this.confirmMode = false;
var work = (id, method, err) => {
this.opened = false;
var error = new RabbitClientError(err);
this.emit('close', error, this.id);
if (error) {
this.emit('err... | [
"function",
"Channel",
"(",
"client",
",",
"id",
")",
"{",
"EE",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"opened",
"=",
"false",
";",
"this",
".",
"confirmMode... | Work with channels.
The channel class provides methods for a client to establish a channel to a server
and for both peers to operate the channel thereafter.
@class Channel
@extends EventEmitter
@param {BRAMQPClient} client Client object that returns from bramqp#openAMQPCommunication() method.
@param {Number} id Chann... | [
"Work",
"with",
"channels",
"."
] | 3e2bd769a2828f7592eba79556c9ef1491177781 | https://github.com/NumminorihSF/bramqp-wrapper/blob/3e2bd769a2828f7592eba79556c9ef1491177781/domain/channel.js#L18-L48 | train |
linyngfly/omelo | lib/common/service/channelService.js | function(uid, sid, group) {
if(!uid || !sid || !group) {
return false;
}
for(let i=0, l=group.length; i<l; i++) {
if(group[i] === uid) {
group.splice(i, 1);
return true;
}
}
return false;
} | javascript | function(uid, sid, group) {
if(!uid || !sid || !group) {
return false;
}
for(let i=0, l=group.length; i<l; i++) {
if(group[i] === uid) {
group.splice(i, 1);
return true;
}
}
return false;
} | [
"function",
"(",
"uid",
",",
"sid",
",",
"group",
")",
"{",
"if",
"(",
"!",
"uid",
"||",
"!",
"sid",
"||",
"!",
"group",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"l",
"=",
"group",
".",
"length",
";",
"i... | delete element from array | [
"delete",
"element",
"from",
"array"
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/common/service/channelService.js#L359-L372 | train | |
linyngfly/omelo | lib/common/service/channelService.js | function(channelService, route, msg, groups, opts, cb) {
let app = channelService.app;
let namespace = 'sys';
let service = 'channelRemote';
let method = 'pushMessage';
let count = utils.size(groups);
let successFlag = false;
let failIds = [];
logger.debug('[%s] channelService sendMessageByGroup route:... | javascript | function(channelService, route, msg, groups, opts, cb) {
let app = channelService.app;
let namespace = 'sys';
let service = 'channelRemote';
let method = 'pushMessage';
let count = utils.size(groups);
let successFlag = false;
let failIds = [];
logger.debug('[%s] channelService sendMessageByGroup route:... | [
"function",
"(",
"channelService",
",",
"route",
",",
"msg",
",",
"groups",
",",
"opts",
",",
"cb",
")",
"{",
"let",
"app",
"=",
"channelService",
".",
"app",
";",
"let",
"namespace",
"=",
"'sys'",
";",
"let",
"service",
"=",
"'channelRemote'",
";",
"l... | push message by group
@param route {String} route route message
@param msg {Object} message that would be sent to client
@param groups {Object} grouped uids, , key: sid, value: [uid]
@param opts {Object} push options
@param cb {Function} cb(err)
@api private | [
"push",
"message",
"by",
"group"
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/common/service/channelService.js#L385-L449 | train | |
yeptlabs/wns | src/core/base/wnConsole.js | function () {
process.stdin.resume();
process.stdin.setEncoding('utf8');
_execCtx = [self];
process.stdin.on('data', function (chunk) {
var ctx = _execCtx[0],
cmd = chunk.substr(0,chunk.length-1);
if (cmd.substr(0,2) == '..')
{
cmd = 'if (_execCtx.length>1) _execCtx.shift(); undefined... | javascript | function () {
process.stdin.resume();
process.stdin.setEncoding('utf8');
_execCtx = [self];
process.stdin.on('data', function (chunk) {
var ctx = _execCtx[0],
cmd = chunk.substr(0,chunk.length-1);
if (cmd.substr(0,2) == '..')
{
cmd = 'if (_execCtx.length>1) _execCtx.shift(); undefined... | [
"function",
"(",
")",
"{",
"process",
".",
"stdin",
".",
"resume",
"(",
")",
";",
"process",
".",
"stdin",
".",
"setEncoding",
"(",
"'utf8'",
")",
";",
"_execCtx",
"=",
"[",
"self",
"]",
";",
"process",
".",
"stdin",
".",
"on",
"(",
"'data'",
",",
... | Listen to the console input | [
"Listen",
"to",
"the",
"console",
"input"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnConsole.js#L77-L100 | train | |
yeptlabs/wns | src/core/base/wnConsole.js | function (serverPath)
{
if (!_.isString(serverPath))
return false;
var _sourcePath = cwd+sourcePath,
relativeSourcePath = path.relative(serverPath,_sourcePath)+'/',
relativeServerPath = path.relative(cwd,serverPath);
self.e.log("[*] Building new wnServer on `"+serverPath+"`");
if (!fs.exist... | javascript | function (serverPath)
{
if (!_.isString(serverPath))
return false;
var _sourcePath = cwd+sourcePath,
relativeSourcePath = path.relative(serverPath,_sourcePath)+'/',
relativeServerPath = path.relative(cwd,serverPath);
self.e.log("[*] Building new wnServer on `"+serverPath+"`");
if (!fs.exist... | [
"function",
"(",
"serverPath",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"serverPath",
")",
")",
"return",
"false",
";",
"var",
"_sourcePath",
"=",
"cwd",
"+",
"sourcePath",
",",
"relativeSourcePath",
"=",
"path",
".",
"relative",
"(",
"server... | Build a new server structure on the given directory
@param string $serverPath directory of the new server
@return boolean successfully builded? | [
"Build",
"a",
"new",
"server",
"structure",
"on",
"the",
"given",
"directory"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnConsole.js#L107-L140 | train | |
yeptlabs/wns | src/core/base/wnConsole.js | function (servers)
{
if (!_.isObject(servers))
return false;
var modules = {};
for (s in servers)
{
var ref=servers[s],
s = 'server-'+s;
modules[s]=ref;
modules[s].modulePath=(modules[s].serverPath || modules[s].modulePath);
modules[s].class='wnServer';
modules[s].autoInit = ... | javascript | function (servers)
{
if (!_.isObject(servers))
return false;
var modules = {};
for (s in servers)
{
var ref=servers[s],
s = 'server-'+s;
modules[s]=ref;
modules[s].modulePath=(modules[s].serverPath || modules[s].modulePath);
modules[s].class='wnServer';
modules[s].autoInit = ... | [
"function",
"(",
"servers",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"servers",
")",
")",
"return",
"false",
";",
"var",
"modules",
"=",
"{",
"}",
";",
"for",
"(",
"s",
"in",
"servers",
")",
"{",
"var",
"ref",
"=",
"servers",
"[",
"... | Set new properties to the respective servers
@param object $servers servers configurations | [
"Set",
"new",
"properties",
"to",
"the",
"respective",
"servers"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnConsole.js#L146-L162 | train | |
yeptlabs/wns | src/core/base/wnConsole.js | function (id)
{
var m = this.getModule('server-'+id, function (server) {
self.e.loadServer(server);
});
_serverModules.push(m);
return m;
} | javascript | function (id)
{
var m = this.getModule('server-'+id, function (server) {
self.e.loadServer(server);
});
_serverModules.push(m);
return m;
} | [
"function",
"(",
"id",
")",
"{",
"var",
"m",
"=",
"this",
".",
"getModule",
"(",
"'server-'",
"+",
"id",
",",
"function",
"(",
"server",
")",
"{",
"self",
".",
"e",
".",
"loadServer",
"(",
"server",
")",
";",
"}",
")",
";",
"_serverModules",
".",
... | Create a new instance of server.
@param STRING $id server ID
@return wnModule the module instance, false if the module is disabled or does not exist. | [
"Create",
"a",
"new",
"instance",
"of",
"server",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnConsole.js#L199-L206 | train | |
yeptlabs/wns | src/core/base/wnConsole.js | function (serverPath,relativeMainPath)
{
if (relativeMainPath)
serverPath = path.relative(cwd,path.resolve(mainPath,serverPath));
var serverConfig = {},
consoleID = this.getServerModules().length+1;
serverConfig[consoleID] = { 'modulePath': serverPath, 'serverID': consoleID };
this.e.log('[*] B... | javascript | function (serverPath,relativeMainPath)
{
if (relativeMainPath)
serverPath = path.relative(cwd,path.resolve(mainPath,serverPath));
var serverConfig = {},
consoleID = this.getServerModules().length+1;
serverConfig[consoleID] = { 'modulePath': serverPath, 'serverID': consoleID };
this.e.log('[*] B... | [
"function",
"(",
"serverPath",
",",
"relativeMainPath",
")",
"{",
"if",
"(",
"relativeMainPath",
")",
"serverPath",
"=",
"path",
".",
"relative",
"(",
"cwd",
",",
"path",
".",
"resolve",
"(",
"mainPath",
",",
"serverPath",
")",
")",
";",
"var",
"serverConf... | Create a new wnServer and puts under the management of this console
@param $serverPath server module path
@param $relativeMainPath boolean relative to mainPath | [
"Create",
"a",
"new",
"wnServer",
"and",
"puts",
"under",
"the",
"management",
"of",
"this",
"console"
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnConsole.js#L239-L262 | train | |
yeptlabs/wns | src/core/base/wnConsole.js | function (id)
{
if (this.hasServer(id))
{
this.e.log('[*] Console active in SERVER#' + id);
this.activeServer = id;
} else {
this.e.log('[*] Console active in NONE');
this.activeServer = -1;
}
} | javascript | function (id)
{
if (this.hasServer(id))
{
this.e.log('[*] Console active in SERVER#' + id);
this.activeServer = id;
} else {
this.e.log('[*] Console active in NONE');
this.activeServer = -1;
}
} | [
"function",
"(",
"id",
")",
"{",
"if",
"(",
"this",
".",
"hasServer",
"(",
"id",
")",
")",
"{",
"this",
".",
"e",
".",
"log",
"(",
"'[*] Console active in SERVER#'",
"+",
"id",
")",
";",
"this",
".",
"activeServer",
"=",
"id",
";",
"}",
"else",
"{"... | Define the server as the active on the console.
@param $server wnServer instance | [
"Define",
"the",
"server",
"as",
"the",
"active",
"on",
"the",
"console",
"."
] | c42602b062dcf6bbffc22e4365bba2cbf363fe2f | https://github.com/yeptlabs/wns/blob/c42602b062dcf6bbffc22e4365bba2cbf363fe2f/src/core/base/wnConsole.js#L268-L278 | train | |
linyngfly/omelo | lib/components/session.js | function(app, opts) {
opts = opts || {};
this.app = app;
this.service = new SessionService(opts);
let getFun = function(m) {
return (function() {
return function() {
return self.service[m].apply(self.service, arguments);
};
})();
};
// proxy the service methods excep... | javascript | function(app, opts) {
opts = opts || {};
this.app = app;
this.service = new SessionService(opts);
let getFun = function(m) {
return (function() {
return function() {
return self.service[m].apply(self.service, arguments);
};
})();
};
// proxy the service methods excep... | [
"function",
"(",
"app",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"app",
"=",
"app",
";",
"this",
".",
"service",
"=",
"new",
"SessionService",
"(",
"opts",
")",
";",
"let",
"getFun",
"=",
"function",
"(",
"m",... | Session component. Manage sessions.
@param {Object} app current application context
@param {Object} opts attach parameters | [
"Session",
"component",
".",
"Manage",
"sessions",
"."
] | fb5f79fa31c69de36bd1c370bad5edfa753ca601 | https://github.com/linyngfly/omelo/blob/fb5f79fa31c69de36bd1c370bad5edfa753ca601/lib/components/session.js#L15-L37 | 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.