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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
psalaets/grid-walk | lib/walker.js | coord | function coord(coordOrColumn, row) {
if (arguments.length == 1) { // copy incoming coord object
return {
column: coordOrColumn.column,
row: coordOrColumn.row
};
} else if (arguments.length == 2) { // create coord object
return {
column: coordOrColumn,
row: row
};
}
} | javascript | function coord(coordOrColumn, row) {
if (arguments.length == 1) { // copy incoming coord object
return {
column: coordOrColumn.column,
row: coordOrColumn.row
};
} else if (arguments.length == 2) { // create coord object
return {
column: coordOrColumn,
row: row
};
}
} | [
"function",
"coord",
"(",
"coordOrColumn",
",",
"row",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"==",
"1",
")",
"{",
"// copy incoming coord object",
"return",
"{",
"column",
":",
"coordOrColumn",
".",
"column",
",",
"row",
":",
"coordOrColumn",
".",... | Creates a coordinate object which is an object with column and row properties.
@param {object|number} coordOrColumn - Coordinate object to copy or column
number to create coordinate object with.
@param {number} [row] - Required when first argument is column number.
@param {object} object with column and row properties | [
"Creates",
"a",
"coordinate",
"object",
"which",
"is",
"an",
"object",
"with",
"column",
"and",
"row",
"properties",
"."
] | 6969e4c9aa0a18289dd3af7da136f7966bcb022d | https://github.com/psalaets/grid-walk/blob/6969e4c9aa0a18289dd3af7da136f7966bcb022d/lib/walker.js#L154-L166 | train |
psalaets/grid-walk | lib/walker.js | calcDirection | function calcDirection(start, end) {
var direction = new Vec2(end);
direction.subtract(start);
direction.normalize();
return direction;
} | javascript | function calcDirection(start, end) {
var direction = new Vec2(end);
direction.subtract(start);
direction.normalize();
return direction;
} | [
"function",
"calcDirection",
"(",
"start",
",",
"end",
")",
"{",
"var",
"direction",
"=",
"new",
"Vec2",
"(",
"end",
")",
";",
"direction",
".",
"subtract",
"(",
"start",
")",
";",
"direction",
".",
"normalize",
"(",
")",
";",
"return",
"direction",
";... | Figure out direction vector of line connecting two points.
@param {Vec2} start
@param {Vec2} end
@return {Vec2} normalized direction vector | [
"Figure",
"out",
"direction",
"vector",
"of",
"line",
"connecting",
"two",
"points",
"."
] | 6969e4c9aa0a18289dd3af7da136f7966bcb022d | https://github.com/psalaets/grid-walk/blob/6969e4c9aa0a18289dd3af7da136f7966bcb022d/lib/walker.js#L193-L198 | train |
acos-server/acos-jsparsons | static/js-parsons/ui-extension/parsons-site-ui.js | function(newAction) {
// ignore init and feedback actions
if (newAction.type === "init" || newAction.type === "feedback") { return; }
var action = parson.whatWeDidPreviously();
// if we have been here before (action not undefined) and more than one line in solution...
if (action && action.output && ... | javascript | function(newAction) {
// ignore init and feedback actions
if (newAction.type === "init" || newAction.type === "feedback") { return; }
var action = parson.whatWeDidPreviously();
// if we have been here before (action not undefined) and more than one line in solution...
if (action && action.output && ... | [
"function",
"(",
"newAction",
")",
"{",
"// ignore init and feedback actions",
"if",
"(",
"newAction",
".",
"type",
"===",
"\"init\"",
"||",
"newAction",
".",
"type",
"===",
"\"feedback\"",
")",
"{",
"return",
";",
"}",
"var",
"action",
"=",
"parson",
".",
"... | callback function called when user action is done on codelines | [
"callback",
"function",
"called",
"when",
"user",
"action",
"is",
"done",
"on",
"codelines"
] | 8c504c261137b0bedf1939a60dd76cfe21d01d7f | https://github.com/acos-server/acos-jsparsons/blob/8c504c261137b0bedf1939a60dd76cfe21d01d7f/static/js-parsons/ui-extension/parsons-site-ui.js#L141-L173 | train | |
acos-server/acos-jsparsons | static/js-parsons/ui-extension/parsons-site-ui.js | function(title, message, callback, options) {
var buttons = {};
buttons[options?(options.buttonTitle || "OK"):"OK"] = function() {
$(this).dialog( "close" );
};
var opts = $.extend(true,
{ buttons: buttons,
modal: true,
ti... | javascript | function(title, message, callback, options) {
var buttons = {};
buttons[options?(options.buttonTitle || "OK"):"OK"] = function() {
$(this).dialog( "close" );
};
var opts = $.extend(true,
{ buttons: buttons,
modal: true,
ti... | [
"function",
"(",
"title",
",",
"message",
",",
"callback",
",",
"options",
")",
"{",
"var",
"buttons",
"=",
"{",
"}",
";",
"buttons",
"[",
"options",
"?",
"(",
"options",
".",
"buttonTitle",
"||",
"\"OK\"",
")",
":",
"\"OK\"",
"]",
"=",
"function",
"... | function used to show a UI message dialog | [
"function",
"used",
"to",
"show",
"a",
"UI",
"message",
"dialog"
] | 8c504c261137b0bedf1939a60dd76cfe21d01d7f | https://github.com/acos-server/acos-jsparsons/blob/8c504c261137b0bedf1939a60dd76cfe21d01d7f/static/js-parsons/ui-extension/parsons-site-ui.js#L176-L200 | train | |
acos-server/acos-jsparsons | static/js-parsons/ui-extension/parsons-site-ui.js | function(duration) {
$("#header").addClass("timer");
$("#timer").show().animate({width: "100%"}, duration, function() {
$("#header").removeClass("timer");
$("#timer").hide().css({width: "0"});
});
} | javascript | function(duration) {
$("#header").addClass("timer");
$("#timer").show().animate({width: "100%"}, duration, function() {
$("#header").removeClass("timer");
$("#timer").hide().css({width: "0"});
});
} | [
"function",
"(",
"duration",
")",
"{",
"$",
"(",
"\"#header\"",
")",
".",
"addClass",
"(",
"\"timer\"",
")",
";",
"$",
"(",
"\"#timer\"",
")",
".",
"show",
"(",
")",
".",
"animate",
"(",
"{",
"width",
":",
"\"100%\"",
"}",
",",
"duration",
",",
"fu... | function to disable feedback for duration milliseconds | [
"function",
"to",
"disable",
"feedback",
"for",
"duration",
"milliseconds"
] | 8c504c261137b0bedf1939a60dd76cfe21d01d7f | https://github.com/acos-server/acos-jsparsons/blob/8c504c261137b0bedf1939a60dd76cfe21d01d7f/static/js-parsons/ui-extension/parsons-site-ui.js#L203-L209 | train | |
acos-server/acos-jsparsons | static/js-parsons/ui-extension/parsons-site-ui.js | function(feedback) {
var isCorrect = ($.isArray(feedback) && feedback.length === 0) ||
('feedback' in feedback && feedback.success);
// correctly solved but collection has more exercises
if (isCorrect && $.isFunction(PARSONS_SETTINGS.next)) {
$("#ul-sortable").sortable("destroy");... | javascript | function(feedback) {
var isCorrect = ($.isArray(feedback) && feedback.length === 0) ||
('feedback' in feedback && feedback.success);
// correctly solved but collection has more exercises
if (isCorrect && $.isFunction(PARSONS_SETTINGS.next)) {
$("#ul-sortable").sortable("destroy");... | [
"function",
"(",
"feedback",
")",
"{",
"var",
"isCorrect",
"=",
"(",
"$",
".",
"isArray",
"(",
"feedback",
")",
"&&",
"feedback",
".",
"length",
"===",
"0",
")",
"||",
"(",
"'feedback'",
"in",
"feedback",
"&&",
"feedback",
".",
"success",
")",
";",
"... | default feedback callback handler | [
"default",
"feedback",
"callback",
"handler"
] | 8c504c261137b0bedf1939a60dd76cfe21d01d7f | https://github.com/acos-server/acos-jsparsons/blob/8c504c261137b0bedf1939a60dd76cfe21d01d7f/static/js-parsons/ui-extension/parsons-site-ui.js#L213-L259 | train | |
toddbluhm/bluebird-events | index.js | function (events, func) {
for (var i = 0; i < events.length; i++) {
obj.once(events[i], func)
listeners[events[i]] = func
}
} | javascript | function (events, func) {
for (var i = 0; i < events.length; i++) {
obj.once(events[i], func)
listeners[events[i]] = func
}
} | [
"function",
"(",
"events",
",",
"func",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"events",
".",
"length",
";",
"i",
"++",
")",
"{",
"obj",
".",
"once",
"(",
"events",
"[",
"i",
"]",
",",
"func",
")",
"listeners",
"[",
"event... | Adds an array of events to the object with the given func | [
"Adds",
"an",
"array",
"of",
"events",
"to",
"the",
"object",
"with",
"the",
"given",
"func"
] | 3f9045c73c35ad28e6c285feca4a740bfec6ff91 | https://github.com/toddbluhm/bluebird-events/blob/3f9045c73c35ad28e6c285feca4a740bfec6ff91/index.js#L45-L50 | train | |
yefremov/aggregatejs | max.js | max | function max(array) {
var length = array.length;
if (length === 0) {
return 0;
}
var index = -1;
var result = array[++index];
while (++index < length) {
if (array[index] > result) {
result = array[index];
}
}
return result;
} | javascript | function max(array) {
var length = array.length;
if (length === 0) {
return 0;
}
var index = -1;
var result = array[++index];
while (++index < length) {
if (array[index] > result) {
result = array[index];
}
}
return result;
} | [
"function",
"max",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"length",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"var",
"index",
"=",
"-",
"1",
";",
"var",
"result",
"=",
"array",
"[",
"++",
"ind... | Returns the largest number in `array`.
@param {Array} array Range of numbers to get maximum.
@return {number}
@example
max([100, -100, 150, -50, 250, 100]);
// => 250 | [
"Returns",
"the",
"largest",
"number",
"in",
"array",
"."
] | 932b28a15a5707135e7095950000a838db409511 | https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/max.js#L19-L36 | train |
taoyuan/sira-express-rest | lib/rest.js | buildRoutes | function buildRoutes(obj) {
var routes = obj.http;
if (routes && !Array.isArray(routes)) {
routes = [routes];
}
// overidden
if (routes) {
// patch missing verbs / routes
routes.forEach(function (r) {
r.verb = String(r.verb || 'all').toLowerCase();
r... | javascript | function buildRoutes(obj) {
var routes = obj.http;
if (routes && !Array.isArray(routes)) {
routes = [routes];
}
// overidden
if (routes) {
// patch missing verbs / routes
routes.forEach(function (r) {
r.verb = String(r.verb || 'all').toLowerCase();
r... | [
"function",
"buildRoutes",
"(",
"obj",
")",
"{",
"var",
"routes",
"=",
"obj",
".",
"http",
";",
"if",
"(",
"routes",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"routes",
")",
")",
"{",
"routes",
"=",
"[",
"routes",
"]",
";",
"}",
"// overidden",
"if"... | Get the path for the given method.
Rest.prototype.buildRoutes = buildRoutes; | [
"Get",
"the",
"path",
"for",
"the",
"given",
"method",
".",
"Rest",
".",
"prototype",
".",
"buildRoutes",
"=",
"buildRoutes",
";"
] | 84b06a3cb127cf68f194a1b1ec115db0e560078c | https://github.com/taoyuan/sira-express-rest/blob/84b06a3cb127cf68f194a1b1ec115db0e560078c/lib/rest.js#L341-L375 | train |
benmosheron/ben-loves-vectors | vector.js | create2x2 | function create2x2(a, b, c, d){
if (undef(a)) throw new Error("At least one argument must be provided.");
if (undef(b)){
// Everything = a
b = a;
c = a;
d = a;
}
else{
// we have a and b
if(undef(c)){
c = a;
d = b;
}
... | javascript | function create2x2(a, b, c, d){
if (undef(a)) throw new Error("At least one argument must be provided.");
if (undef(b)){
// Everything = a
b = a;
c = a;
d = a;
}
else{
// we have a and b
if(undef(c)){
c = a;
d = b;
}
... | [
"function",
"create2x2",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
")",
"{",
"if",
"(",
"undef",
"(",
"a",
")",
")",
"throw",
"new",
"Error",
"(",
"\"At least one argument must be provided.\"",
")",
";",
"if",
"(",
"undef",
"(",
"b",
")",
")",
"{",
"... | Create a 2D vector by providing one, two, or four values | [
"Create",
"a",
"2D",
"vector",
"by",
"providing",
"one",
"two",
"or",
"four",
"values"
] | 8af737655f6a0fc4a585b3281f516129bb5bc8d3 | https://github.com/benmosheron/ben-loves-vectors/blob/8af737655f6a0fc4a585b3281f516129bb5bc8d3/vector.js#L130-L151 | train |
benmosheron/ben-loves-vectors | vector.js | drillRec | function drillRec(v){
const next = v.get(0);
if(v.length > 1 || !isAVector(next)) return v;
return drillRec(next);
} | javascript | function drillRec(v){
const next = v.get(0);
if(v.length > 1 || !isAVector(next)) return v;
return drillRec(next);
} | [
"function",
"drillRec",
"(",
"v",
")",
"{",
"const",
"next",
"=",
"v",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"v",
".",
"length",
">",
"1",
"||",
"!",
"isAVector",
"(",
"next",
")",
")",
"return",
"v",
";",
"return",
"drillRec",
"(",
"next"... | drill to first level with >1 value | [
"drill",
"to",
"first",
"level",
"with",
">",
"1",
"value"
] | 8af737655f6a0fc4a585b3281f516129bb5bc8d3 | https://github.com/benmosheron/ben-loves-vectors/blob/8af737655f6a0fc4a585b3281f516129bb5bc8d3/vector.js#L350-L354 | train |
benmosheron/ben-loves-vectors | vector.js | mapToValues | function mapToValues(v){
function mapRec(e){
if(!isAVector(e)) return e;
return mapRec(e.get(0));
}
return v.map(mapRec);
} | javascript | function mapToValues(v){
function mapRec(e){
if(!isAVector(e)) return e;
return mapRec(e.get(0));
}
return v.map(mapRec);
} | [
"function",
"mapToValues",
"(",
"v",
")",
"{",
"function",
"mapRec",
"(",
"e",
")",
"{",
"if",
"(",
"!",
"isAVector",
"(",
"e",
")",
")",
"return",
"e",
";",
"return",
"mapRec",
"(",
"e",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"return",
"v",... | map to elementary values | [
"map",
"to",
"elementary",
"values"
] | 8af737655f6a0fc4a585b3281f516129bb5bc8d3 | https://github.com/benmosheron/ben-loves-vectors/blob/8af737655f6a0fc4a585b3281f516129bb5bc8d3/vector.js#L357-L363 | train |
cli-kit/cli-mid-command | index.js | lazy | function lazy(arg) {
var conf = this.configure();
var action = arg.action();
if(!conf.command.dir || action !== undefined) return false;
var file = path.join(conf.command.dir, getModulePath.call(this, arg))
try{
action = require(file);
if(typeof action !== 'function') {
return this.raise(this.er... | javascript | function lazy(arg) {
var conf = this.configure();
var action = arg.action();
if(!conf.command.dir || action !== undefined) return false;
var file = path.join(conf.command.dir, getModulePath.call(this, arg))
try{
action = require(file);
if(typeof action !== 'function') {
return this.raise(this.er... | [
"function",
"lazy",
"(",
"arg",
")",
"{",
"var",
"conf",
"=",
"this",
".",
"configure",
"(",
")",
";",
"var",
"action",
"=",
"arg",
".",
"action",
"(",
")",
";",
"if",
"(",
"!",
"conf",
".",
"command",
".",
"dir",
"||",
"action",
"!==",
"undefine... | lazily load a command action definition from a module | [
"lazily",
"load",
"a",
"command",
"action",
"definition",
"from",
"a",
"module"
] | fd2c3d758886e2833df7dcf84b0e14cd40649671 | https://github.com/cli-kit/cli-mid-command/blob/fd2c3d758886e2833df7dcf84b0e14cd40649671/index.js#L23-L37 | train |
jwoudenberg/require-compiled | index.js | rewriteRequires | function rewriteRequires (filename) {
var basedir = path.dirname(filename)
return wrapListener(
function (nodePath) {
if (nodePath.isLiteral() && !path.isAbsolute(nodePath.node.value)) {
var match = nodePath.node.value.match(/^compile!(.+)$/)
nodePath.node.value = match
... | javascript | function rewriteRequires (filename) {
var basedir = path.dirname(filename)
return wrapListener(
function (nodePath) {
if (nodePath.isLiteral() && !path.isAbsolute(nodePath.node.value)) {
var match = nodePath.node.value.match(/^compile!(.+)$/)
nodePath.node.value = match
... | [
"function",
"rewriteRequires",
"(",
"filename",
")",
"{",
"var",
"basedir",
"=",
"path",
".",
"dirname",
"(",
"filename",
")",
"return",
"wrapListener",
"(",
"function",
"(",
"nodePath",
")",
"{",
"if",
"(",
"nodePath",
".",
"isLiteral",
"(",
")",
"&&",
... | Rewrite requires to use absolute paths. This way tests the compiled tests can still be ran from a different directory. | [
"Rewrite",
"requires",
"to",
"use",
"absolute",
"paths",
".",
"This",
"way",
"tests",
"the",
"compiled",
"tests",
"can",
"still",
"be",
"ran",
"from",
"a",
"different",
"directory",
"."
] | 99f45ad1f286ba346313d23e6d42d78adff68d42 | https://github.com/jwoudenberg/require-compiled/blob/99f45ad1f286ba346313d23e6d42d78adff68d42/index.js#L84-L102 | train |
meltmedia/node-usher | lib/activity/poller.js | ActivityPoller | function ActivityPoller(name, domain, options) {
if (!(this instanceof ActivityPoller)) {
return new ActivityPoller(name, domain, options);
}
events.EventEmitter.call(this);
if (!_.isString(name)) {
throw new Error('A `name` is required');
}
if (!_.isString(domain)) {
throw new Error('A `doma... | javascript | function ActivityPoller(name, domain, options) {
if (!(this instanceof ActivityPoller)) {
return new ActivityPoller(name, domain, options);
}
events.EventEmitter.call(this);
if (!_.isString(name)) {
throw new Error('A `name` is required');
}
if (!_.isString(domain)) {
throw new Error('A `doma... | [
"function",
"ActivityPoller",
"(",
"name",
",",
"domain",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ActivityPoller",
")",
")",
"{",
"return",
"new",
"ActivityPoller",
"(",
"name",
",",
"domain",
",",
"options",
")",
";",
"}",
... | Represents a single, named poller, where all activities are defined.
@constructor
@param {string} name - The name of the poller. This is arbitrary and has no bering on SWF.
@param {string} domain - The AWS SWF domain name to execute this pollers activities in.
@param {object} [options] - Additional options used when po... | [
"Represents",
"a",
"single",
"named",
"poller",
"where",
"all",
"activities",
"are",
"defined",
"."
] | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/activity/poller.js#L33-L67 | train |
docLoop/core | manage-calls.js | function(obj, method_name, force_call_after = 1000){
if(typeof obj[method_name] != 'function') throw new TypeError("collateCalls(): Not a method '"+method_name+ "' on "+obj.toString())
var original_fn = obj[method_name],
scheduled_runs = {}
function requestRun(...args){
var str = JSON.stringify(args... | javascript | function(obj, method_name, force_call_after = 1000){
if(typeof obj[method_name] != 'function') throw new TypeError("collateCalls(): Not a method '"+method_name+ "' on "+obj.toString())
var original_fn = obj[method_name],
scheduled_runs = {}
function requestRun(...args){
var str = JSON.stringify(args... | [
"function",
"(",
"obj",
",",
"method_name",
",",
"force_call_after",
"=",
"1000",
")",
"{",
"if",
"(",
"typeof",
"obj",
"[",
"method_name",
"]",
"!=",
"'function'",
")",
"throw",
"new",
"TypeError",
"(",
"\"collateCalls(): Not a method '\"",
"+",
"method_name",
... | Replaces a method of provided object with a proxy,
that will prevent multiple calls to the original method with the same arguments
while waiting for a response.
The proxy method will allways wrap the original method in a Promise.
If a previous call with the same arguments is still pending the proxy will return the co... | [
"Replaces",
"a",
"method",
"of",
"provided",
"object",
"with",
"a",
"proxy",
"that",
"will",
"prevent",
"multiple",
"calls",
"to",
"the",
"original",
"method",
"with",
"the",
"same",
"arguments",
"while",
"waiting",
"for",
"a",
"response",
"."
] | 111870e3dcc537997fa31dee485e355e487af794 | https://github.com/docLoop/core/blob/111870e3dcc537997fa31dee485e355e487af794/manage-calls.js#L96-L121 | train | |
billysbilling/inflectors | index.js | function() {
singulars = {};
for (var k in plurals) {
if (!plurals.hasOwnProperty(k)) continue;
singulars[plurals[k]] = k;
}
} | javascript | function() {
singulars = {};
for (var k in plurals) {
if (!plurals.hasOwnProperty(k)) continue;
singulars[plurals[k]] = k;
}
} | [
"function",
"(",
")",
"{",
"singulars",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"k",
"in",
"plurals",
")",
"{",
"if",
"(",
"!",
"plurals",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"continue",
";",
"singulars",
"[",
"plurals",
"[",
"k",
"]",
"]",... | Clears singular rules and recreates from opposites of plural rules | [
"Clears",
"singular",
"rules",
"and",
"recreates",
"from",
"opposites",
"of",
"plural",
"rules"
] | 092d024e9e883aef911354e2af1c669a463d448f | https://github.com/billysbilling/inflectors/blob/092d024e9e883aef911354e2af1c669a463d448f/index.js#L74-L80 | train | |
redisjs/jsr-server | lib/command/script/evalsha.js | execute | function execute(req, res) {
ScriptManager.evalsha(req, res, '' + req.args[0], req.args.slice(1));
} | javascript | function execute(req, res) {
ScriptManager.evalsha(req, res, '' + req.args[0], req.args.slice(1));
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"ScriptManager",
".",
"evalsha",
"(",
"req",
",",
"res",
",",
"''",
"+",
"req",
".",
"args",
"[",
"0",
"]",
",",
"req",
".",
"args",
".",
"slice",
"(",
"1",
")",
")",
";",
"}"
] | Respond to the EVALSHA command. | [
"Respond",
"to",
"the",
"EVALSHA",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/script/evalsha.js#L18-L20 | train |
feedhenry/fh-statsc | lib/stats.js | send | function send(data, cb) {
if (enabled) {
var send_data = new Buffer(data);
try {
socket.send(send_data, 0, send_data.length, port, host, function(err, bytes) {
if (cb) {
return cb(err, bytes);
}
});
} catch (x) {
// Purposely ignored..
... | javascript | function send(data, cb) {
if (enabled) {
var send_data = new Buffer(data);
try {
socket.send(send_data, 0, send_data.length, port, host, function(err, bytes) {
if (cb) {
return cb(err, bytes);
}
});
} catch (x) {
// Purposely ignored..
... | [
"function",
"send",
"(",
"data",
",",
"cb",
")",
"{",
"if",
"(",
"enabled",
")",
"{",
"var",
"send_data",
"=",
"new",
"Buffer",
"(",
"data",
")",
";",
"try",
"{",
"socket",
".",
"send",
"(",
"send_data",
",",
"0",
",",
"send_data",
".",
"length",
... | needs to send in batches every second or so | [
"needs",
"to",
"send",
"in",
"batches",
"every",
"second",
"or",
"so"
] | 6a320a3dfa5d6baabc6ea4d5d7280bdb60e6757d | https://github.com/feedhenry/fh-statsc/blob/6a320a3dfa5d6baabc6ea4d5d7280bdb60e6757d/lib/stats.js#L23-L39 | train |
nfroidure/common-services | src/codeGenerator.js | codeGenerator | async function codeGenerator(length = 6) {
const code = new Array(length)
.fill('0')
.map(() => CHARS_SET[Math.floor(random() * (charsSetLength - 1))])
.join('');
log('debug', `Generated a new code:`, code);
return code;
} | javascript | async function codeGenerator(length = 6) {
const code = new Array(length)
.fill('0')
.map(() => CHARS_SET[Math.floor(random() * (charsSetLength - 1))])
.join('');
log('debug', `Generated a new code:`, code);
return code;
} | [
"async",
"function",
"codeGenerator",
"(",
"length",
"=",
"6",
")",
"{",
"const",
"code",
"=",
"new",
"Array",
"(",
"length",
")",
".",
"fill",
"(",
"'0'",
")",
".",
"map",
"(",
"(",
")",
"=>",
"CHARS_SET",
"[",
"Math",
".",
"floor",
"(",
"random",... | Returns a random code
@param {Number} [length]
An optional custon code length (defaults to 6)
@return {Promise<String>}
A promise of the generated code
@example
console.log([
codeGenerator(),
codeGenerator(),
codeGenerator(),
]);
// Prints: ABCDEF,GHJKMN,PRSTUV | [
"Returns",
"a",
"random",
"code"
] | 09df32597fe798777abec0ef1f3a994e91046085 | https://github.com/nfroidure/common-services/blob/09df32597fe798777abec0ef1f3a994e91046085/src/codeGenerator.js#L62-L69 | train |
gethuman/pancakes-mongo | lib/pancakes.mongo.adapter.js | getModel | function getModel(resource) {
var name = resource.name;
// if not already in the model cache, get it
if (!cache.models[name]) {
var schema = new mongoose.Schema(resource.fields, { collection: name });
// loop through indexes and add them to the schema
_.each(resource.indexes, funct... | javascript | function getModel(resource) {
var name = resource.name;
// if not already in the model cache, get it
if (!cache.models[name]) {
var schema = new mongoose.Schema(resource.fields, { collection: name });
// loop through indexes and add them to the schema
_.each(resource.indexes, funct... | [
"function",
"getModel",
"(",
"resource",
")",
"{",
"var",
"name",
"=",
"resource",
".",
"name",
";",
"// if not already in the model cache, get it",
"if",
"(",
"!",
"cache",
".",
"models",
"[",
"name",
"]",
")",
"{",
"var",
"schema",
"=",
"new",
"mongoose",
... | Create a mongoose model object from a set of fields, fieldsets and indexes
@param resource
@returns {Model} | [
"Create",
"a",
"mongoose",
"model",
"object",
"from",
"a",
"set",
"of",
"fields",
"fieldsets",
"and",
"indexes"
] | e10d2ca61643607008fdcb14b55d8a383284463b | https://github.com/gethuman/pancakes-mongo/blob/e10d2ca61643607008fdcb14b55d8a383284463b/lib/pancakes.mongo.adapter.js#L114-L130 | train |
gethuman/pancakes-mongo | lib/pancakes.mongo.adapter.js | saveIndexInfo | function saveIndexInfo() {
// reset the cache
var tmpCache = cache.idxInfo;
cache.idxInfo = {};
var promises = [];
// add promise for each things being saved/updated
_.each(tmpCache, function (idxInfo, key) {
var where = { str: key };
var select = '_id count';
var pro... | javascript | function saveIndexInfo() {
// reset the cache
var tmpCache = cache.idxInfo;
cache.idxInfo = {};
var promises = [];
// add promise for each things being saved/updated
_.each(tmpCache, function (idxInfo, key) {
var where = { str: key };
var select = '_id count';
var pro... | [
"function",
"saveIndexInfo",
"(",
")",
"{",
"// reset the cache",
"var",
"tmpCache",
"=",
"cache",
".",
"idxInfo",
";",
"cache",
".",
"idxInfo",
"=",
"{",
"}",
";",
"var",
"promises",
"=",
"[",
"]",
";",
"// add promise for each things being saved/updated",
"_",... | Save a query to the idxInfo table | [
"Save",
"a",
"query",
"to",
"the",
"idxInfo",
"table"
] | e10d2ca61643607008fdcb14b55d8a383284463b | https://github.com/gethuman/pancakes-mongo/blob/e10d2ca61643607008fdcb14b55d8a383284463b/lib/pancakes.mongo.adapter.js#L135-L167 | train |
tomiberes/batoh | src/batoh.js | function(cb) {
var self = this;
var request;
try {
request = IndexedDB.open(self.setup.database, self.setup.version);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsuccess = function(event) {
self.idb = event.target.result;
if (isFunction(cb)) return cb(... | javascript | function(cb) {
var self = this;
var request;
try {
request = IndexedDB.open(self.setup.database, self.setup.version);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsuccess = function(event) {
self.idb = event.target.result;
if (isFunction(cb)) return cb(... | [
"function",
"(",
"cb",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"request",
";",
"try",
"{",
"request",
"=",
"IndexedDB",
".",
"open",
"(",
"self",
".",
"setup",
".",
"database",
",",
"self",
".",
"setup",
".",
"version",
")",
";",
"}",
"... | Open or create the database using the `setup` passed to the constructor.
@param {Function} callback - gets one argument `(err)`,
if there is no error `err` is null. | [
"Open",
"or",
"create",
"the",
"database",
"using",
"the",
"setup",
"passed",
"to",
"the",
"constructor",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L66-L101 | train | |
tomiberes/batoh | src/batoh.js | function(cb) {
if (IndexedDB.deleteDatabase) {
var request = IndexedDB.deleteDatabase(this.setup.database);
// It's always in an order of onblocked -> onsuccess,
// ignoring other handlers, for now.
request.onsuccess = function(event) {
if (isFunction(cb)) return cb(null, event.targe... | javascript | function(cb) {
if (IndexedDB.deleteDatabase) {
var request = IndexedDB.deleteDatabase(this.setup.database);
// It's always in an order of onblocked -> onsuccess,
// ignoring other handlers, for now.
request.onsuccess = function(event) {
if (isFunction(cb)) return cb(null, event.targe... | [
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"IndexedDB",
".",
"deleteDatabase",
")",
"{",
"var",
"request",
"=",
"IndexedDB",
".",
"deleteDatabase",
"(",
"this",
".",
"setup",
".",
"database",
")",
";",
"// It's always in an order of onblocked -> onsuccess,",
"/... | If deleting database is provided by implementation,
delete the database used with current setup.
@param {Function} callback - gets one argument `(err)`,
if there is no error `err` is null.
TODO: correct success, blocked, versionchange handling,
current spec is unclear and outcome is not usable,
thus using only the `o... | [
"If",
"deleting",
"database",
"is",
"provided",
"by",
"implementation",
"delete",
"the",
"database",
"used",
"with",
"current",
"setup",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L125-L140 | train | |
tomiberes/batoh | src/batoh.js | function(storeNames, mode, result, cb) {
var transaction;
try {
transaction = this.idb.transaction(storeNames, mode);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
transaction.onabort = function(event) {
if (isFunction(cb)) return cb(event.target.error);
};
transact... | javascript | function(storeNames, mode, result, cb) {
var transaction;
try {
transaction = this.idb.transaction(storeNames, mode);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
transaction.onabort = function(event) {
if (isFunction(cb)) return cb(event.target.error);
};
transact... | [
"function",
"(",
"storeNames",
",",
"mode",
",",
"result",
",",
"cb",
")",
"{",
"var",
"transaction",
";",
"try",
"{",
"transaction",
"=",
"this",
".",
"idb",
".",
"transaction",
"(",
"storeNames",
",",
"mode",
")",
";",
"}",
"catch",
"(",
"err",
")"... | Wrap IDBDatabase.transaction
@param {String} storeNames - names of the object stores to use.
@param {String} mode - transaction mode to use.
@param {Function} callback - gets two arguments `(err, result)`,
if there is no Error `err` is `null`.
@param {Object} result - Object that will be returned as a result of
the tr... | [
"Wrap",
"IDBDatabase",
".",
"transaction"
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L152-L169 | train | |
tomiberes/batoh | src/batoh.js | function(storeName, transaction, cb) {
try {
return transaction.objectStore(storeName);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
} | javascript | function(storeName, transaction, cb) {
try {
return transaction.objectStore(storeName);
} catch (err) {
if (isFunction(cb)) return cb(err);
}
} | [
"function",
"(",
"storeName",
",",
"transaction",
",",
"cb",
")",
"{",
"try",
"{",
"return",
"transaction",
".",
"objectStore",
"(",
"storeName",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"isFunction",
"(",
"cb",
")",
")",
"return",
"c... | Wrap IDBTransation.objectStore
@param {String} storeName - name of the object store to use.
@param {IDBTransaction} transaction - to use.
@param {Function} callback - gets one argument `(err)`,
if there is no error, it won't be called. | [
"Wrap",
"IDBTransation",
".",
"objectStore"
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L179-L185 | train | |
tomiberes/batoh | src/batoh.js | function(storeName, value, key, cb) {
// For usage of out-of-line keys a `key` argument have to be specified,
// otherwise the `request` will be made assuming in-line key or key generator.
// For detailed possibilities see what you can't do in `DataError` section here:
// `https://developer.mozilla.org/... | javascript | function(storeName, value, key, cb) {
// For usage of out-of-line keys a `key` argument have to be specified,
// otherwise the `request` will be made assuming in-line key or key generator.
// For detailed possibilities see what you can't do in `DataError` section here:
// `https://developer.mozilla.org/... | [
"function",
"(",
"storeName",
",",
"value",
",",
"key",
",",
"cb",
")",
"{",
"// For usage of out-of-line keys a `key` argument have to be specified,",
"// otherwise the `request` will be made assuming in-line key or key generator.",
"// For detailed possibilities see what you can't do in ... | Add one or more records. If record already exist in object store,
returns an Error.
@param {String} storeName - name of the object store to use.
@param {Object|Object[]} value - Object or Array of objects to store.
@param {String|String[]} [key] - String or an Array of strings,
as a keys for the values.
If an Array is... | [
"Add",
"one",
"or",
"more",
"records",
".",
"If",
"record",
"already",
"exist",
"in",
"object",
"store",
"returns",
"an",
"Error",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L201-L250 | train | |
tomiberes/batoh | src/batoh.js | function(storeName, key, cb) {
if (!Array.isArray(key)) {
key = [key];
}
var result = [];
var transaction = this.transaction(storeName, MODE.READ_WRITE, result, cb);
var store = this.store(storeName, transaction, cb);
var _del = function(key) {
var request;
try {
reque... | javascript | function(storeName, key, cb) {
if (!Array.isArray(key)) {
key = [key];
}
var result = [];
var transaction = this.transaction(storeName, MODE.READ_WRITE, result, cb);
var store = this.store(storeName, transaction, cb);
var _del = function(key) {
var request;
try {
reque... | [
"function",
"(",
"storeName",
",",
"key",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"key",
")",
")",
"{",
"key",
"=",
"[",
"key",
"]",
";",
"}",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"transaction",
"=",
"this",
... | Delete one or more records specified by the key.
@param {String} storeName - name of the object store to use
@param {String} key - key that identifies the record to be deleted.
@param {Function} callback - gets two arguments `(err, result)`,
if there is no Error `err` is `null`. `result` is always an Array of the
resu... | [
"Delete",
"one",
"or",
"more",
"records",
"specified",
"by",
"the",
"key",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L360-L385 | train | |
tomiberes/batoh | src/batoh.js | function(storeName, query, each, cb) {
if (arguments.length === 3) {
cb = each;
each = null;
}
if (arguments.length === 2) {
cb = query;
query = null;
each = null;
}
var result = [];
var transaction = this.transaction(storeName, MODE.READ_ONLY, result, cb);
var... | javascript | function(storeName, query, each, cb) {
if (arguments.length === 3) {
cb = each;
each = null;
}
if (arguments.length === 2) {
cb = query;
query = null;
each = null;
}
var result = [];
var transaction = this.transaction(storeName, MODE.READ_ONLY, result, cb);
var... | [
"function",
"(",
"storeName",
",",
"query",
",",
"each",
",",
"cb",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"3",
")",
"{",
"cb",
"=",
"each",
";",
"each",
"=",
"null",
";",
"}",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
... | Open cursor and query the object store.
@param {string} storeName - name of the object store to use
@param {Object} query - configuration Object defining the query
@param {String} [query.index] - index to use, if omitted cursor is
opened on the keyPath of the store
@param {Object} [query.range] - IDBKeyRange object de... | [
"Open",
"cursor",
"and",
"query",
"the",
"object",
"store",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L405-L468 | train | |
tomiberes/batoh | src/batoh.js | function(storeName, cb) {
var result;
var transaction = this.transaction(storeName, MODE.READ_ONLY, result, cb);
var store = this.store(storeName, transaction, cb);
var request;
try {
request = store.count();
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsuc... | javascript | function(storeName, cb) {
var result;
var transaction = this.transaction(storeName, MODE.READ_ONLY, result, cb);
var store = this.store(storeName, transaction, cb);
var request;
try {
request = store.count();
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsuc... | [
"function",
"(",
"storeName",
",",
"cb",
")",
"{",
"var",
"result",
";",
"var",
"transaction",
"=",
"this",
".",
"transaction",
"(",
"storeName",
",",
"MODE",
".",
"READ_ONLY",
",",
"result",
",",
"cb",
")",
";",
"var",
"store",
"=",
"this",
".",
"st... | Count the objects in the store.
@param {String} storeName - name of the object store to count.
@param {Function} callback - gets one argument `(err)`,
if there is no error `err` is null. | [
"Count",
"the",
"objects",
"in",
"the",
"store",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L477-L493 | train | |
tomiberes/batoh | src/batoh.js | function(storeName, cb) {
var result;
var transaction = this.transaction(storeName, MODE.READ_WRITE, result, cb);
var store = this.store(storeName, transaction, cb);
var request;
try {
request = store.clear();
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsu... | javascript | function(storeName, cb) {
var result;
var transaction = this.transaction(storeName, MODE.READ_WRITE, result, cb);
var store = this.store(storeName, transaction, cb);
var request;
try {
request = store.clear();
} catch (err) {
if (isFunction(cb)) return cb(err);
}
request.onsu... | [
"function",
"(",
"storeName",
",",
"cb",
")",
"{",
"var",
"result",
";",
"var",
"transaction",
"=",
"this",
".",
"transaction",
"(",
"storeName",
",",
"MODE",
".",
"READ_WRITE",
",",
"result",
",",
"cb",
")",
";",
"var",
"store",
"=",
"this",
".",
"s... | Clear the object store of all records.
@param {String} storeName - name of the object store to clear
@param {Function} callback - gets one argument `(err)`,
if there is no error `err` is null. | [
"Clear",
"the",
"object",
"store",
"of",
"all",
"records",
"."
] | 2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d | https://github.com/tomiberes/batoh/blob/2bc5d0bb5d5fa8d7fdb6998298ca51c50e4ee54d/src/batoh.js#L502-L518 | train | |
gardr/validator | lib/rule/validate/codeUsage.js | validate | function validate(harvested, report, next, options) {
report.setChecklist('CodeUsage', 'Static code analysis');
var illegalIdentifiers = ['geolocation'];
function analyze(content, sourceURL, origin) {
var ast;
var trace = {
'trace': {
'sourceURL': sourceURL
... | javascript | function validate(harvested, report, next, options) {
report.setChecklist('CodeUsage', 'Static code analysis');
var illegalIdentifiers = ['geolocation'];
function analyze(content, sourceURL, origin) {
var ast;
var trace = {
'trace': {
'sourceURL': sourceURL
... | [
"function",
"validate",
"(",
"harvested",
",",
"report",
",",
"next",
",",
"options",
")",
"{",
"report",
".",
"setChecklist",
"(",
"'CodeUsage'",
",",
"'Static code analysis'",
")",
";",
"var",
"illegalIdentifiers",
"=",
"[",
"'geolocation'",
"]",
";",
"funct... | navigator.geolocation | [
"navigator",
".",
"geolocation"
] | 8ff6acc9e312d3a33f35422110397cd83b035036 | https://github.com/gardr/validator/blob/8ff6acc9e312d3a33f35422110397cd83b035036/lib/rule/validate/codeUsage.js#L5-L75 | train |
inception-soa/inception.primitives | lib/error.js | PrimitiveError | function PrimitiveError(code, metadata, cause) {
if (code === undefined || code === null) {
throw new TypeError('`code` is a required argument!');
}
PrimitiveError.super_.call(this, this.constructor.ERRORS[code]);
if (metadata instanceof Error) {
cause = metadata;
metadata = undefined;
}
/**
... | javascript | function PrimitiveError(code, metadata, cause) {
if (code === undefined || code === null) {
throw new TypeError('`code` is a required argument!');
}
PrimitiveError.super_.call(this, this.constructor.ERRORS[code]);
if (metadata instanceof Error) {
cause = metadata;
metadata = undefined;
}
/**
... | [
"function",
"PrimitiveError",
"(",
"code",
",",
"metadata",
",",
"cause",
")",
"{",
"if",
"(",
"code",
"===",
"undefined",
"||",
"code",
"===",
"null",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'`code` is a required argument!'",
")",
";",
"}",
"PrimitiveE... | A base class for all errors
This class inherits from the JavaScript Error class, and then parasitically
inherits from PrimitiveObject. Multiple inheritance isn't pretty!
@param {String} code A unique code identifying the error
@param {Object} [metadata] Metadata related to the error
@param {Error} [cause] The origina... | [
"A",
"base",
"class",
"for",
"all",
"errors"
] | fc9fa777248050eefe3e62f73b9f15494bdc0bbc | https://github.com/inception-soa/inception.primitives/blob/fc9fa777248050eefe3e62f73b9f15494bdc0bbc/lib/error.js#L41-L64 | train |
redisjs/jsr-server | lib/client.js | Client | function Client(socket) {
// flag whether an external or internal client socket
this._tcp = (socket instanceof Socket);
// index into the connections array
this._index = -1;
// file descriptor
this._fd = socket._handle.fd;
// remote ip address
this._remoteAddress = socket.remoteAddress;
// remote... | javascript | function Client(socket) {
// flag whether an external or internal client socket
this._tcp = (socket instanceof Socket);
// index into the connections array
this._index = -1;
// file descriptor
this._fd = socket._handle.fd;
// remote ip address
this._remoteAddress = socket.remoteAddress;
// remote... | [
"function",
"Client",
"(",
"socket",
")",
"{",
"// flag whether an external or internal client socket",
"this",
".",
"_tcp",
"=",
"(",
"socket",
"instanceof",
"Socket",
")",
";",
"// index into the connections array",
"this",
".",
"_index",
"=",
"-",
"1",
";",
"// f... | Encapsulates client connection state. | [
"Encapsulates",
"client",
"connection",
"state",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/client.js#L25-L83 | train |
redisjs/jsr-server | lib/client.js | getObject | function getObject() {
var o = {}
, i
, fields = arguments.length
? Array.prototype.slice.call(arguments, 0) : keys;
for(i = 0;i < fields.length;i++) {
o[fields[i]] = this[fields[i]];
}
return o;
} | javascript | function getObject() {
var o = {}
, i
, fields = arguments.length
? Array.prototype.slice.call(arguments, 0) : keys;
for(i = 0;i < fields.length;i++) {
o[fields[i]] = this[fields[i]];
}
return o;
} | [
"function",
"getObject",
"(",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"i",
",",
"fields",
"=",
"arguments",
".",
"length",
"?",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
":",
"keys",
";",
"for",
"(",... | Get an object of information about this client. | [
"Get",
"an",
"object",
"of",
"information",
"about",
"this",
"client",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/client.js#L88-L97 | train |
SebastianOsuna/configure.js | lib/configure.js | _configFilter | function _configFilter ( f ) {
var parts = f.split("."),
ext = parts[ parts.length - 1 ],
pre = parts[ parts.length - 2 ],
name = parts[ parts.length - 3];
return !!(ext === "dist" && pre === "json" &&
exports.__ignores.indexOf( name ) === -1 && e... | javascript | function _configFilter ( f ) {
var parts = f.split("."),
ext = parts[ parts.length - 1 ],
pre = parts[ parts.length - 2 ],
name = parts[ parts.length - 3];
return !!(ext === "dist" && pre === "json" &&
exports.__ignores.indexOf( name ) === -1 && e... | [
"function",
"_configFilter",
"(",
"f",
")",
"{",
"var",
"parts",
"=",
"f",
".",
"split",
"(",
"\".\"",
")",
",",
"ext",
"=",
"parts",
"[",
"parts",
".",
"length",
"-",
"1",
"]",
",",
"pre",
"=",
"parts",
"[",
"parts",
".",
"length",
"-",
"2",
"... | filename filter function | [
"filename",
"filter",
"function"
] | 39551c58d92a4ce065df25e6b9999b8495ca4833 | https://github.com/SebastianOsuna/configure.js/blob/39551c58d92a4ce065df25e6b9999b8495ca4833/lib/configure.js#L90-L98 | train |
foru17/gulp-rev-custom-tag | tool.js | function (directory, filename) {
return Path.join(directory, filename).replace(/^[a-z]:\\/i, '/').replace(/\\/g, '/');
} | javascript | function (directory, filename) {
return Path.join(directory, filename).replace(/^[a-z]:\\/i, '/').replace(/\\/g, '/');
} | [
"function",
"(",
"directory",
",",
"filename",
")",
"{",
"return",
"Path",
".",
"join",
"(",
"directory",
",",
"filename",
")",
".",
"replace",
"(",
"/",
"^[a-z]:\\\\",
"/",
"i",
",",
"'/'",
")",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'/... | Joins a directory and a filename, replaces Windows forward-slash with a backslash. | [
"Joins",
"a",
"directory",
"and",
"a",
"filename",
"replaces",
"Windows",
"forward",
"-",
"slash",
"with",
"a",
"backslash",
"."
] | 96ef47647629f49b15d3f8fca024fc567bcb358e | https://github.com/foru17/gulp-rev-custom-tag/blob/96ef47647629f49b15d3f8fca024fc567bcb358e/tool.js#L27-L31 | train | |
foru17/gulp-rev-custom-tag | tool.js | function (base, path, noStartingSlash) {
if (base === path) {
return '';
}
// Sanitize inputs, convert windows to posix style slashes, ensure trailing slash for base
base = base.replace(/^[a-z]:/i, '').replace(/\\/g, '/').replace(/\/$/g, '') + '/';
path = path.repla... | javascript | function (base, path, noStartingSlash) {
if (base === path) {
return '';
}
// Sanitize inputs, convert windows to posix style slashes, ensure trailing slash for base
base = base.replace(/^[a-z]:/i, '').replace(/\\/g, '/').replace(/\/$/g, '') + '/';
path = path.repla... | [
"function",
"(",
"base",
",",
"path",
",",
"noStartingSlash",
")",
"{",
"if",
"(",
"base",
"===",
"path",
")",
"{",
"return",
"''",
";",
"}",
"// Sanitize inputs, convert windows to posix style slashes, ensure trailing slash for base",
"base",
"=",
"base",
".",
"rep... | Given a base path and resource path, will return resource path relative to the base.
Also replaces Windows forward-slash with a backslash. | [
"Given",
"a",
"base",
"path",
"and",
"resource",
"path",
"will",
"return",
"resource",
"path",
"relative",
"to",
"the",
"base",
".",
"Also",
"replaces",
"Windows",
"forward",
"-",
"slash",
"with",
"a",
"backslash",
"."
] | 96ef47647629f49b15d3f8fca024fc567bcb358e | https://github.com/foru17/gulp-rev-custom-tag/blob/96ef47647629f49b15d3f8fca024fc567bcb358e/tool.js#L37-L64 | train | |
ksmithut/logget | index.js | Log | function Log(namespace) {
// If it's called without new, still return a new instance.
if (!(this instanceof Log)) { return new Log(namespace); }
// Configure Log if it hasn't already
if (!logger) { Log.configure(); }
// This gets all of the log levels and applies them to this
Object.keys(logger.levels).fo... | javascript | function Log(namespace) {
// If it's called without new, still return a new instance.
if (!(this instanceof Log)) { return new Log(namespace); }
// Configure Log if it hasn't already
if (!logger) { Log.configure(); }
// This gets all of the log levels and applies them to this
Object.keys(logger.levels).fo... | [
"function",
"Log",
"(",
"namespace",
")",
"{",
"// If it's called without new, still return a new instance.",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Log",
")",
")",
"{",
"return",
"new",
"Log",
"(",
"namespace",
")",
";",
"}",
"// Configure Log if it hasn't alr... | Log You create a new log by specifying a namespace. This basically only keeps track of the namepace prefix that goes into each log. If nothing is passed, then it doesn't prefix it with anything. | [
"Log",
"You",
"create",
"a",
"new",
"log",
"by",
"specifying",
"a",
"namespace",
".",
"This",
"basically",
"only",
"keeps",
"track",
"of",
"the",
"namepace",
"prefix",
"that",
"goes",
"into",
"each",
"log",
".",
"If",
"nothing",
"is",
"passed",
"then",
"... | b04ea84cb573fb2aef8e7d46589c94d5a0c085d4 | https://github.com/ksmithut/logget/blob/b04ea84cb573fb2aef8e7d46589c94d5a0c085d4/index.js#L31-L52 | train |
trekjs/utils | lib/pbkdf2.js | genSalt | function genSalt() {
var len = arguments[0] === undefined ? 16 : arguments[0];
var encoding = arguments[1] === undefined ? 'hex' : arguments[1];
return (0, _token2['default'])(len, encoding);
} | javascript | function genSalt() {
var len = arguments[0] === undefined ? 16 : arguments[0];
var encoding = arguments[1] === undefined ? 'hex' : arguments[1];
return (0, _token2['default'])(len, encoding);
} | [
"function",
"genSalt",
"(",
")",
"{",
"var",
"len",
"=",
"arguments",
"[",
"0",
"]",
"===",
"undefined",
"?",
"16",
":",
"arguments",
"[",
"0",
"]",
";",
"var",
"encoding",
"=",
"arguments",
"[",
"1",
"]",
"===",
"undefined",
"?",
"'hex'",
":",
"ar... | Generate a salt.
@method
@param {Number} len
@param {String} encoding
@return {Promise} by default 32 of slat length. | [
"Generate",
"a",
"salt",
"."
] | a6c7138ec7f7ccdff95df85c6662e7cefcd94eb0 | https://github.com/trekjs/utils/blob/a6c7138ec7f7ccdff95df85c6662e7cefcd94eb0/lib/pbkdf2.js#L29-L34 | train |
raineorshine/prefixnote | index.js | parse | function parse(str) {
// find the prefix expressions and the main value
var stringMatches = str.match(stringRegex)
var allExpString = stringMatches[1] || ''
var value = stringMatches[2]
// parse each prefix expression
var expressions = execAll(allExpressionsRegex, allExpString)
// grab the expression ... | javascript | function parse(str) {
// find the prefix expressions and the main value
var stringMatches = str.match(stringRegex)
var allExpString = stringMatches[1] || ''
var value = stringMatches[2]
// parse each prefix expression
var expressions = execAll(allExpressionsRegex, allExpString)
// grab the expression ... | [
"function",
"parse",
"(",
"str",
")",
"{",
"// find the prefix expressions and the main value",
"var",
"stringMatches",
"=",
"str",
".",
"match",
"(",
"stringRegex",
")",
"var",
"allExpString",
"=",
"stringMatches",
"[",
"1",
"]",
"||",
"''",
"var",
"value",
"="... | Parses a string with one or more prefixnote expressions. Extracts and parses each expression.
@returns { original, value, expressions } | [
"Parses",
"a",
"string",
"with",
"one",
"or",
"more",
"prefixnote",
"expressions",
".",
"Extracts",
"and",
"parses",
"each",
"expression",
"."
] | 83b56cbdd00f9221cf75f516249f9343d2561067 | https://github.com/raineorshine/prefixnote/blob/83b56cbdd00f9221cf75f516249f9343d2561067/index.js#L50-L68 | train |
redisjs/jsr-store | lib/command/string.js | set | function set(key, value /*, exflag, secs, pxflag, ms, xflag, req*/) {
var i
, arg
// expiry flag: EX | PX
, flag
// expiry value: number
, expiry
// exists flag: NX | XX
, xflag
// request object when available
, req;
for(i = 0;i < arguments.length;i++) {
arg = arguments[i];... | javascript | function set(key, value /*, exflag, secs, pxflag, ms, xflag, req*/) {
var i
, arg
// expiry flag: EX | PX
, flag
// expiry value: number
, expiry
// exists flag: NX | XX
, xflag
// request object when available
, req;
for(i = 0;i < arguments.length;i++) {
arg = arguments[i];... | [
"function",
"set",
"(",
"key",
",",
"value",
"/*, exflag, secs, pxflag, ms, xflag, req*/",
")",
"{",
"var",
"i",
",",
"arg",
"// expiry flag: EX | PX",
",",
"flag",
"// expiry value: number",
",",
"expiry",
"// exists flag: NX | XX",
",",
"xflag",
"// request object when ... | Set a key value pair.
When EX and PX are combined the last declaration wins. | [
"Set",
"a",
"key",
"value",
"pair",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L12-L36 | train |
redisjs/jsr-store | lib/command/string.js | setnx | function setnx(key, value, req) {
var res = this.setKey(
key, value, undefined, undefined, Constants.NX, req);
return res ? 1 : 0;
} | javascript | function setnx(key, value, req) {
var res = this.setKey(
key, value, undefined, undefined, Constants.NX, req);
return res ? 1 : 0;
} | [
"function",
"setnx",
"(",
"key",
",",
"value",
",",
"req",
")",
"{",
"var",
"res",
"=",
"this",
".",
"setKey",
"(",
"key",
",",
"value",
",",
"undefined",
",",
"undefined",
",",
"Constants",
".",
"NX",
",",
"req",
")",
";",
"return",
"res",
"?",
... | Set a key if it does not exist. | [
"Set",
"a",
"key",
"if",
"it",
"does",
"not",
"exist",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L41-L45 | train |
redisjs/jsr-store | lib/command/string.js | setex | function setex(key, secs, value, req) {
return this.setKey(
key, value, Constants.EX, secs, undefined, req);
} | javascript | function setex(key, secs, value, req) {
return this.setKey(
key, value, Constants.EX, secs, undefined, req);
} | [
"function",
"setex",
"(",
"key",
",",
"secs",
",",
"value",
",",
"req",
")",
"{",
"return",
"this",
".",
"setKey",
"(",
"key",
",",
"value",
",",
"Constants",
".",
"EX",
",",
"secs",
",",
"undefined",
",",
"req",
")",
";",
"}"
] | Set a key to expire in seconds. | [
"Set",
"a",
"key",
"to",
"expire",
"in",
"seconds",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L50-L53 | train |
redisjs/jsr-store | lib/command/string.js | psetex | function psetex(key, ms, value, req) {
return this.setKey(
key, value, Constants.PX, ms, undefined, req);
} | javascript | function psetex(key, ms, value, req) {
return this.setKey(
key, value, Constants.PX, ms, undefined, req);
} | [
"function",
"psetex",
"(",
"key",
",",
"ms",
",",
"value",
",",
"req",
")",
"{",
"return",
"this",
".",
"setKey",
"(",
"key",
",",
"value",
",",
"Constants",
".",
"PX",
",",
"ms",
",",
"undefined",
",",
"req",
")",
";",
"}"
] | Set a key to expire in milliseconds. | [
"Set",
"a",
"key",
"to",
"expire",
"in",
"milliseconds",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L58-L61 | train |
redisjs/jsr-store | lib/command/string.js | getset | function getset(key, value, req) {
var val = this.getKey(key, req);
this.setKey(key, value, undefined, undefined, undefined, req);
return val || null;
} | javascript | function getset(key, value, req) {
var val = this.getKey(key, req);
this.setKey(key, value, undefined, undefined, undefined, req);
return val || null;
} | [
"function",
"getset",
"(",
"key",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"this",
".",
"setKey",
"(",
"key",
",",
"value",
",",
"undefined",
",",
"undefined",
",",
"undefined",... | Set a key to value and retrieve the old value. | [
"Set",
"a",
"key",
"to",
"value",
"and",
"retrieve",
"the",
"old",
"value",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L77-L81 | train |
redisjs/jsr-store | lib/command/string.js | mset | function mset() {
var args = slice.call(arguments)
, req;
// got a req object
if(typeof args[args.length -1] === 'object') {
req = args.pop();
}
for(var i = 0;i < args.length;i += 2) {
this.setKey(args[i], args[i + 1], undefined, undefined, undefined, req);
}
return OK;
} | javascript | function mset() {
var args = slice.call(arguments)
, req;
// got a req object
if(typeof args[args.length -1] === 'object') {
req = args.pop();
}
for(var i = 0;i < args.length;i += 2) {
this.setKey(args[i], args[i + 1], undefined, undefined, undefined, req);
}
return OK;
} | [
"function",
"mset",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"req",
";",
"// got a req object",
"if",
"(",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
")",
"{",
"req",
... | Set multiple keys to multiple values. | [
"Set",
"multiple",
"keys",
"to",
"multiple",
"values",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L86-L100 | train |
redisjs/jsr-store | lib/command/string.js | msetnx | function msetnx() {
var args = slice.call(arguments)
, i
, req;
// got a req object
if(typeof args[args.length -1] === 'object') {
req = args.pop();
}
for(i = 0;i < args.length;i += 2) {
if(this.keyExists(args[i], req)) {
return 0;
}
}
for(i = 0;i < args.length;i += 2) {
t... | javascript | function msetnx() {
var args = slice.call(arguments)
, i
, req;
// got a req object
if(typeof args[args.length -1] === 'object') {
req = args.pop();
}
for(i = 0;i < args.length;i += 2) {
if(this.keyExists(args[i], req)) {
return 0;
}
}
for(i = 0;i < args.length;i += 2) {
t... | [
"function",
"msetnx",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"i",
",",
"req",
";",
"// got a req object",
"if",
"(",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
")",
... | Set multiple keys to multiple values only if none
of the keys already exist.
This is O(N^2) but redis is O(N), not sure how they do that. | [
"Set",
"multiple",
"keys",
"to",
"multiple",
"values",
"only",
"if",
"none",
"of",
"the",
"keys",
"already",
"exist",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L108-L129 | train |
redisjs/jsr-store | lib/command/string.js | mget | function mget() {
var args = slice.call(arguments)
, list = [];
// got a req object
if(typeof args[args.length -1] === 'object') {
args.pop();
}
for(var i = 0;i < args.length;i++) {
list.push(this.get(args[i]));
}
return list;
} | javascript | function mget() {
var args = slice.call(arguments)
, list = [];
// got a req object
if(typeof args[args.length -1] === 'object') {
args.pop();
}
for(var i = 0;i < args.length;i++) {
list.push(this.get(args[i]));
}
return list;
} | [
"function",
"mget",
"(",
")",
"{",
"var",
"args",
"=",
"slice",
".",
"call",
"(",
"arguments",
")",
",",
"list",
"=",
"[",
"]",
";",
"// got a req object",
"if",
"(",
"typeof",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"... | Get the values of all the given keys. | [
"Get",
"the",
"values",
"of",
"all",
"the",
"given",
"keys",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L135-L149 | train |
redisjs/jsr-store | lib/command/string.js | incrbyfloat | function incrbyfloat(key, amount, req) {
var val = utils.strtofloat(this.getKey(key, req));
amount = utils.strtofloat(amount);
val += amount;
this.setKey(key, val, undefined, undefined, undefined, req);
return val;
} | javascript | function incrbyfloat(key, amount, req) {
var val = utils.strtofloat(this.getKey(key, req));
amount = utils.strtofloat(amount);
val += amount;
this.setKey(key, val, undefined, undefined, undefined, req);
return val;
} | [
"function",
"incrbyfloat",
"(",
"key",
",",
"amount",
",",
"req",
")",
"{",
"var",
"val",
"=",
"utils",
".",
"strtofloat",
"(",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
")",
";",
"amount",
"=",
"utils",
".",
"strtofloat",
"(",
"amount",
... | Increment the float value of a key by the given amount. | [
"Increment",
"the",
"float",
"value",
"of",
"a",
"key",
"by",
"the",
"given",
"amount",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L154-L160 | train |
redisjs/jsr-store | lib/command/string.js | incrby | function incrby(key, amount, req) {
var val = utils.strtoint(this.getKey(key, req));
amount = utils.strtoint(amount);
val += amount;
this.setKey(key, val, undefined, undefined, undefined, req);
return val;
} | javascript | function incrby(key, amount, req) {
var val = utils.strtoint(this.getKey(key, req));
amount = utils.strtoint(amount);
val += amount;
this.setKey(key, val, undefined, undefined, undefined, req);
return val;
} | [
"function",
"incrby",
"(",
"key",
",",
"amount",
",",
"req",
")",
"{",
"var",
"val",
"=",
"utils",
".",
"strtoint",
"(",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
")",
";",
"amount",
"=",
"utils",
".",
"strtoint",
"(",
"amount",
")",
";... | Increment a key by an amount. | [
"Increment",
"a",
"key",
"by",
"an",
"amount",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L165-L171 | train |
redisjs/jsr-store | lib/command/string.js | append | function append(key, value, req) {
var val = this.getKey(key, req)
, str = typeof val === 'string';
// doesn't exist becomes the empty string
if(val === undefined) val = new Buffer('');
if(!(val instanceof Buffer)) val = new Buffer('' + val);
if(!(value instanceof Buffer)) value = new Buffer('' + value);
... | javascript | function append(key, value, req) {
var val = this.getKey(key, req)
, str = typeof val === 'string';
// doesn't exist becomes the empty string
if(val === undefined) val = new Buffer('');
if(!(val instanceof Buffer)) val = new Buffer('' + val);
if(!(value instanceof Buffer)) value = new Buffer('' + value);
... | [
"function",
"append",
"(",
"key",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"str",
"=",
"typeof",
"val",
"===",
"'string'",
";",
"// doesn't exist becomes the empty string",
"if",
"(",... | Append a value to a key. | [
"Append",
"a",
"value",
"to",
"a",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L201-L215 | train |
redisjs/jsr-store | lib/command/string.js | getrange | function getrange(key, start, end, req) {
var val = this.getKey(key, req);
if(!val) return '';
start = parseInt(start);
end = parseInt(end);
if(start < 0) start = val.length + start;
if(end < 0) end = val.length + end;
// TODO: buffer compat
return (val + '').substr(start, end + 1);
} | javascript | function getrange(key, start, end, req) {
var val = this.getKey(key, req);
if(!val) return '';
start = parseInt(start);
end = parseInt(end);
if(start < 0) start = val.length + start;
if(end < 0) end = val.length + end;
// TODO: buffer compat
return (val + '').substr(start, end + 1);
} | [
"function",
"getrange",
"(",
"key",
",",
"start",
",",
"end",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
";",
"if",
"(",
"!",
"val",
")",
"return",
"''",
";",
"start",
"=",
"parseInt",
"(",
"sta... | Get a substring of the string stored at a key. | [
"Get",
"a",
"substring",
"of",
"the",
"string",
"stored",
"at",
"a",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L220-L229 | train |
redisjs/jsr-store | lib/command/string.js | setrange | function setrange(key, offset, value, req) {
var val = this.getKey(key, req)
, str = typeof val === 'string'
, len
, buf;
if(val && !(val instanceof Buffer)) val = new Buffer(val);
if(typeof val === 'number') val = new Buffer('' + val);
if(typeof value === 'string') {
value = new Buffer(value);
... | javascript | function setrange(key, offset, value, req) {
var val = this.getKey(key, req)
, str = typeof val === 'string'
, len
, buf;
if(val && !(val instanceof Buffer)) val = new Buffer(val);
if(typeof val === 'number') val = new Buffer('' + val);
if(typeof value === 'string') {
value = new Buffer(value);
... | [
"function",
"setrange",
"(",
"key",
",",
"offset",
",",
"value",
",",
"req",
")",
"{",
"var",
"val",
"=",
"this",
".",
"getKey",
"(",
"key",
",",
"req",
")",
",",
"str",
"=",
"typeof",
"val",
"===",
"'string'",
",",
"len",
",",
"buf",
";",
"if",
... | Set a substring of the string stored at a key. | [
"Set",
"a",
"substring",
"of",
"the",
"string",
"stored",
"at",
"a",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L234-L271 | train |
redisjs/jsr-store | lib/command/string.js | getbit | function getbit(key, bitoffset, req) {
var buf = this.getValueBuffer(key, req)
, byte = bitoffset >> 3
, bit = 7 - (bitoffset & 0x7)
, bitval = 0;
if(buf === undefined) return 0;
if(byte < buf.length) {
bitval = buf[byte] & (1 << bit);
}
return bitval ? 1 : 0;
} | javascript | function getbit(key, bitoffset, req) {
var buf = this.getValueBuffer(key, req)
, byte = bitoffset >> 3
, bit = 7 - (bitoffset & 0x7)
, bitval = 0;
if(buf === undefined) return 0;
if(byte < buf.length) {
bitval = buf[byte] & (1 << bit);
}
return bitval ? 1 : 0;
} | [
"function",
"getbit",
"(",
"key",
",",
"bitoffset",
",",
"req",
")",
"{",
"var",
"buf",
"=",
"this",
".",
"getValueBuffer",
"(",
"key",
",",
"req",
")",
",",
"byte",
"=",
"bitoffset",
">>",
"3",
",",
"bit",
"=",
"7",
"-",
"(",
"bitoffset",
"&",
"... | Returns the bit value at offset in the string value stored at key. | [
"Returns",
"the",
"bit",
"value",
"at",
"offset",
"in",
"the",
"string",
"value",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L287-L297 | train |
redisjs/jsr-store | lib/command/string.js | bitpos | function bitpos(key, bit, start, end /* req */) {
var req = typeof arguments[arguments.length - 1] === 'object'
? arguments[arguments.length - 1] : null
, buf = this.getValueBuffer(key, req, true)
, i
, ind;
if(buf === undefined) buf = new Buffer('');
if(bit && !buf.length) return -1;
// got s... | javascript | function bitpos(key, bit, start, end /* req */) {
var req = typeof arguments[arguments.length - 1] === 'object'
? arguments[arguments.length - 1] : null
, buf = this.getValueBuffer(key, req, true)
, i
, ind;
if(buf === undefined) buf = new Buffer('');
if(bit && !buf.length) return -1;
// got s... | [
"function",
"bitpos",
"(",
"key",
",",
"bit",
",",
"start",
",",
"end",
"/* req */",
")",
"{",
"var",
"req",
"=",
"typeof",
"arguments",
"[",
"arguments",
".",
"length",
"-",
"1",
"]",
"===",
"'object'",
"?",
"arguments",
"[",
"arguments",
".",
"length... | Return the position of the first bit set to 1 or 0 in a string. | [
"Return",
"the",
"position",
"of",
"the",
"first",
"bit",
"set",
"to",
"1",
"or",
"0",
"in",
"a",
"string",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L362-L410 | train |
redisjs/jsr-store | lib/command/string.js | setbit | function setbit(key, offset, value, req) {
var buf = this.getValueBuffer(key, req, true)
, zeros
, pos
, shift
, byte
, bit;
if(buf === undefined) buf = new Buffer('');
pos = Math.floor(offset / 8);
bit = pos >= buf.length ? 0 : this.getbit(key, offset, req);
if(pos + 1 >= buf.length) {
... | javascript | function setbit(key, offset, value, req) {
var buf = this.getValueBuffer(key, req, true)
, zeros
, pos
, shift
, byte
, bit;
if(buf === undefined) buf = new Buffer('');
pos = Math.floor(offset / 8);
bit = pos >= buf.length ? 0 : this.getbit(key, offset, req);
if(pos + 1 >= buf.length) {
... | [
"function",
"setbit",
"(",
"key",
",",
"offset",
",",
"value",
",",
"req",
")",
"{",
"var",
"buf",
"=",
"this",
".",
"getValueBuffer",
"(",
"key",
",",
"req",
",",
"true",
")",
",",
"zeros",
",",
"pos",
",",
"shift",
",",
"byte",
",",
"bit",
";",... | Sets or clears the bit at offset in the string value stored at key. | [
"Sets",
"or",
"clears",
"the",
"bit",
"at",
"offset",
"in",
"the",
"string",
"value",
"stored",
"at",
"key",
"."
] | b2b5c5b0347819f8a388b5d67e121ee8d73f328c | https://github.com/redisjs/jsr-store/blob/b2b5c5b0347819f8a388b5d67e121ee8d73f328c/lib/command/string.js#L415-L439 | train |
loomio/router | docs/processors/markdown.js | graphvizualize | function graphvizualize(data, cb) {
var cp = exec('dot -Tsvg');
// buffer stdout
var buf = '';
cp.stdout.on('data', function (data) {
buf += data;
});
cp.on('error', function () {});
cp.on('close', function (code) {
cb(null, code > 0 ? '' : buf);
});
// set dot to stdin
cp.stdin.end(data);... | javascript | function graphvizualize(data, cb) {
var cp = exec('dot -Tsvg');
// buffer stdout
var buf = '';
cp.stdout.on('data', function (data) {
buf += data;
});
cp.on('error', function () {});
cp.on('close', function (code) {
cb(null, code > 0 ? '' : buf);
});
// set dot to stdin
cp.stdin.end(data);... | [
"function",
"graphvizualize",
"(",
"data",
",",
"cb",
")",
"{",
"var",
"cp",
"=",
"exec",
"(",
"'dot -Tsvg'",
")",
";",
"// buffer stdout",
"var",
"buf",
"=",
"''",
";",
"cp",
".",
"stdout",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"data",
")"... | make a graphviz thing | [
"make",
"a",
"graphviz",
"thing"
] | 4af3b95674216b6a415b802322f5e44b78351d06 | https://github.com/loomio/router/blob/4af3b95674216b6a415b802322f5e44b78351d06/docs/processors/markdown.js#L109-L124 | train |
willemdewit/java.properties.js | dist/systemjs/main.js | parseLines | function parseLines(lines) {
var propertyMap = {};
lines.forEach(function (line) {
var parsed = parseLine(line);
if (!parsed) {
throw new Error('Cannot parse line: ', line);
}
propertyMap[parsed[1]] = parsed[2];
});
return p... | javascript | function parseLines(lines) {
var propertyMap = {};
lines.forEach(function (line) {
var parsed = parseLine(line);
if (!parsed) {
throw new Error('Cannot parse line: ', line);
}
propertyMap[parsed[1]] = parsed[2];
});
return p... | [
"function",
"parseLines",
"(",
"lines",
")",
"{",
"var",
"propertyMap",
"=",
"{",
"}",
";",
"lines",
".",
"forEach",
"(",
"function",
"(",
"line",
")",
"{",
"var",
"parsed",
"=",
"parseLine",
"(",
"line",
")",
";",
"if",
"(",
"!",
"parsed",
")",
"{... | Parses the lines add adds the key-values to the return object
@param lines {String[]}
@returns {{}} the parsed key-value pairs | [
"Parses",
"the",
"lines",
"add",
"adds",
"the",
"key",
"-",
"values",
"to",
"the",
"return",
"object"
] | dfd733f74e8bc0d196a7238caf92bdae07a80aa5 | https://github.com/willemdewit/java.properties.js/blob/dfd733f74e8bc0d196a7238caf92bdae07a80aa5/dist/systemjs/main.js#L169-L179 | train |
willemdewit/java.properties.js | dist/systemjs/main.js | parseValues | function parseValues(obj) {
Object.keys(obj).forEach(function (key) {
obj[key] = parseValue(obj[key]);
});
return obj;
} | javascript | function parseValues(obj) {
Object.keys(obj).forEach(function (key) {
obj[key] = parseValue(obj[key]);
});
return obj;
} | [
"function",
"parseValues",
"(",
"obj",
")",
"{",
"Object",
".",
"keys",
"(",
"obj",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"parseValue",
"(",
"obj",
"[",
"key",
"]",
")",
";",
"}",
")",
";",
"re... | Loops over the object values and tries to parse them to a native value.
@param obj
@returns {Object} the same object as the argument | [
"Loops",
"over",
"the",
"object",
"values",
"and",
"tries",
"to",
"parse",
"them",
"to",
"a",
"native",
"value",
"."
] | dfd733f74e8bc0d196a7238caf92bdae07a80aa5 | https://github.com/willemdewit/java.properties.js/blob/dfd733f74e8bc0d196a7238caf92bdae07a80aa5/dist/systemjs/main.js#L186-L191 | train |
gilt/node-jasmine-phantomjs | jasmine-phantomjs.js | function () {
try {
// we're creating a simple reporter to:
// 1. track stats on the specs run
// 2. mimic a 'finished' callback
function FinishedReporter () {
this.total = this.passed = this.failed = 0;
}
FinishedReporter.prototype = {
report... | javascript | function () {
try {
// we're creating a simple reporter to:
// 1. track stats on the specs run
// 2. mimic a 'finished' callback
function FinishedReporter () {
this.total = this.passed = this.failed = 0;
}
FinishedReporter.prototype = {
report... | [
"function",
"(",
")",
"{",
"try",
"{",
"// we're creating a simple reporter to:",
"// 1. track stats on the specs run",
"// 2. mimic a 'finished' callback",
"function",
"FinishedReporter",
"(",
")",
"{",
"this",
".",
"total",
"=",
"this",
".",
"passed",
"=",
"this",
"."... | this runs in the context of a phantomjs page. | [
"this",
"runs",
"in",
"the",
"context",
"of",
"a",
"phantomjs",
"page",
"."
] | 8c8ecf116240b9b247f2c68d8ed32d8cf985f67e | https://github.com/gilt/node-jasmine-phantomjs/blob/8c8ecf116240b9b247f2c68d8ed32d8cf985f67e/jasmine-phantomjs.js#L234-L280 | train | |
andrewscwei/requiem | src/dom/addToChildRegistry.js | addToChildRegistry | function addToChildRegistry(childRegistry, child, name) {
assertType(childRegistry, 'object', false, 'Invalid child registry specified');
assertType(child, [Node, Array], false, 'Invalid child(ren) specified');
assertType(name, 'string', true, 'Invalid name specified');
let inferredName = getInstanceNameFromEl... | javascript | function addToChildRegistry(childRegistry, child, name) {
assertType(childRegistry, 'object', false, 'Invalid child registry specified');
assertType(child, [Node, Array], false, 'Invalid child(ren) specified');
assertType(name, 'string', true, 'Invalid name specified');
let inferredName = getInstanceNameFromEl... | [
"function",
"addToChildRegistry",
"(",
"childRegistry",
",",
"child",
",",
"name",
")",
"{",
"assertType",
"(",
"childRegistry",
",",
"'object'",
",",
"false",
",",
"'Invalid child registry specified'",
")",
";",
"assertType",
"(",
"child",
",",
"[",
"Node",
","... | Adds a child or an array of children with the same name to the specified
child registry.
@param {Object} childRegistry - The child registry.
@param {Node|Array} child - Either one child element or an array of multiple
child elements with the same name.
@param {string} [name] - Name of the child(ren).
@return {boolean... | [
"Adds",
"a",
"child",
"or",
"an",
"array",
"of",
"children",
"with",
"the",
"same",
"name",
"to",
"the",
"specified",
"child",
"registry",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/addToChildRegistry.js#L24-L45 | train |
cronvel/meta-pdf | lib/PdfRenderer.js | renderPdf | function renderPdf( runtime , data ) {
prepareRenderPdf( runtime , data ) ;
runtime.pendingPdfCommands.push( data ) ;
} | javascript | function renderPdf( runtime , data ) {
prepareRenderPdf( runtime , data ) ;
runtime.pendingPdfCommands.push( data ) ;
} | [
"function",
"renderPdf",
"(",
"runtime",
",",
"data",
")",
"{",
"prepareRenderPdf",
"(",
"runtime",
",",
"data",
")",
";",
"runtime",
".",
"pendingPdfCommands",
".",
"push",
"(",
"data",
")",
";",
"}"
] | It delays most pdf commands to get more context | [
"It",
"delays",
"most",
"pdf",
"commands",
"to",
"get",
"more",
"context"
] | 5e939e5895aef94ac31d331b7d3950494975d87e | https://github.com/cronvel/meta-pdf/blob/5e939e5895aef94ac31d331b7d3950494975d87e/lib/PdfRenderer.js#L226-L229 | train |
skerit/hawkejs | lib/element/custom_element.js | ElementConstructor | function ElementConstructor() {
var attr,
i;
// Trigger an initial attribute change
for (i = 0; i < this.attributes.length; i++) {
attr = this.attributes[i];
this.attributeChangedCallback(attr.name, null, attr.value, true);
}
} | javascript | function ElementConstructor() {
var attr,
i;
// Trigger an initial attribute change
for (i = 0; i < this.attributes.length; i++) {
attr = this.attributes[i];
this.attributeChangedCallback(attr.name, null, attr.value, true);
}
} | [
"function",
"ElementConstructor",
"(",
")",
"{",
"var",
"attr",
",",
"i",
";",
"// Trigger an initial attribute change",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"attributes",
".",
"length",
";",
"i",
"++",
")",
"{",
"attr",
"=",
"this",
... | Base element constructor
@author Jelle De Loecker <jelle@develry.be>
@since 1.1.0
@version 2.0.0 | [
"Base",
"element",
"constructor"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/element/custom_element.js#L19-L29 | train |
skerit/hawkejs | lib/element/custom_element.js | getPrivate | function getPrivate(instance) {
var map = weak_properties.get(instance);
if (!map) {
map = {
// Attribute configurations
attributes : {},
// Attribute values for use in property getters
prop_values : {},
// Attribute string values
values : {},
// New values that are beign set
new_... | javascript | function getPrivate(instance) {
var map = weak_properties.get(instance);
if (!map) {
map = {
// Attribute configurations
attributes : {},
// Attribute values for use in property getters
prop_values : {},
// Attribute string values
values : {},
// New values that are beign set
new_... | [
"function",
"getPrivate",
"(",
"instance",
")",
"{",
"var",
"map",
"=",
"weak_properties",
".",
"get",
"(",
"instance",
")",
";",
"if",
"(",
"!",
"map",
")",
"{",
"map",
"=",
"{",
"// Attribute configurations",
"attributes",
":",
"{",
"}",
",",
"// Attri... | Create a private variable for the given instance
@author Jelle De Loecker <jelle@develry.be>
@since 1.1.1
@version 1.1.1
@param {Element} instance
@return {Object} | [
"Create",
"a",
"private",
"variable",
"for",
"the",
"given",
"instance"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/element/custom_element.js#L80-L103 | train |
skerit/hawkejs | lib/element/custom_element.js | renderCustomTemplate | function renderCustomTemplate() {
var that = this,
child,
vars = {},
i;
for (i = 0; i < this.children.length; i++) {
child = this.children[i];
if (!child.getAttribute) {
continue;
}
if (child.getAttribute('slot')) {
vars[child.getAttribute('slot')] = child;
}
}
Hawkejs.removeChil... | javascript | function renderCustomTemplate() {
var that = this,
child,
vars = {},
i;
for (i = 0; i < this.children.length; i++) {
child = this.children[i];
if (!child.getAttribute) {
continue;
}
if (child.getAttribute('slot')) {
vars[child.getAttribute('slot')] = child;
}
}
Hawkejs.removeChil... | [
"function",
"renderCustomTemplate",
"(",
")",
"{",
"var",
"that",
"=",
"this",
",",
"child",
",",
"vars",
"=",
"{",
"}",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
... | The custom template render function
@author Jelle De Loecker <jelle@develry.be>
@since 2.0.0
@version 2.0.0 | [
"The",
"custom",
"template",
"render",
"function"
] | 15ed7205183ac2c425362deb8c0796c0d16b898a | https://github.com/skerit/hawkejs/blob/15ed7205183ac2c425362deb8c0796c0d16b898a/lib/element/custom_element.js#L546-L598 | train |
redisjs/jsr-server | lib/command/server/flushdb.js | execute | function execute(req, res) {
// TODO: ensure a conflict is triggered on all watched keys
req.db.flushdb();
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
// TODO: ensure a conflict is triggered on all watched keys
req.db.flushdb();
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// TODO: ensure a conflict is triggered on all watched keys",
"req",
".",
"db",
".",
"flushdb",
"(",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the FLUSHDB command. | [
"Respond",
"to",
"the",
"FLUSHDB",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/flushdb.js#L17-L21 | train |
integreat-io/great-uri-template | lib/filters/wrap.js | wrap | function wrap (value, ...parts) {
if (value === null || value === undefined || value === '' || parts.length < 2) {
return value
}
if (parts.length >= 4) {
return parts[0] + [].concat(value).map((val) => parts[1] + val + parts[2]) + parts[3]
}
return parts[0] + value + parts[1]
} | javascript | function wrap (value, ...parts) {
if (value === null || value === undefined || value === '' || parts.length < 2) {
return value
}
if (parts.length >= 4) {
return parts[0] + [].concat(value).map((val) => parts[1] + val + parts[2]) + parts[3]
}
return parts[0] + value + parts[1]
} | [
"function",
"wrap",
"(",
"value",
",",
"...",
"parts",
")",
"{",
"if",
"(",
"value",
"===",
"null",
"||",
"value",
"===",
"undefined",
"||",
"value",
"===",
"''",
"||",
"parts",
".",
"length",
"<",
"2",
")",
"{",
"return",
"value",
"}",
"if",
"(",
... | Wrap the value with the strings provided in args.
If the value is an array, two parts will wrap the entire result, while four
parts will also wrap each element. With four parts and no array, the value
will be wrapped as an array with one element.
@param {string} value - The value to wrap
@param {string[]} parts - Array... | [
"Wrap",
"the",
"value",
"with",
"the",
"strings",
"provided",
"in",
"args",
".",
"If",
"the",
"value",
"is",
"an",
"array",
"two",
"parts",
"will",
"wrap",
"the",
"entire",
"result",
"while",
"four",
"parts",
"will",
"also",
"wrap",
"each",
"element",
".... | 0e896ead0567737cf31a4a8b76a26cfa6ce60759 | https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/wrap.js#L10-L20 | train |
chrisJohn404/ljswitchboard-device_scanner | lib/open_all_device_scanner.js | getOnError | function getOnError (msg) {
return function getLastFoundDevicesErrorHandler (err) {
console.error('An Error', err, msg, err.stack);
var errDefered = q.defer();
errDefered.reject(err);
return errDefered.promise;
};
} | javascript | function getOnError (msg) {
return function getLastFoundDevicesErrorHandler (err) {
console.error('An Error', err, msg, err.stack);
var errDefered = q.defer();
errDefered.reject(err);
return errDefered.promise;
};
} | [
"function",
"getOnError",
"(",
"msg",
")",
"{",
"return",
"function",
"getLastFoundDevicesErrorHandler",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"'An Error'",
",",
"err",
",",
"msg",
",",
"err",
".",
"stack",
")",
";",
"var",
"errDefered",
"=",... | Define an error handling function. | [
"Define",
"an",
"error",
"handling",
"function",
"."
] | 9a8f0936387bfedc09ab1b2d655cecf79ad15a6b | https://github.com/chrisJohn404/ljswitchboard-device_scanner/blob/9a8f0936387bfedc09ab1b2d655cecf79ad15a6b/lib/open_all_device_scanner.js#L1911-L1918 | train |
cemtopkaya/kuark-db | lib/cem.js | f_temp_sil_kurum | function f_temp_sil_kurum(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKurum(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKurumIstenmeyen(_tahta_id))
].allX();
}
else {
return null;
}
} | javascript | function f_temp_sil_kurum(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKurum(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKurumIstenmeyen(_tahta_id))
].allX();
}
else {
return null;
}
} | [
"function",
"f_temp_sil_kurum",
"(",
"_tahta_id",
")",
"{",
"if",
"(",
"_tahta_id",
")",
"{",
"return",
"[",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"ssetTahtaKurum",
"(",
"_tahta_id",
")",
")... | endregion region KURUM | [
"endregion",
"region",
"KURUM"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L119-L130 | train |
cemtopkaya/kuark-db | lib/cem.js | f_temp_sil_kalem | function f_temp_sil_kalem(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalem(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalemTumu(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalemIstenmeyen(_tahta_id)),
... | javascript | function f_temp_sil_kalem(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalem(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalemTumu(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKalemIstenmeyen(_tahta_id)),
... | [
"function",
"f_temp_sil_kalem",
"(",
"_tahta_id",
")",
"{",
"if",
"(",
"_tahta_id",
")",
"{",
"return",
"[",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"ssetTahtaKalem",
"(",
"_tahta_id",
")",
")... | endregion region KALEM | [
"endregion",
"region",
"KALEM"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L414-L425 | train |
cemtopkaya/kuark-db | lib/cem.js | f_temp_sil_anahtar | function f_temp_sil_anahtar(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaIhale(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaAnahtarIhaleleri(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.zsetTahtaIhaleSiraliIhaleTarihi... | javascript | function f_temp_sil_anahtar(_tahta_id) {
if (_tahta_id) {
return [
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaIhale(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaAnahtarIhaleleri(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.zsetTahtaIhaleSiraliIhaleTarihi... | [
"function",
"f_temp_sil_anahtar",
"(",
"_tahta_id",
")",
"{",
"if",
"(",
"_tahta_id",
")",
"{",
"return",
"[",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"ssetTahtaIhale",
"(",
"_tahta_id",
")",
... | endregion region TAHTA ANAHTAR | [
"endregion",
"region",
"TAHTA",
"ANAHTAR"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L751-L762 | train |
cemtopkaya/kuark-db | lib/cem.js | f_provider_raw_sil | function f_provider_raw_sil(_kullanici) {
//hata almamak için elastic e eklemeden önce providers içindeki raw bilgisi siliniyor
if (_kullanici.Providers.GP) {
delete _kullanici.Providers.GP.raw;
} else if (_kullanici.Providers.TW) {
delete _kullanici.Providers.TW.raw;
} else if (_k... | javascript | function f_provider_raw_sil(_kullanici) {
//hata almamak için elastic e eklemeden önce providers içindeki raw bilgisi siliniyor
if (_kullanici.Providers.GP) {
delete _kullanici.Providers.GP.raw;
} else if (_kullanici.Providers.TW) {
delete _kullanici.Providers.TW.raw;
} else if (_k... | [
"function",
"f_provider_raw_sil",
"(",
"_kullanici",
")",
"{",
"//hata almamak için elastic e eklemeden önce providers içindeki raw bilgisi siliniyor\r",
"if",
"(",
"_kullanici",
".",
"Providers",
".",
"GP",
")",
"{",
"delete",
"_kullanici",
".",
"Providers",
".",
"GP",
"... | endregion region KULLANICI | [
"endregion",
"region",
"KULLANICI"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L790-L799 | train |
cemtopkaya/kuark-db | lib/cem.js | f_temp_sil_tahta | function f_temp_sil_tahta(_tahta_id) {
return db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKullanici(_tahta_id));
} | javascript | function f_temp_sil_tahta(_tahta_id) {
return db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaKullanici(_tahta_id));
} | [
"function",
"f_temp_sil_tahta",
"(",
"_tahta_id",
")",
"{",
"return",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"ssetTahtaKullanici",
"(",
"_tahta_id",
")",
")",
";",
"}"
] | endregion region TAHTA | [
"endregion",
"region",
"TAHTA"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L872-L874 | train |
AtlasIQ/makedeb | index.js | getTempBuildDir | function getTempBuildDir(packageName, version) {
return temp.mkdirAsync('makdeb')
.then(function(tempDir) {
return path.join(tempDir, packageName +'-'+ version);
});
} | javascript | function getTempBuildDir(packageName, version) {
return temp.mkdirAsync('makdeb')
.then(function(tempDir) {
return path.join(tempDir, packageName +'-'+ version);
});
} | [
"function",
"getTempBuildDir",
"(",
"packageName",
",",
"version",
")",
"{",
"return",
"temp",
".",
"mkdirAsync",
"(",
"'makdeb'",
")",
".",
"then",
"(",
"function",
"(",
"tempDir",
")",
"{",
"return",
"path",
".",
"join",
"(",
"tempDir",
",",
"packageName... | Returns a temporary directory in the required "packageName-version" format. | [
"Returns",
"a",
"temporary",
"directory",
"in",
"the",
"required",
"packageName",
"-",
"version",
"format",
"."
] | 017719bc0e0d3594a05d7b30af2430c635e49363 | https://github.com/AtlasIQ/makedeb/blob/017719bc0e0d3594a05d7b30af2430c635e49363/index.js#L90-L95 | train |
AtlasIQ/makedeb | index.js | tarDir | function tarDir(dir) {
var archiveName = path.basename(dir) +'.orig.tar.xz';
var archivePath = path.join(path.dirname(dir), archiveName);
return exec('tar cfJ '+ archivePath +' '+ dir);
} | javascript | function tarDir(dir) {
var archiveName = path.basename(dir) +'.orig.tar.xz';
var archivePath = path.join(path.dirname(dir), archiveName);
return exec('tar cfJ '+ archivePath +' '+ dir);
} | [
"function",
"tarDir",
"(",
"dir",
")",
"{",
"var",
"archiveName",
"=",
"path",
".",
"basename",
"(",
"dir",
")",
"+",
"'.orig.tar.xz'",
";",
"var",
"archivePath",
"=",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"dir",
")",
",",
"archiveName... | Uses tar to create an xz archive of a directory and writes it to its parent dir. | [
"Uses",
"tar",
"to",
"create",
"an",
"xz",
"archive",
"of",
"a",
"directory",
"and",
"writes",
"it",
"to",
"its",
"parent",
"dir",
"."
] | 017719bc0e0d3594a05d7b30af2430c635e49363 | https://github.com/AtlasIQ/makedeb/blob/017719bc0e0d3594a05d7b30af2430c635e49363/index.js#L99-L104 | train |
AtlasIQ/makedeb | index.js | writeDebianFiles | function writeDebianFiles(tempBuildDir, options) {
var debianDir = path.join(tempBuildDir, 'DEBIAN');
return fse.ensureDirAsync(debianDir)
.then(function() {
// Read the control file template.
return fse.readFileAsync(path.join(TEMPLATE_FILES_DIR, 'control.tmpl'), 'utf8');
})
.then(... | javascript | function writeDebianFiles(tempBuildDir, options) {
var debianDir = path.join(tempBuildDir, 'DEBIAN');
return fse.ensureDirAsync(debianDir)
.then(function() {
// Read the control file template.
return fse.readFileAsync(path.join(TEMPLATE_FILES_DIR, 'control.tmpl'), 'utf8');
})
.then(... | [
"function",
"writeDebianFiles",
"(",
"tempBuildDir",
",",
"options",
")",
"{",
"var",
"debianDir",
"=",
"path",
".",
"join",
"(",
"tempBuildDir",
",",
"'DEBIAN'",
")",
";",
"return",
"fse",
".",
"ensureDirAsync",
"(",
"debianDir",
")",
".",
"then",
"(",
"f... | Write the required files into the DEBIAN directory. | [
"Write",
"the",
"required",
"files",
"into",
"the",
"DEBIAN",
"directory",
"."
] | 017719bc0e0d3594a05d7b30af2430c635e49363 | https://github.com/AtlasIQ/makedeb/blob/017719bc0e0d3594a05d7b30af2430c635e49363/index.js#L107-L121 | train |
derdesign/protos | middleware/logger/logger.js | function() {
var data, json, log = accessLogFormat.call(self, this.request, this, app);
if (format == 'json') {
log = app.applyFilters('access_log_data', log, this.request, app);
json = JSON.stringify(log);
data = [log, json]; // msg (object), log (text)
app.emit('access_log', json, data... | javascript | function() {
var data, json, log = accessLogFormat.call(self, this.request, this, app);
if (format == 'json') {
log = app.applyFilters('access_log_data', log, this.request, app);
json = JSON.stringify(log);
data = [log, json]; // msg (object), log (text)
app.emit('access_log', json, data... | [
"function",
"(",
")",
"{",
"var",
"data",
",",
"json",
",",
"log",
"=",
"accessLogFormat",
".",
"call",
"(",
"self",
",",
"this",
".",
"request",
",",
"this",
",",
"app",
")",
";",
"if",
"(",
"format",
"==",
"'json'",
")",
"{",
"log",
"=",
"app",... | Access Log Callback | [
"Access",
"Log",
"Callback"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/logger/logger.js#L176-L187 | train | |
bobholt/ampersand-jsonapi-model | bin/ampersand-jsonapi-model.js | _initCollections | function _initCollections() {
if (!this._collections) {
return;
}
for (var coll in this._collections) {
this[coll] = new this._collections[coll](null, { parent: this, parse: true });
}
} | javascript | function _initCollections() {
if (!this._collections) {
return;
}
for (var coll in this._collections) {
this[coll] = new this._collections[coll](null, { parent: this, parse: true });
}
} | [
"function",
"_initCollections",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_collections",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"coll",
"in",
"this",
".",
"_collections",
")",
"{",
"this",
"[",
"coll",
"]",
"=",
"new",
"this",
".",
"_c... | Initializes collections as type defined in model definition.
@method _initCollections
@memberof JSONAPIModel
@instance
@private
@returns {Object} An instance of the collection type | [
"Initializes",
"collections",
"as",
"type",
"defined",
"in",
"model",
"definition",
"."
] | 9d67d4ce40272046c672d5cf3b391a63fff67a29 | https://github.com/bobholt/ampersand-jsonapi-model/blob/9d67d4ce40272046c672d5cf3b391a63fff67a29/bin/ampersand-jsonapi-model.js#L105-L113 | train |
bobholt/ampersand-jsonapi-model | bin/ampersand-jsonapi-model.js | _initChildren | function _initChildren() {
if (!this._children) {
return;
}
for (var child in this._children) {
var childAttrs = this._attrs && this._attrs[child] ? this._attrs[child] : {};
this[child] = new this._children[child](childAttrs, { parent: this, parse: true });
this.listenTo(this[child],... | javascript | function _initChildren() {
if (!this._children) {
return;
}
for (var child in this._children) {
var childAttrs = this._attrs && this._attrs[child] ? this._attrs[child] : {};
this[child] = new this._children[child](childAttrs, { parent: this, parse: true });
this.listenTo(this[child],... | [
"function",
"_initChildren",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_children",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"child",
"in",
"this",
".",
"_children",
")",
"{",
"var",
"childAttrs",
"=",
"this",
".",
"_attrs",
"&&",
"this",
... | Initializes child models as type defined in model definition.
@method _initChildren
@memberof JSONAPIModel
@instance
@private
@returns {Object} An instance of the child model type | [
"Initializes",
"child",
"models",
"as",
"type",
"defined",
"in",
"model",
"definition",
"."
] | 9d67d4ce40272046c672d5cf3b391a63fff67a29 | https://github.com/bobholt/ampersand-jsonapi-model/blob/9d67d4ce40272046c672d5cf3b391a63fff67a29/bin/ampersand-jsonapi-model.js#L123-L132 | train |
bobholt/ampersand-jsonapi-model | bin/ampersand-jsonapi-model.js | getAttributes | function getAttributes(opts, raw) {
var options = (0, _lodash2.default)({
session: false,
props: false,
derived: false,
children: true,
collections: true
}, opts || {});
var res = {};
for (var item in this._definition) {
var def = this._definition[item];
if (opt... | javascript | function getAttributes(opts, raw) {
var options = (0, _lodash2.default)({
session: false,
props: false,
derived: false,
children: true,
collections: true
}, opts || {});
var res = {};
for (var item in this._definition) {
var def = this._definition[item];
if (opt... | [
"function",
"getAttributes",
"(",
"opts",
",",
"raw",
")",
"{",
"var",
"options",
"=",
"(",
"0",
",",
"_lodash2",
".",
"default",
")",
"(",
"{",
"session",
":",
"false",
",",
"props",
":",
"false",
",",
"derived",
":",
"false",
",",
"children",
":",
... | Returns model and associated children and collections as a plain
object.
@method getAttributes
@memberof JSONAPIModel
@instance
@override
@param {Object} opts - The options for getAttributes.
@param {Boolean} raw - Specifies whether returned values should be
the raw value or should instead use the
getter associated wit... | [
"Returns",
"model",
"and",
"associated",
"children",
"and",
"collections",
"as",
"a",
"plain",
"object",
"."
] | 9d67d4ce40272046c672d5cf3b391a63fff67a29 | https://github.com/bobholt/ampersand-jsonapi-model/blob/9d67d4ce40272046c672d5cf3b391a63fff67a29/bin/ampersand-jsonapi-model.js#L147-L186 | train |
bobholt/ampersand-jsonapi-model | bin/ampersand-jsonapi-model.js | parse | function parse(data) {
// If this comes from a collection, there won't be a data property.
// If it comes from querying the model API directly, it will.
if (!data || !data.data && !data.id) {
return {};
}
var model = data.data ? data.data : data;
/** The attributes on the model. */
... | javascript | function parse(data) {
// If this comes from a collection, there won't be a data property.
// If it comes from querying the model API directly, it will.
if (!data || !data.data && !data.id) {
return {};
}
var model = data.data ? data.data : data;
/** The attributes on the model. */
... | [
"function",
"parse",
"(",
"data",
")",
"{",
"// If this comes from a collection, there won't be a data property.",
"// If it comes from querying the model API directly, it will.",
"if",
"(",
"!",
"data",
"||",
"!",
"data",
".",
"data",
"&&",
"!",
"data",
".",
"id",
")",
... | Parses the server response into a format which Ampersand Models
expect. Called when collection is initialized.
@method parse
@memberof JSONAPIModel
@instance
@override
@param {Object} data - The data received from the server.
@returns {Object} The transformed model. | [
"Parses",
"the",
"server",
"response",
"into",
"a",
"format",
"which",
"Ampersand",
"Models",
"expect",
".",
"Called",
"when",
"collection",
"is",
"initialized",
"."
] | 9d67d4ce40272046c672d5cf3b391a63fff67a29 | https://github.com/bobholt/ampersand-jsonapi-model/blob/9d67d4ce40272046c672d5cf3b391a63fff67a29/bin/ampersand-jsonapi-model.js#L198-L219 | train |
bobholt/ampersand-jsonapi-model | bin/ampersand-jsonapi-model.js | save | function save(key, val, opts) {
var _this = this;
var options = {};
var attrs = {};
var method = '';
var sync = null;
function wrapError(model, modelOptions) {
var error = modelOptions.error;
modelOptions.error = function (resp) {
if (error) {
error(model, resp, m... | javascript | function save(key, val, opts) {
var _this = this;
var options = {};
var attrs = {};
var method = '';
var sync = null;
function wrapError(model, modelOptions) {
var error = modelOptions.error;
modelOptions.error = function (resp) {
if (error) {
error(model, resp, m... | [
"function",
"save",
"(",
"key",
",",
"val",
",",
"opts",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"var",
"options",
"=",
"{",
"}",
";",
"var",
"attrs",
"=",
"{",
"}",
";",
"var",
"method",
"=",
"''",
";",
"var",
"sync",
"=",
"null",
";",
"... | Saves a model to the persistence layer by delegating to
ampersand-sync.
@method save
@memberof JSONAPIModel
@instance
@override
@param {String|Object} key - If a string: the property of the model
to change. If an object: the
properties of the model to change as
`{key: value}`
@param {*|Object} val - If `key` is a strin... | [
"Saves",
"a",
"model",
"to",
"the",
"persistence",
"layer",
"by",
"delegating",
"to",
"ampersand",
"-",
"sync",
"."
] | 9d67d4ce40272046c672d5cf3b391a63fff67a29 | https://github.com/bobholt/ampersand-jsonapi-model/blob/9d67d4ce40272046c672d5cf3b391a63fff67a29/bin/ampersand-jsonapi-model.js#L241-L326 | train |
bobholt/ampersand-jsonapi-model | bin/ampersand-jsonapi-model.js | serialize | function serialize() {
var _this2 = this;
var res = this.getAttributes({
props: true,
children: false,
collections: false
}, true);
var id = res.id;
var relationships = {};
(0, _lodash4.default)(this._children, function (value, key) {
relationships[key] = {
data... | javascript | function serialize() {
var _this2 = this;
var res = this.getAttributes({
props: true,
children: false,
collections: false
}, true);
var id = res.id;
var relationships = {};
(0, _lodash4.default)(this._children, function (value, key) {
relationships[key] = {
data... | [
"function",
"serialize",
"(",
")",
"{",
"var",
"_this2",
"=",
"this",
";",
"var",
"res",
"=",
"this",
".",
"getAttributes",
"(",
"{",
"props",
":",
"true",
",",
"children",
":",
"false",
",",
"collections",
":",
"false",
"}",
",",
"true",
")",
";",
... | Serializes the model into a format which the JSON-API server
expects.
@method serialize
@memberof JSONAPIModel
@instance
@override
@returns {Object} The JSON-API-formatted model. | [
"Serializes",
"the",
"model",
"into",
"a",
"format",
"which",
"the",
"JSON",
"-",
"API",
"server",
"expects",
"."
] | 9d67d4ce40272046c672d5cf3b391a63fff67a29 | https://github.com/bobholt/ampersand-jsonapi-model/blob/9d67d4ce40272046c672d5cf3b391a63fff67a29/bin/ampersand-jsonapi-model.js#L337-L367 | train |
tolokoban/ToloFrameWork | ker/mod/wdg.modal.js | onScroll | function onScroll(body, evt) {
if (body.scrollTop > 0) {
$.addClass(body, "top");
} else {
$.removeClass(body, "top");
}
if (body.scrollHeight - body.scrollTop > body.clientHeight) {
$.addClass(body, "bottom");
} else {
$.removeClass(body, "bottom");
}
} | javascript | function onScroll(body, evt) {
if (body.scrollTop > 0) {
$.addClass(body, "top");
} else {
$.removeClass(body, "top");
}
if (body.scrollHeight - body.scrollTop > body.clientHeight) {
$.addClass(body, "bottom");
} else {
$.removeClass(body, "bottom");
}
} | [
"function",
"onScroll",
"(",
"body",
",",
"evt",
")",
"{",
"if",
"(",
"body",
".",
"scrollTop",
">",
"0",
")",
"{",
"$",
".",
"addClass",
"(",
"body",
",",
"\"top\"",
")",
";",
"}",
"else",
"{",
"$",
".",
"removeClass",
"(",
"body",
",",
"\"top\"... | Help the user to understand that the `body` can or cannot scroll to
the top or to the bottom, or both.
If the user can scroll up, a thin top inset shadow is displayed.
If the user can scroll down, a thin bottom inset shadow is displayed. | [
"Help",
"the",
"user",
"to",
"understand",
"that",
"the",
"body",
"can",
"or",
"cannot",
"scroll",
"to",
"the",
"top",
"or",
"to",
"the",
"bottom",
"or",
"both",
".",
"If",
"the",
"user",
"can",
"scroll",
"up",
"a",
"thin",
"top",
"inset",
"shadow",
... | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.modal.js#L261-L273 | train |
openmason/panda-lang | lib/panda.js | function(ast, source) {
if(!ast) return;
for(var i=0;i<ast.length;i++) {
var node=ast[i];
if(node && node.length>=3 && node[0]=='=') {
// looking for ['=', id, val]
runtime.ast()[node[1]] = {'ast': [node]};
runtime.source()[node[1]] = source;
}
}
... | javascript | function(ast, source) {
if(!ast) return;
for(var i=0;i<ast.length;i++) {
var node=ast[i];
if(node && node.length>=3 && node[0]=='=') {
// looking for ['=', id, val]
runtime.ast()[node[1]] = {'ast': [node]};
runtime.source()[node[1]] = source;
}
}
... | [
"function",
"(",
"ast",
",",
"source",
")",
"{",
"if",
"(",
"!",
"ast",
")",
"return",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ast",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"node",
"=",
"ast",
"[",
"i",
"]",
";",
"i... | load a given AST to runtime - prepare all variables | [
"load",
"a",
"given",
"AST",
"to",
"runtime",
"-",
"prepare",
"all",
"variables"
] | 1fec357306e0e871d6126254f0f758ade84f30a7 | https://github.com/openmason/panda-lang/blob/1fec357306e0e871d6126254f0f758ade84f30a7/lib/panda.js#L18-L28 | train | |
Bartvds/miniwrite | lib/io.js | stream | function stream(nodeStream, linebreak) {
linebreak = (typeof linebreak !== 'undefined' ? linebreak : '\n');
var mw = core.base();
mw.enabled = true;
mw.stream = nodeStream;
mw.linebreak = linebreak;
mw.writeln = function (line) {
if (mw.enabled) {
mw.stream.write(line + linebreak);
... | javascript | function stream(nodeStream, linebreak) {
linebreak = (typeof linebreak !== 'undefined' ? linebreak : '\n');
var mw = core.base();
mw.enabled = true;
mw.stream = nodeStream;
mw.linebreak = linebreak;
mw.writeln = function (line) {
if (mw.enabled) {
mw.stream.write(line + linebreak);
... | [
"function",
"stream",
"(",
"nodeStream",
",",
"linebreak",
")",
"{",
"linebreak",
"=",
"(",
"typeof",
"linebreak",
"!==",
"'undefined'",
"?",
"linebreak",
":",
"'\\n'",
")",
";",
"var",
"mw",
"=",
"core",
".",
"base",
"(",
")",
";",
"mw",
".",
"enabled... | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - node.js stream | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"... | 0b716dfdd203e20bdf71b552d1776ade8a55ced5 | https://github.com/Bartvds/miniwrite/blob/0b716dfdd203e20bdf71b552d1776ade8a55ced5/lib/io.js#L44-L60 | train |
UWNetworksLab/uProxy-obfuscators | demo/html/benchmark.js | WriteFteTable | function WriteFteTable() {
for (var i = 0; i < test_languages.length; i++) {
var retval = '';
retval += '<tr id="fte_row' + i + '">';
retval += '<td class="obfuscatorName">fte</td>';
retval += '<td class="testNum">' + test_languages[i]['description'] + '</td>';
retval += '<td class="testProto">' +... | javascript | function WriteFteTable() {
for (var i = 0; i < test_languages.length; i++) {
var retval = '';
retval += '<tr id="fte_row' + i + '">';
retval += '<td class="obfuscatorName">fte</td>';
retval += '<td class="testNum">' + test_languages[i]['description'] + '</td>';
retval += '<td class="testProto">' +... | [
"function",
"WriteFteTable",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"test_languages",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"retval",
"=",
"''",
";",
"retval",
"+=",
"'<tr id=\"fte_row'",
"+",
"i",
"+",
"'\">'",
"... | Functions for the FTE table | [
"Functions",
"for",
"the",
"FTE",
"table"
] | f00ccc31561f2c0cfa84d99349d9981b17abecb2 | https://github.com/UWNetworksLab/uProxy-obfuscators/blob/f00ccc31561f2c0cfa84d99349d9981b17abecb2/demo/html/benchmark.js#L81-L106 | train |
mosaicjs/mosaic-styles | src/Color.js | function(amount) {
var hsl = this.toHSL();
hsl.l += amount;
hsl.l = clamp(hsl.l);
return Color.fromHSL(hsl);
} | javascript | function(amount) {
var hsl = this.toHSL();
hsl.l += amount;
hsl.l = clamp(hsl.l);
return Color.fromHSL(hsl);
} | [
"function",
"(",
"amount",
")",
"{",
"var",
"hsl",
"=",
"this",
".",
"toHSL",
"(",
")",
";",
"hsl",
".",
"l",
"+=",
"amount",
";",
"hsl",
".",
"l",
"=",
"clamp",
"(",
"hsl",
".",
"l",
")",
";",
"return",
"Color",
".",
"fromHSL",
"(",
"hsl",
"... | Returns a lighten version of this color
@param amount
value in the range [0..1] | [
"Returns",
"a",
"lighten",
"version",
"of",
"this",
"color"
] | 0b8c963043da36cef673b47d7c8340908caf6cad | https://github.com/mosaicjs/mosaic-styles/blob/0b8c963043da36cef673b47d7c8340908caf6cad/src/Color.js#L130-L135 | train | |
redisjs/jsr-server | lib/command/database/string/bitcount.js | validate | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var start
, end;
if(args.length !== 1 && args.length !== 3) {
throw new CommandArgLength(cmd);
}
if(args.length > 1) {
start = parseInt('' + args[1]);
if(isNaN(start)) throw IntegerRange;
args... | javascript | function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var start
, end;
if(args.length !== 1 && args.length !== 3) {
throw new CommandArgLength(cmd);
}
if(args.length > 1) {
start = parseInt('' + args[1]);
if(isNaN(start)) throw IntegerRange;
args... | [
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"start",
",",
"end",
";",
"if",
"(",
"args",
".",
"length",
"!... | Validate the BITCOUNT command. | [
"Validate",
"the",
"BITCOUNT",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/string/bitcount.js#L20-L37 | train |
quantumpayments/media | bin/play.js | readCookie | function readCookie (cookiePath) {
var cookie
try {
var c = fs.readFileSync(cookiePath)
debug('loaded cookie', JSON.parse(c))
var sid = c['connect-sid']
debug('serialized', sid)
} catch (e) {
debug(e)
}
return cookie
} | javascript | function readCookie (cookiePath) {
var cookie
try {
var c = fs.readFileSync(cookiePath)
debug('loaded cookie', JSON.parse(c))
var sid = c['connect-sid']
debug('serialized', sid)
} catch (e) {
debug(e)
}
return cookie
} | [
"function",
"readCookie",
"(",
"cookiePath",
")",
"{",
"var",
"cookie",
"try",
"{",
"var",
"c",
"=",
"fs",
".",
"readFileSync",
"(",
"cookiePath",
")",
"debug",
"(",
"'loaded cookie'",
",",
"JSON",
".",
"parse",
"(",
"c",
")",
")",
"var",
"sid",
"=",
... | Reads a cookie from a file
@param {string} cookiePath The path to the cookie file.
@return {object} The cookie object | [
"Reads",
"a",
"cookie",
"from",
"a",
"file"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/play.js#L904-L917 | train |
quantumpayments/media | bin/play.js | writeCookie | function writeCookie (response, cookiePath) {
try {
debug('got response')
var cookies = cookie.parse(response.headers['set-cookie'][0])
debug('connect.sid', cookies['connect.sid'])
fs.writeFileSync(cookiePath, JSON.stringify(cookies))
} catch (e) {
debug(e)
}
} | javascript | function writeCookie (response, cookiePath) {
try {
debug('got response')
var cookies = cookie.parse(response.headers['set-cookie'][0])
debug('connect.sid', cookies['connect.sid'])
fs.writeFileSync(cookiePath, JSON.stringify(cookies))
} catch (e) {
debug(e)
}
} | [
"function",
"writeCookie",
"(",
"response",
",",
"cookiePath",
")",
"{",
"try",
"{",
"debug",
"(",
"'got response'",
")",
"var",
"cookies",
"=",
"cookie",
".",
"parse",
"(",
"response",
".",
"headers",
"[",
"'set-cookie'",
"]",
"[",
"0",
"]",
")",
"debug... | Write a cookie to file.
@param {object} response The express response object.
@param {string} cookiePath The path to the cookie file. | [
"Write",
"a",
"cookie",
"to",
"file",
"."
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/play.js#L924-L933 | train |
quantumpayments/media | bin/play.js | updateLastSeen | function updateLastSeen (params, config) {
qpm_media.updateLastSeen(params, config).then(function (ret) {
if (ret.conn) {
var conn = ret.conn
conn.close()
}
}).catch(function (err) {
if (err.conn) {
var conn = err.conn
conn.close()
}
console.error(err.err)
})
} | javascript | function updateLastSeen (params, config) {
qpm_media.updateLastSeen(params, config).then(function (ret) {
if (ret.conn) {
var conn = ret.conn
conn.close()
}
}).catch(function (err) {
if (err.conn) {
var conn = err.conn
conn.close()
}
console.error(err.err)
})
} | [
"function",
"updateLastSeen",
"(",
"params",
",",
"config",
")",
"{",
"qpm_media",
".",
"updateLastSeen",
"(",
"params",
",",
"config",
")",
".",
"then",
"(",
"function",
"(",
"ret",
")",
"{",
"if",
"(",
"ret",
".",
"conn",
")",
"{",
"var",
"conn",
"... | Update last seen time.
@param {objext} params The params update.
@param {object} config Optional config. | [
"Update",
"last",
"seen",
"time",
"."
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/play.js#L940-L953 | train |
quantumpayments/media | bin/play.js | getType | function getType (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[1]) {
ret = parseInt(a[1])
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | javascript | function getType (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[1]) {
ret = parseInt(a[1])
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | [
"function",
"getType",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"null",
"var",
"match",
"=",
"/",
"[0-9]+,[0-9]+,.*",
"/",
".",
"test",
"(",
"str",
")",
"if",
"(",
"!",
"match",
")",
"{",
"return",
"null",
"}",
"var",
"a",
"=",
"str",
".",
"split... | Get type of uri
@param {string} str The uri
@return {number} The type or null | [
"Get",
"type",
"of",
"uri"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/play.js#L1014-L1030 | train |
quantumpayments/media | bin/play.js | getFile | function getFile (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[2]) {
ret = a[2]
return ret
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | javascript | function getFile (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[2]) {
ret = a[2]
return ret
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | [
"function",
"getFile",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"null",
"var",
"match",
"=",
"/",
"[0-9]+,[0-9]+,.*",
"/",
".",
"test",
"(",
"str",
")",
"if",
"(",
"!",
"match",
")",
"{",
"return",
"null",
"}",
"var",
"a",
"=",
"str",
".",
"split... | Get file of uri
@param {string} str The uri
@return {string} The file or null | [
"Get",
"file",
"of",
"uri"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/play.js#L1037-L1054 | train |
quantumpayments/media | bin/play.js | getStart | function getStart (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[0]) {
var end = a[0]
ret = parseInt(end)
return ret
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | javascript | function getStart (str) {
var ret = null
var match = /[0-9]+,[0-9]+,.*/.test(str)
if (!match) {
return null
}
var a = str.split(',')
if (a && a[0]) {
var end = a[0]
ret = parseInt(end)
return ret
} else {
return null
}
if (isNaN(ret)) {
return null
}
return ret
} | [
"function",
"getStart",
"(",
"str",
")",
"{",
"var",
"ret",
"=",
"null",
"var",
"match",
"=",
"/",
"[0-9]+,[0-9]+,.*",
"/",
".",
"test",
"(",
"str",
")",
"if",
"(",
"!",
"match",
")",
"{",
"return",
"null",
"}",
"var",
"a",
"=",
"str",
".",
"spli... | Get start of uri
@param {string} str The uri
@return {number} The start or -1 | [
"Get",
"start",
"of",
"uri"
] | b53034e6dd2a94dca950e60a49e403aceaa1cdf1 | https://github.com/quantumpayments/media/blob/b53034e6dd2a94dca950e60a49e403aceaa1cdf1/bin/play.js#L1061-L1079 | train |
Everyplay/backbone-db-local | index.js | sort | function sort(property) {
// sort by multiple properties
function multisort(properties) {
return function multiCompare(a, b) {
var i = 0;
var result = 0;
var numberOfProperties = properties.length;
while(result === 0 && i < numberOfProperties) {
result = sort(properties[i])(a, b)... | javascript | function sort(property) {
// sort by multiple properties
function multisort(properties) {
return function multiCompare(a, b) {
var i = 0;
var result = 0;
var numberOfProperties = properties.length;
while(result === 0 && i < numberOfProperties) {
result = sort(properties[i])(a, b)... | [
"function",
"sort",
"(",
"property",
")",
"{",
"// sort by multiple properties",
"function",
"multisort",
"(",
"properties",
")",
"{",
"return",
"function",
"multiCompare",
"(",
"a",
",",
"b",
")",
"{",
"var",
"i",
"=",
"0",
";",
"var",
"result",
"=",
"0",... | in-memory sort, just for mocking db functionality | [
"in",
"-",
"memory",
"sort",
"just",
"for",
"mocking",
"db",
"functionality"
] | d1449f579dc4fa67be02b11f57aee74d40f3cf95 | https://github.com/Everyplay/backbone-db-local/blob/d1449f579dc4fa67be02b11f57aee74d40f3cf95/index.js#L51-L84 | train |
Everyplay/backbone-db-local | index.js | multisort | function multisort(properties) {
return function multiCompare(a, b) {
var i = 0;
var result = 0;
var numberOfProperties = properties.length;
while(result === 0 && i < numberOfProperties) {
result = sort(properties[i])(a, b);
i++;
}
return result;
};
} | javascript | function multisort(properties) {
return function multiCompare(a, b) {
var i = 0;
var result = 0;
var numberOfProperties = properties.length;
while(result === 0 && i < numberOfProperties) {
result = sort(properties[i])(a, b);
i++;
}
return result;
};
} | [
"function",
"multisort",
"(",
"properties",
")",
"{",
"return",
"function",
"multiCompare",
"(",
"a",
",",
"b",
")",
"{",
"var",
"i",
"=",
"0",
";",
"var",
"result",
"=",
"0",
";",
"var",
"numberOfProperties",
"=",
"properties",
".",
"length",
";",
"wh... | sort by multiple properties | [
"sort",
"by",
"multiple",
"properties"
] | d1449f579dc4fa67be02b11f57aee74d40f3cf95 | https://github.com/Everyplay/backbone-db-local/blob/d1449f579dc4fa67be02b11f57aee74d40f3cf95/index.js#L53-L64 | train |
builtforme/swatchjs-koa-middleware | lib/response/index.js | exception | function exception(exceptionObj) {
const errorMessage = getErrorMessage(exceptionObj);
const errorDetails = getErrorDetails(exceptionObj);
return {
ok: false,
error: errorMessage,
details: errorDetails,
};
} | javascript | function exception(exceptionObj) {
const errorMessage = getErrorMessage(exceptionObj);
const errorDetails = getErrorDetails(exceptionObj);
return {
ok: false,
error: errorMessage,
details: errorDetails,
};
} | [
"function",
"exception",
"(",
"exceptionObj",
")",
"{",
"const",
"errorMessage",
"=",
"getErrorMessage",
"(",
"exceptionObj",
")",
";",
"const",
"errorDetails",
"=",
"getErrorDetails",
"(",
"exceptionObj",
")",
";",
"return",
"{",
"ok",
":",
"false",
",",
"err... | `exception` should return an object with message and details | [
"exception",
"should",
"return",
"an",
"object",
"with",
"message",
"and",
"details"
] | cead904997ff6f6733ffab482aa4509cf4364945 | https://github.com/builtforme/swatchjs-koa-middleware/blob/cead904997ff6f6733ffab482aa4509cf4364945/lib/response/index.js#L26-L35 | train |
jldec/pub-src-redis | pub-src-redis.js | connect | function connect() {
if (!redis) {
debug('createClient ' + key + ' at ' + host + ':' + port);
redis = redisLib.createClient(port, host, redisOpts); }
} | javascript | function connect() {
if (!redis) {
debug('createClient ' + key + ' at ' + host + ':' + port);
redis = redisLib.createClient(port, host, redisOpts); }
} | [
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"!",
"redis",
")",
"{",
"debug",
"(",
"'createClient '",
"+",
"key",
"+",
"' at '",
"+",
"host",
"+",
"':'",
"+",
"port",
")",
";",
"redis",
"=",
"redisLib",
".",
"createClient",
"(",
"port",
",",
"h... | connect is called automatically by other methods | [
"connect",
"is",
"called",
"automatically",
"by",
"other",
"methods"
] | d18e13fde82ff969571f59790e15098a5edbd89e | https://github.com/jldec/pub-src-redis/blob/d18e13fde82ff969571f59790e15098a5edbd89e/pub-src-redis.js#L51-L55 | 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.