id
int32 0
58k
| 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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
50,200 | 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 content inside the braces
.map(function (match) { return match[1] })
.map(parseExpression)
return {
original: str,
value: value,
expressions: expressions
}
} | 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 content inside the braces
.map(function (match) { return match[1] })
.map(parseExpression)
return {
original: str,
value: value,
expressions: expressions
}
} | [
"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 content inside the braces",
".",
"map",
"(",
"function",
"(",
"match",
")",
"{",
"return",
"match",
"[",
"1",
"]",
"}",
")",
".",
"map",
"(",
"parseExpression",
")",
"return",
"{",
"original",
":",
"str",
",",
"value",
":",
"value",
",",
"expressions",
":",
"expressions",
"}",
"}"
] | 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 |
50,201 | 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];
if(typeof arg === 'object') {
req = arg;
}else if(arg === Constants.NX || arg === Constants.XX) {
xflag = arg;
}else if(arg === Constants.EX || arg === Constants.PX) {
flag = arg;
expiry = arguments[++i];
}
}
return this.setKey(key, value, flag, expiry, xflag, req) || null;
} | 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];
if(typeof arg === 'object') {
req = arg;
}else if(arg === Constants.NX || arg === Constants.XX) {
xflag = arg;
}else if(arg === Constants.EX || arg === Constants.PX) {
flag = arg;
expiry = arguments[++i];
}
}
return this.setKey(key, value, flag, expiry, xflag, req) || null;
} | [
"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",
"]",
";",
"if",
"(",
"typeof",
"arg",
"===",
"'object'",
")",
"{",
"req",
"=",
"arg",
";",
"}",
"else",
"if",
"(",
"arg",
"===",
"Constants",
".",
"NX",
"||",
"arg",
"===",
"Constants",
".",
"XX",
")",
"{",
"xflag",
"=",
"arg",
";",
"}",
"else",
"if",
"(",
"arg",
"===",
"Constants",
".",
"EX",
"||",
"arg",
"===",
"Constants",
".",
"PX",
")",
"{",
"flag",
"=",
"arg",
";",
"expiry",
"=",
"arguments",
"[",
"++",
"i",
"]",
";",
"}",
"}",
"return",
"this",
".",
"setKey",
"(",
"key",
",",
"value",
",",
"flag",
",",
"expiry",
",",
"xflag",
",",
"req",
")",
"||",
"null",
";",
"}"
] | 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 |
50,202 | 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",
"?",
"1",
":",
"0",
";",
"}"
] | 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 |
50,203 | 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 |
50,204 | 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 |
50,205 | 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",
",",
"req",
")",
";",
"return",
"val",
"||",
"null",
";",
"}"
] | 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 |
50,206 | 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",
"=",
"args",
".",
"pop",
"(",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"this",
".",
"setKey",
"(",
"args",
"[",
"i",
"]",
",",
"args",
"[",
"i",
"+",
"1",
"]",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"return",
"OK",
";",
"}"
] | 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 |
50,207 | 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) {
this.setKey(args[i], args[i + 1], undefined, undefined, undefined, req);
}
return 1;
} | 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) {
this.setKey(args[i], args[i + 1], undefined, undefined, undefined, req);
}
return 1;
} | [
"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",
")",
"{",
"this",
".",
"setKey",
"(",
"args",
"[",
"i",
"]",
",",
"args",
"[",
"i",
"+",
"1",
"]",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"}",
"return",
"1",
";",
"}"
] | 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 |
50,208 | 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'",
")",
"{",
"args",
".",
"pop",
"(",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"list",
".",
"push",
"(",
"this",
".",
"get",
"(",
"args",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"list",
";",
"}"
] | 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 |
50,209 | 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",
")",
";",
"val",
"+=",
"amount",
";",
"this",
".",
"setKey",
"(",
"key",
",",
"val",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"return",
"val",
";",
"}"
] | 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 |
50,210 | 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",
")",
";",
"val",
"+=",
"amount",
";",
"this",
".",
"setKey",
"(",
"key",
",",
"val",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"return",
"val",
";",
"}"
] | 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 |
50,211 | 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);
// coerce numbers to strings
//val = (val + '') + value;
//val = val.concat()
val = Buffer.concat([val, value], val.length + value.length);
if(str) val = val.toString();
this.setKey(key, val, undefined, undefined, undefined, req);
return str ? Buffer.byteLength(val) : val.length;
} | 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);
// coerce numbers to strings
//val = (val + '') + value;
//val = val.concat()
val = Buffer.concat([val, value], val.length + value.length);
if(str) val = val.toString();
this.setKey(key, val, undefined, undefined, undefined, req);
return str ? Buffer.byteLength(val) : val.length;
} | [
"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",
")",
";",
"// coerce numbers to strings",
"//val = (val + '') + value;",
"//val = val.concat()",
"val",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"val",
",",
"value",
"]",
",",
"val",
".",
"length",
"+",
"value",
".",
"length",
")",
";",
"if",
"(",
"str",
")",
"val",
"=",
"val",
".",
"toString",
"(",
")",
";",
"this",
".",
"setKey",
"(",
"key",
",",
"val",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"return",
"str",
"?",
"Buffer",
".",
"byteLength",
"(",
"val",
")",
":",
"val",
".",
"length",
";",
"}"
] | 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 |
50,212 | 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",
"(",
"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",
")",
";",
"}"
] | 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 |
50,213 | 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);
}
offset = parseInt(offset);
if(!val) {
val = new Buffer('');
}
// zero pad where necessary
while(val.length < offset) {
val = Buffer.concat([val, new Buffer([0])], val.length + 1);
}
// slice the buffer to offset
if(offset < val.length) {
val = val.slice(0, offset);
}
val = Buffer.concat([val, value], val.length + value.length);
// was a string, put back as a string
if(str) {
val = '' + val;
len = Buffer.byteLength(val);
// was a buffer
}else{
len = val.length;
}
this.setKey(key, val, undefined, undefined, undefined, req);
return len;
} | 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);
}
offset = parseInt(offset);
if(!val) {
val = new Buffer('');
}
// zero pad where necessary
while(val.length < offset) {
val = Buffer.concat([val, new Buffer([0])], val.length + 1);
}
// slice the buffer to offset
if(offset < val.length) {
val = val.slice(0, offset);
}
val = Buffer.concat([val, value], val.length + value.length);
// was a string, put back as a string
if(str) {
val = '' + val;
len = Buffer.byteLength(val);
// was a buffer
}else{
len = val.length;
}
this.setKey(key, val, undefined, undefined, undefined, req);
return len;
} | [
"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",
")",
";",
"}",
"offset",
"=",
"parseInt",
"(",
"offset",
")",
";",
"if",
"(",
"!",
"val",
")",
"{",
"val",
"=",
"new",
"Buffer",
"(",
"''",
")",
";",
"}",
"// zero pad where necessary",
"while",
"(",
"val",
".",
"length",
"<",
"offset",
")",
"{",
"val",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"val",
",",
"new",
"Buffer",
"(",
"[",
"0",
"]",
")",
"]",
",",
"val",
".",
"length",
"+",
"1",
")",
";",
"}",
"// slice the buffer to offset",
"if",
"(",
"offset",
"<",
"val",
".",
"length",
")",
"{",
"val",
"=",
"val",
".",
"slice",
"(",
"0",
",",
"offset",
")",
";",
"}",
"val",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"val",
",",
"value",
"]",
",",
"val",
".",
"length",
"+",
"value",
".",
"length",
")",
";",
"// was a string, put back as a string",
"if",
"(",
"str",
")",
"{",
"val",
"=",
"''",
"+",
"val",
";",
"len",
"=",
"Buffer",
".",
"byteLength",
"(",
"val",
")",
";",
"// was a buffer",
"}",
"else",
"{",
"len",
"=",
"val",
".",
"length",
";",
"}",
"this",
".",
"setKey",
"(",
"key",
",",
"val",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"return",
"len",
";",
"}"
] | 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 |
50,214 | 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",
"&",
"0x7",
")",
",",
"bitval",
"=",
"0",
";",
"if",
"(",
"buf",
"===",
"undefined",
")",
"return",
"0",
";",
"if",
"(",
"byte",
"<",
"buf",
".",
"length",
")",
"{",
"bitval",
"=",
"buf",
"[",
"byte",
"]",
"&",
"(",
"1",
"<<",
"bit",
")",
";",
"}",
"return",
"bitval",
"?",
"1",
":",
"0",
";",
"}"
] | 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 |
50,215 | 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 start/end range
if(arguments.length >= 3) {
if(start < 0) start = buf.length + start;
if(start < 0) start = 0;
if(end < 0) end = buf.length + end;
if(end < 0) end = 0;
if(end > buf.length || end === undefined) end = buf.length;
}else{
start = 0;
end = buf.length;
}
if(typeof start === 'object') start = 0;
if(typeof end === 'object') end = buf.length;
// get the range we are inspecting
buf = buf.slice(start, end + 1);
function getBitPos(bit, byte, index) {
var mask = [0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01]
, i;
for(i = 0;i < mask.length;i++) {
if(bit && (byte & mask[i]) || !bit && !(byte & mask[i])) {
return index + i;
}
}
return -1;
}
for(i = 0;i < buf.length;i++) {
ind = getBitPos(bit, buf[i], (start + i) * 8);
if(~ind) return ind;
}
// looking for clear bit, but all bits set
if(!bit) return i * 8;
return -1;
} | 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 start/end range
if(arguments.length >= 3) {
if(start < 0) start = buf.length + start;
if(start < 0) start = 0;
if(end < 0) end = buf.length + end;
if(end < 0) end = 0;
if(end > buf.length || end === undefined) end = buf.length;
}else{
start = 0;
end = buf.length;
}
if(typeof start === 'object') start = 0;
if(typeof end === 'object') end = buf.length;
// get the range we are inspecting
buf = buf.slice(start, end + 1);
function getBitPos(bit, byte, index) {
var mask = [0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01]
, i;
for(i = 0;i < mask.length;i++) {
if(bit && (byte & mask[i]) || !bit && !(byte & mask[i])) {
return index + i;
}
}
return -1;
}
for(i = 0;i < buf.length;i++) {
ind = getBitPos(bit, buf[i], (start + i) * 8);
if(~ind) return ind;
}
// looking for clear bit, but all bits set
if(!bit) return i * 8;
return -1;
} | [
"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 start/end range",
"if",
"(",
"arguments",
".",
"length",
">=",
"3",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"start",
"=",
"buf",
".",
"length",
"+",
"start",
";",
"if",
"(",
"start",
"<",
"0",
")",
"start",
"=",
"0",
";",
"if",
"(",
"end",
"<",
"0",
")",
"end",
"=",
"buf",
".",
"length",
"+",
"end",
";",
"if",
"(",
"end",
"<",
"0",
")",
"end",
"=",
"0",
";",
"if",
"(",
"end",
">",
"buf",
".",
"length",
"||",
"end",
"===",
"undefined",
")",
"end",
"=",
"buf",
".",
"length",
";",
"}",
"else",
"{",
"start",
"=",
"0",
";",
"end",
"=",
"buf",
".",
"length",
";",
"}",
"if",
"(",
"typeof",
"start",
"===",
"'object'",
")",
"start",
"=",
"0",
";",
"if",
"(",
"typeof",
"end",
"===",
"'object'",
")",
"end",
"=",
"buf",
".",
"length",
";",
"// get the range we are inspecting",
"buf",
"=",
"buf",
".",
"slice",
"(",
"start",
",",
"end",
"+",
"1",
")",
";",
"function",
"getBitPos",
"(",
"bit",
",",
"byte",
",",
"index",
")",
"{",
"var",
"mask",
"=",
"[",
"0x80",
",",
"0x40",
",",
"0x20",
",",
"0x10",
",",
"0x08",
",",
"0x04",
",",
"0x02",
",",
"0x01",
"]",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"mask",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"bit",
"&&",
"(",
"byte",
"&",
"mask",
"[",
"i",
"]",
")",
"||",
"!",
"bit",
"&&",
"!",
"(",
"byte",
"&",
"mask",
"[",
"i",
"]",
")",
")",
"{",
"return",
"index",
"+",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"buf",
".",
"length",
";",
"i",
"++",
")",
"{",
"ind",
"=",
"getBitPos",
"(",
"bit",
",",
"buf",
"[",
"i",
"]",
",",
"(",
"start",
"+",
"i",
")",
"*",
"8",
")",
";",
"if",
"(",
"~",
"ind",
")",
"return",
"ind",
";",
"}",
"// looking for clear bit, but all bits set",
"if",
"(",
"!",
"bit",
")",
"return",
"i",
"*",
"8",
";",
"return",
"-",
"1",
";",
"}"
] | 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 |
50,216 | 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) {
zeros = new Buffer(pos + 1 - buf.length);
zeros.fill('\u0000');
buf = Buffer.concat([buf, zeros], buf.length + zeros.length);
}
shift = 7 - (offset & 0x7);
byte = buf[pos];
byte &= ~(1 << shift);
byte |= ((value & 0x01) << shift);
buf[pos] = byte;
this.setKey(key, buf, undefined, undefined, undefined, req);
return bit;
} | 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) {
zeros = new Buffer(pos + 1 - buf.length);
zeros.fill('\u0000');
buf = Buffer.concat([buf, zeros], buf.length + zeros.length);
}
shift = 7 - (offset & 0x7);
byte = buf[pos];
byte &= ~(1 << shift);
byte |= ((value & 0x01) << shift);
buf[pos] = byte;
this.setKey(key, buf, undefined, undefined, undefined, req);
return bit;
} | [
"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",
")",
"{",
"zeros",
"=",
"new",
"Buffer",
"(",
"pos",
"+",
"1",
"-",
"buf",
".",
"length",
")",
";",
"zeros",
".",
"fill",
"(",
"'\\u0000'",
")",
";",
"buf",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"buf",
",",
"zeros",
"]",
",",
"buf",
".",
"length",
"+",
"zeros",
".",
"length",
")",
";",
"}",
"shift",
"=",
"7",
"-",
"(",
"offset",
"&",
"0x7",
")",
";",
"byte",
"=",
"buf",
"[",
"pos",
"]",
";",
"byte",
"&=",
"~",
"(",
"1",
"<<",
"shift",
")",
";",
"byte",
"|=",
"(",
"(",
"value",
"&",
"0x01",
")",
"<<",
"shift",
")",
";",
"buf",
"[",
"pos",
"]",
"=",
"byte",
";",
"this",
".",
"setKey",
"(",
"key",
",",
"buf",
",",
"undefined",
",",
"undefined",
",",
"undefined",
",",
"req",
")",
";",
"return",
"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 |
50,217 | 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",
")",
"{",
"buf",
"+=",
"data",
";",
"}",
")",
";",
"cp",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
")",
"{",
"}",
")",
";",
"cp",
".",
"on",
"(",
"'close'",
",",
"function",
"(",
"code",
")",
"{",
"cb",
"(",
"null",
",",
"code",
">",
"0",
"?",
"''",
":",
"buf",
")",
";",
"}",
")",
";",
"// set dot to stdin",
"cp",
".",
"stdin",
".",
"end",
"(",
"data",
")",
";",
"}"
] | make a graphviz thing | [
"make",
"a",
"graphviz",
"thing"
] | 4af3b95674216b6a415b802322f5e44b78351d06 | https://github.com/loomio/router/blob/4af3b95674216b6a415b802322f5e44b78351d06/docs/processors/markdown.js#L109-L124 |
50,218 | 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 propertyMap;
} | 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 propertyMap;
} | [
"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",
"propertyMap",
";",
"}"
] | 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 |
50,219 | 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",
"]",
")",
";",
"}",
")",
";",
"return",
"obj",
";",
"}"
] | 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 |
50,220 | 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 = {
reportRunnerResults: function (runner) {
window.__runner__.failures = this.failed;
window.__runner__.passed = (this.failed === 0);
window.__runner__.finished = true;
},
reportSpecStarting: function (spec) {
this.total++;
},
reportSpecResults: function(spec) {
if (spec.results().skipped) {
return;
}
spec.results().passed() ? this.passed++ : this.failed++;
}
};
// this reporter is always added last
jasmineEnv.addReporter(new FinishedReporter());
jasmineEnv.execute();
return true;
}
catch (e) {
var out = 'Script Error in PhantomJS\n\nMessage:\n ' + e.message +
'\nStack:\n ' + e.stack + '\n';
console.log(out);
return false;
}
} | 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 = {
reportRunnerResults: function (runner) {
window.__runner__.failures = this.failed;
window.__runner__.passed = (this.failed === 0);
window.__runner__.finished = true;
},
reportSpecStarting: function (spec) {
this.total++;
},
reportSpecResults: function(spec) {
if (spec.results().skipped) {
return;
}
spec.results().passed() ? this.passed++ : this.failed++;
}
};
// this reporter is always added last
jasmineEnv.addReporter(new FinishedReporter());
jasmineEnv.execute();
return true;
}
catch (e) {
var out = 'Script Error in PhantomJS\n\nMessage:\n ' + e.message +
'\nStack:\n ' + e.stack + '\n';
console.log(out);
return false;
}
} | [
"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",
"=",
"{",
"reportRunnerResults",
":",
"function",
"(",
"runner",
")",
"{",
"window",
".",
"__runner__",
".",
"failures",
"=",
"this",
".",
"failed",
";",
"window",
".",
"__runner__",
".",
"passed",
"=",
"(",
"this",
".",
"failed",
"===",
"0",
")",
";",
"window",
".",
"__runner__",
".",
"finished",
"=",
"true",
";",
"}",
",",
"reportSpecStarting",
":",
"function",
"(",
"spec",
")",
"{",
"this",
".",
"total",
"++",
";",
"}",
",",
"reportSpecResults",
":",
"function",
"(",
"spec",
")",
"{",
"if",
"(",
"spec",
".",
"results",
"(",
")",
".",
"skipped",
")",
"{",
"return",
";",
"}",
"spec",
".",
"results",
"(",
")",
".",
"passed",
"(",
")",
"?",
"this",
".",
"passed",
"++",
":",
"this",
".",
"failed",
"++",
";",
"}",
"}",
";",
"// this reporter is always added last",
"jasmineEnv",
".",
"addReporter",
"(",
"new",
"FinishedReporter",
"(",
")",
")",
";",
"jasmineEnv",
".",
"execute",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"var",
"out",
"=",
"'Script Error in PhantomJS\\n\\nMessage:\\n '",
"+",
"e",
".",
"message",
"+",
"'\\nStack:\\n '",
"+",
"e",
".",
"stack",
"+",
"'\\n'",
";",
"console",
".",
"log",
"(",
"out",
")",
";",
"return",
"false",
";",
"}",
"}"
] | 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 |
|
50,221 | 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 = getInstanceNameFromElement(child);
if (!inferredName) {
if ((typeof name !== 'string') || (name === '')) return false;
setAttribute(child, 'name', name);
}
else {
name = inferredName;
}
if (childRegistry[name])
childRegistry[name] = [].concat(childRegistry[name], child);
else
childRegistry[name] = child;
return true;
} | 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 = getInstanceNameFromElement(child);
if (!inferredName) {
if ((typeof name !== 'string') || (name === '')) return false;
setAttribute(child, 'name', name);
}
else {
name = inferredName;
}
if (childRegistry[name])
childRegistry[name] = [].concat(childRegistry[name], child);
else
childRegistry[name] = child;
return true;
} | [
"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",
"=",
"getInstanceNameFromElement",
"(",
"child",
")",
";",
"if",
"(",
"!",
"inferredName",
")",
"{",
"if",
"(",
"(",
"typeof",
"name",
"!==",
"'string'",
")",
"||",
"(",
"name",
"===",
"''",
")",
")",
"return",
"false",
";",
"setAttribute",
"(",
"child",
",",
"'name'",
",",
"name",
")",
";",
"}",
"else",
"{",
"name",
"=",
"inferredName",
";",
"}",
"if",
"(",
"childRegistry",
"[",
"name",
"]",
")",
"childRegistry",
"[",
"name",
"]",
"=",
"[",
"]",
".",
"concat",
"(",
"childRegistry",
"[",
"name",
"]",
",",
"child",
")",
";",
"else",
"childRegistry",
"[",
"name",
"]",
"=",
"child",
";",
"return",
"true",
";",
"}"
] | 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} True if the child is successfully added to the child
registry, false otherwise.
@alias module:requiem~dom.addToChildRegistry | [
"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 |
50,222 | 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 |
50,223 | 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",
".",
"attributes",
"[",
"i",
"]",
";",
"this",
".",
"attributeChangedCallback",
"(",
"attr",
".",
"name",
",",
"null",
",",
"attr",
".",
"value",
",",
"true",
")",
";",
"}",
"}"
] | Base element constructor
@author Jelle De Loecker <[email protected]>
@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 |
50,224 | 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_values : {}
};
weak_properties.set(instance, map);
}
return map;
} | 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_values : {}
};
weak_properties.set(instance, map);
}
return map;
} | [
"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_values",
":",
"{",
"}",
"}",
";",
"weak_properties",
".",
"set",
"(",
"instance",
",",
"map",
")",
";",
"}",
"return",
"map",
";",
"}"
] | Create a private variable for the given instance
@author Jelle De Loecker <[email protected]>
@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 |
50,225 | 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.removeChildren(this);
return Fn.series(function renderTemplate(next) {
var template = that.constructor.compiled_template || that.constructor.template_file;
that.hawkejs_renderer.renderTemplate(template, {self: that}, String(c++)).done(next);
}, function assembleBlock(next, template) {
template.target_block.assemble().done(next);
}, function assembledBlock(next, block) {
var slots,
slot,
name,
i;
for (i = 0; i < block.lines.length; i++) {
that.append(block.lines[i]);
}
slots = Hawkejs.getElementsByAttribute(that, 'data-he-slot');
for (i = 0; i < slots.length; i++) {
slot = slots[i];
name = slot.dataset.heSlot;
if (vars[name]) {
Hawkejs.replaceChildren(slot, vars[name].childNodes);
}
}
next();
}, null);
} | 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.removeChildren(this);
return Fn.series(function renderTemplate(next) {
var template = that.constructor.compiled_template || that.constructor.template_file;
that.hawkejs_renderer.renderTemplate(template, {self: that}, String(c++)).done(next);
}, function assembleBlock(next, template) {
template.target_block.assemble().done(next);
}, function assembledBlock(next, block) {
var slots,
slot,
name,
i;
for (i = 0; i < block.lines.length; i++) {
that.append(block.lines[i]);
}
slots = Hawkejs.getElementsByAttribute(that, 'data-he-slot');
for (i = 0; i < slots.length; i++) {
slot = slots[i];
name = slot.dataset.heSlot;
if (vars[name]) {
Hawkejs.replaceChildren(slot, vars[name].childNodes);
}
}
next();
}, null);
} | [
"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",
".",
"removeChildren",
"(",
"this",
")",
";",
"return",
"Fn",
".",
"series",
"(",
"function",
"renderTemplate",
"(",
"next",
")",
"{",
"var",
"template",
"=",
"that",
".",
"constructor",
".",
"compiled_template",
"||",
"that",
".",
"constructor",
".",
"template_file",
";",
"that",
".",
"hawkejs_renderer",
".",
"renderTemplate",
"(",
"template",
",",
"{",
"self",
":",
"that",
"}",
",",
"String",
"(",
"c",
"++",
")",
")",
".",
"done",
"(",
"next",
")",
";",
"}",
",",
"function",
"assembleBlock",
"(",
"next",
",",
"template",
")",
"{",
"template",
".",
"target_block",
".",
"assemble",
"(",
")",
".",
"done",
"(",
"next",
")",
";",
"}",
",",
"function",
"assembledBlock",
"(",
"next",
",",
"block",
")",
"{",
"var",
"slots",
",",
"slot",
",",
"name",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"block",
".",
"lines",
".",
"length",
";",
"i",
"++",
")",
"{",
"that",
".",
"append",
"(",
"block",
".",
"lines",
"[",
"i",
"]",
")",
";",
"}",
"slots",
"=",
"Hawkejs",
".",
"getElementsByAttribute",
"(",
"that",
",",
"'data-he-slot'",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"slots",
".",
"length",
";",
"i",
"++",
")",
"{",
"slot",
"=",
"slots",
"[",
"i",
"]",
";",
"name",
"=",
"slot",
".",
"dataset",
".",
"heSlot",
";",
"if",
"(",
"vars",
"[",
"name",
"]",
")",
"{",
"Hawkejs",
".",
"replaceChildren",
"(",
"slot",
",",
"vars",
"[",
"name",
"]",
".",
"childNodes",
")",
";",
"}",
"}",
"next",
"(",
")",
";",
"}",
",",
"null",
")",
";",
"}"
] | The custom template render function
@author Jelle De Loecker <[email protected]>
@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 |
50,226 | 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 |
50,227 | 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",
"(",
"parts",
".",
"length",
">=",
"4",
")",
"{",
"return",
"parts",
"[",
"0",
"]",
"+",
"[",
"]",
".",
"concat",
"(",
"value",
")",
".",
"map",
"(",
"(",
"val",
")",
"=>",
"parts",
"[",
"1",
"]",
"+",
"val",
"+",
"parts",
"[",
"2",
"]",
")",
"+",
"parts",
"[",
"3",
"]",
"}",
"return",
"parts",
"[",
"0",
"]",
"+",
"value",
"+",
"parts",
"[",
"1",
"]",
"}"
] | 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 of strings of the format `[outer_left, [inner_left, inner_right,] outer_right]`
@returns {string} The wrapped value | [
"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",
"."
] | 0e896ead0567737cf31a4a8b76a26cfa6ce60759 | https://github.com/integreat-io/great-uri-template/blob/0e896ead0567737cf31a4a8b76a26cfa6ce60759/lib/filters/wrap.js#L10-L20 |
50,228 | 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",
"=",
"q",
".",
"defer",
"(",
")",
";",
"errDefered",
".",
"reject",
"(",
"err",
")",
";",
"return",
"errDefered",
".",
"promise",
";",
"}",
";",
"}"
] | 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 |
50,229 | 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",
")",
")",
",",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"ssetTahtaKurumIstenmeyen",
"(",
"_tahta_id",
")",
")",
"]",
".",
"allX",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | endregion region KURUM | [
"endregion",
"region",
"KURUM"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L119-L130 |
50,230 | 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)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaAnahtarKalemleri(_tahta_id))
].allX();
} else {
return null;
}
} | 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)),
db.redis.dbQ.del(db.redis.kp.temp.ssetTahtaAnahtarKalemleri(_tahta_id))
].allX();
} else {
return null;
}
} | [
"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",
")",
")",
",",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"ssetTahtaAnahtarKalemleri",
"(",
"_tahta_id",
")",
")",
"]",
".",
"allX",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | endregion region KALEM | [
"endregion",
"region",
"KALEM"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L414-L425 |
50,231 | 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.zsetTahtaIhaleSiraliIhaleTarihineGore(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.zsetTahtaAnahtaraGoreSiraliIhaleTarihineGore(_tahta_id))
].allX();
} else {
return null;
}
} | 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.zsetTahtaIhaleSiraliIhaleTarihineGore(_tahta_id)),
db.redis.dbQ.del(db.redis.kp.temp.zsetTahtaAnahtaraGoreSiraliIhaleTarihineGore(_tahta_id))
].allX();
} else {
return null;
}
} | [
"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",
".",
"zsetTahtaIhaleSiraliIhaleTarihineGore",
"(",
"_tahta_id",
")",
")",
",",
"db",
".",
"redis",
".",
"dbQ",
".",
"del",
"(",
"db",
".",
"redis",
".",
"kp",
".",
"temp",
".",
"zsetTahtaAnahtaraGoreSiraliIhaleTarihineGore",
"(",
"_tahta_id",
")",
")",
"]",
".",
"allX",
"(",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | endregion region TAHTA ANAHTAR | [
"endregion",
"region",
"TAHTA",
"ANAHTAR"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L751-L762 |
50,232 | 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 (_kullanici.Providers.FB) {
delete _kullanici.Providers.FB.raw;
}
} | 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 (_kullanici.Providers.FB) {
delete _kullanici.Providers.FB.raw;
}
} | [
"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",
".",
"raw",
";",
"}",
"else",
"if",
"(",
"_kullanici",
".",
"Providers",
".",
"TW",
")",
"{",
"delete",
"_kullanici",
".",
"Providers",
".",
"TW",
".",
"raw",
";",
"}",
"else",
"if",
"(",
"_kullanici",
".",
"Providers",
".",
"FB",
")",
"{",
"delete",
"_kullanici",
".",
"Providers",
".",
"FB",
".",
"raw",
";",
"}",
"}"
] | endregion region KULLANICI | [
"endregion",
"region",
"KULLANICI"
] | d584aaf51f65a013bec79220a05007bd70767ac2 | https://github.com/cemtopkaya/kuark-db/blob/d584aaf51f65a013bec79220a05007bd70767ac2/lib/cem.js#L790-L799 |
50,233 | 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 |
50,234 | 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",
"+",
"'-'",
"+",
"version",
")",
";",
"}",
")",
";",
"}"
] | 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 |
50,235 | 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",
")",
";",
"return",
"exec",
"(",
"'tar cfJ '",
"+",
"archivePath",
"+",
"' '",
"+",
"dir",
")",
";",
"}"
] | 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 |
50,236 | 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(function(controlFileTemplate) {
controlFileTemplate = _(controlFileTemplate).template();
var controlFileContents = controlFileTemplate(options);
return fse.writeFileAsync(path.join(debianDir, 'control'), controlFileContents);
});
} | 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(controlFileTemplate) {
controlFileTemplate = _(controlFileTemplate).template();
var controlFileContents = controlFileTemplate(options);
return fse.writeFileAsync(path.join(debianDir, 'control'), controlFileContents);
});
} | [
"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",
"(",
"controlFileTemplate",
")",
"{",
"controlFileTemplate",
"=",
"_",
"(",
"controlFileTemplate",
")",
".",
"template",
"(",
")",
";",
"var",
"controlFileContents",
"=",
"controlFileTemplate",
"(",
"options",
")",
";",
"return",
"fse",
".",
"writeFileAsync",
"(",
"path",
".",
"join",
"(",
"debianDir",
",",
"'control'",
")",
",",
"controlFileContents",
")",
";",
"}",
")",
";",
"}"
] | 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 |
50,237 | 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, log);
} else {
data = [log, log];
app.emit('access_log', log, 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, log);
} else {
data = [log, log];
app.emit('access_log', log, data);
}
} | [
"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",
",",
"log",
")",
";",
"}",
"else",
"{",
"data",
"=",
"[",
"log",
",",
"log",
"]",
";",
"app",
".",
"emit",
"(",
"'access_log'",
",",
"log",
",",
"data",
")",
";",
"}",
"}"
] | Access Log Callback | [
"Access",
"Log",
"Callback"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/logger/logger.js#L176-L187 |
|
50,238 | 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",
".",
"_collections",
"[",
"coll",
"]",
"(",
"null",
",",
"{",
"parent",
":",
"this",
",",
"parse",
":",
"true",
"}",
")",
";",
"}",
"}"
] | 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 |
50,239 | 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], 'all', this._getEventBubblingHandler(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], 'all', this._getEventBubblingHandler(child));
}
} | [
"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",
"]",
",",
"'all'",
",",
"this",
".",
"_getEventBubblingHandler",
"(",
"child",
")",
")",
";",
"}",
"}"
] | 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 |
50,240 | 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 (options.session && def.session || options.props && !def.session) {
var val = raw ? this._values[item] : this[item];
if (typeof val === 'undefined') {
val = (0, _lodash8.default)(def, 'default');
}
if (typeof val !== 'undefined') {
res[item] = val;
}
}
}
if (options.derived) {
for (var item in this._derived) {
res[item] = this[item];
}
}
if (options.children) {
for (var child in this._children) {
if (this[child].getAttributes) {
res[child] = this[child].getAttributes(options, raw);
}
}
}
if (options.collections) {
for (var coll in this._collections) {
res[coll] = this[coll].models;
}
}
return res;
} | 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 (options.session && def.session || options.props && !def.session) {
var val = raw ? this._values[item] : this[item];
if (typeof val === 'undefined') {
val = (0, _lodash8.default)(def, 'default');
}
if (typeof val !== 'undefined') {
res[item] = val;
}
}
}
if (options.derived) {
for (var item in this._derived) {
res[item] = this[item];
}
}
if (options.children) {
for (var child in this._children) {
if (this[child].getAttributes) {
res[child] = this[child].getAttributes(options, raw);
}
}
}
if (options.collections) {
for (var coll in this._collections) {
res[coll] = this[coll].models;
}
}
return res;
} | [
"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",
"(",
"options",
".",
"session",
"&&",
"def",
".",
"session",
"||",
"options",
".",
"props",
"&&",
"!",
"def",
".",
"session",
")",
"{",
"var",
"val",
"=",
"raw",
"?",
"this",
".",
"_values",
"[",
"item",
"]",
":",
"this",
"[",
"item",
"]",
";",
"if",
"(",
"typeof",
"val",
"===",
"'undefined'",
")",
"{",
"val",
"=",
"(",
"0",
",",
"_lodash8",
".",
"default",
")",
"(",
"def",
",",
"'default'",
")",
";",
"}",
"if",
"(",
"typeof",
"val",
"!==",
"'undefined'",
")",
"{",
"res",
"[",
"item",
"]",
"=",
"val",
";",
"}",
"}",
"}",
"if",
"(",
"options",
".",
"derived",
")",
"{",
"for",
"(",
"var",
"item",
"in",
"this",
".",
"_derived",
")",
"{",
"res",
"[",
"item",
"]",
"=",
"this",
"[",
"item",
"]",
";",
"}",
"}",
"if",
"(",
"options",
".",
"children",
")",
"{",
"for",
"(",
"var",
"child",
"in",
"this",
".",
"_children",
")",
"{",
"if",
"(",
"this",
"[",
"child",
"]",
".",
"getAttributes",
")",
"{",
"res",
"[",
"child",
"]",
"=",
"this",
"[",
"child",
"]",
".",
"getAttributes",
"(",
"options",
",",
"raw",
")",
";",
"}",
"}",
"}",
"if",
"(",
"options",
".",
"collections",
")",
"{",
"for",
"(",
"var",
"coll",
"in",
"this",
".",
"_collections",
")",
"{",
"res",
"[",
"coll",
"]",
"=",
"this",
"[",
"coll",
"]",
".",
"models",
";",
"}",
"}",
"return",
"res",
";",
"}"
] | 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 with its data type.
@returns {Object} The plain-JS model object. | [
"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 |
50,241 | 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. */
var attributes = model.attributes;
// The ID is outside of the other attributes.
attributes.id = model.id;
attributes.type = model.type;
// We have to remember this so that we can parse the children
this._attrs = attributes;
return attributes;
} | 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. */
var attributes = model.attributes;
// The ID is outside of the other attributes.
attributes.id = model.id;
attributes.type = model.type;
// We have to remember this so that we can parse the children
this._attrs = attributes;
return attributes;
} | [
"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. */",
"var",
"attributes",
"=",
"model",
".",
"attributes",
";",
"// The ID is outside of the other attributes.",
"attributes",
".",
"id",
"=",
"model",
".",
"id",
";",
"attributes",
".",
"type",
"=",
"model",
".",
"type",
";",
"// We have to remember this so that we can parse the children",
"this",
".",
"_attrs",
"=",
"attributes",
";",
"return",
"attributes",
";",
"}"
] | 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 |
50,242 | 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, modelOptions);
}
model.trigger('error', model, resp, modelOptions);
};
}
// Handle both `"key", value` and `{key: value}` -style arguments.
if (key == null || (typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object') {
attrs = key;
options = val;
} else {
attrs[key] = val;
options = opts;
}
options = (0, _lodash2.default)({ validate: true }, options);
// If we're not waiting and attributes exist, save acts as
// `set(attr).save(null, opts)` with validation. Otherwise, check if
// the model will be valid when the attributes, if any, are set.
if (attrs && !options.wait) {
if (!this.set(attrs, options)) {
return false;
}
} else if (!this._validate(attrs, options)) {
return false;
}
// After a successful server-side save, the client is (optionally)
// updated with the server-side state.
if (options.parse == null) {
options.parse = true;
}
var success = options.success;
options.success = function (resp) {
var serverAttrs = _this.parse(resp, options);
if (options.wait) {
serverAttrs = (0, _lodash2.default)(attrs || {}, serverAttrs);
}
if ((0, _lodash6.default)(serverAttrs) && !_this.set(serverAttrs, options)) {
return false;
}
if (success) {
success(_this, resp, options);
}
_this.trigger('sync', _this, resp, options);
};
wrapError(this, options);
method = this.isNew() ? 'create' : options.patch ? 'patch' : 'update';
if (method === 'patch') {
options.attrs = transformForPatch(this.serialize(), attrs);
}
// if we're waiting we haven't actually set our attributes yet so
// we need to do make sure we send right data
if (options.wait && method !== 'patch') {
var clonedModel = new this.constructor(this.getAttributes({
props: true
}));
clonedModel.set(attrs);
options.attrs = clonedModel.serialize();
}
sync = this.sync(method, this, options);
// Make the request available on the options object so it can be accessed
// further down the line by `parse`, attached listeners, etc
// Same thing is done for fetch and destroy
options.xhr = sync;
return sync;
} | 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, modelOptions);
}
model.trigger('error', model, resp, modelOptions);
};
}
// Handle both `"key", value` and `{key: value}` -style arguments.
if (key == null || (typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'object') {
attrs = key;
options = val;
} else {
attrs[key] = val;
options = opts;
}
options = (0, _lodash2.default)({ validate: true }, options);
// If we're not waiting and attributes exist, save acts as
// `set(attr).save(null, opts)` with validation. Otherwise, check if
// the model will be valid when the attributes, if any, are set.
if (attrs && !options.wait) {
if (!this.set(attrs, options)) {
return false;
}
} else if (!this._validate(attrs, options)) {
return false;
}
// After a successful server-side save, the client is (optionally)
// updated with the server-side state.
if (options.parse == null) {
options.parse = true;
}
var success = options.success;
options.success = function (resp) {
var serverAttrs = _this.parse(resp, options);
if (options.wait) {
serverAttrs = (0, _lodash2.default)(attrs || {}, serverAttrs);
}
if ((0, _lodash6.default)(serverAttrs) && !_this.set(serverAttrs, options)) {
return false;
}
if (success) {
success(_this, resp, options);
}
_this.trigger('sync', _this, resp, options);
};
wrapError(this, options);
method = this.isNew() ? 'create' : options.patch ? 'patch' : 'update';
if (method === 'patch') {
options.attrs = transformForPatch(this.serialize(), attrs);
}
// if we're waiting we haven't actually set our attributes yet so
// we need to do make sure we send right data
if (options.wait && method !== 'patch') {
var clonedModel = new this.constructor(this.getAttributes({
props: true
}));
clonedModel.set(attrs);
options.attrs = clonedModel.serialize();
}
sync = this.sync(method, this, options);
// Make the request available on the options object so it can be accessed
// further down the line by `parse`, attached listeners, etc
// Same thing is done for fetch and destroy
options.xhr = sync;
return sync;
} | [
"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",
",",
"modelOptions",
")",
";",
"}",
"model",
".",
"trigger",
"(",
"'error'",
",",
"model",
",",
"resp",
",",
"modelOptions",
")",
";",
"}",
";",
"}",
"// Handle both `\"key\", value` and `{key: value}` -style arguments.",
"if",
"(",
"key",
"==",
"null",
"||",
"(",
"typeof",
"key",
"===",
"'undefined'",
"?",
"'undefined'",
":",
"_typeof",
"(",
"key",
")",
")",
"===",
"'object'",
")",
"{",
"attrs",
"=",
"key",
";",
"options",
"=",
"val",
";",
"}",
"else",
"{",
"attrs",
"[",
"key",
"]",
"=",
"val",
";",
"options",
"=",
"opts",
";",
"}",
"options",
"=",
"(",
"0",
",",
"_lodash2",
".",
"default",
")",
"(",
"{",
"validate",
":",
"true",
"}",
",",
"options",
")",
";",
"// If we're not waiting and attributes exist, save acts as",
"// `set(attr).save(null, opts)` with validation. Otherwise, check if",
"// the model will be valid when the attributes, if any, are set.",
"if",
"(",
"attrs",
"&&",
"!",
"options",
".",
"wait",
")",
"{",
"if",
"(",
"!",
"this",
".",
"set",
"(",
"attrs",
",",
"options",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"this",
".",
"_validate",
"(",
"attrs",
",",
"options",
")",
")",
"{",
"return",
"false",
";",
"}",
"// After a successful server-side save, the client is (optionally)",
"// updated with the server-side state.",
"if",
"(",
"options",
".",
"parse",
"==",
"null",
")",
"{",
"options",
".",
"parse",
"=",
"true",
";",
"}",
"var",
"success",
"=",
"options",
".",
"success",
";",
"options",
".",
"success",
"=",
"function",
"(",
"resp",
")",
"{",
"var",
"serverAttrs",
"=",
"_this",
".",
"parse",
"(",
"resp",
",",
"options",
")",
";",
"if",
"(",
"options",
".",
"wait",
")",
"{",
"serverAttrs",
"=",
"(",
"0",
",",
"_lodash2",
".",
"default",
")",
"(",
"attrs",
"||",
"{",
"}",
",",
"serverAttrs",
")",
";",
"}",
"if",
"(",
"(",
"0",
",",
"_lodash6",
".",
"default",
")",
"(",
"serverAttrs",
")",
"&&",
"!",
"_this",
".",
"set",
"(",
"serverAttrs",
",",
"options",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"success",
")",
"{",
"success",
"(",
"_this",
",",
"resp",
",",
"options",
")",
";",
"}",
"_this",
".",
"trigger",
"(",
"'sync'",
",",
"_this",
",",
"resp",
",",
"options",
")",
";",
"}",
";",
"wrapError",
"(",
"this",
",",
"options",
")",
";",
"method",
"=",
"this",
".",
"isNew",
"(",
")",
"?",
"'create'",
":",
"options",
".",
"patch",
"?",
"'patch'",
":",
"'update'",
";",
"if",
"(",
"method",
"===",
"'patch'",
")",
"{",
"options",
".",
"attrs",
"=",
"transformForPatch",
"(",
"this",
".",
"serialize",
"(",
")",
",",
"attrs",
")",
";",
"}",
"// if we're waiting we haven't actually set our attributes yet so",
"// we need to do make sure we send right data",
"if",
"(",
"options",
".",
"wait",
"&&",
"method",
"!==",
"'patch'",
")",
"{",
"var",
"clonedModel",
"=",
"new",
"this",
".",
"constructor",
"(",
"this",
".",
"getAttributes",
"(",
"{",
"props",
":",
"true",
"}",
")",
")",
";",
"clonedModel",
".",
"set",
"(",
"attrs",
")",
";",
"options",
".",
"attrs",
"=",
"clonedModel",
".",
"serialize",
"(",
")",
";",
"}",
"sync",
"=",
"this",
".",
"sync",
"(",
"method",
",",
"this",
",",
"options",
")",
";",
"// Make the request available on the options object so it can be accessed",
"// further down the line by `parse`, attached listeners, etc",
"// Same thing is done for fetch and destroy",
"options",
".",
"xhr",
"=",
"sync",
";",
"return",
"sync",
";",
"}"
] | 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 string: the value of the
property to change. If `key` is an object:
method options as described under `opts`.
@param {Object|undefined} opts - Options to be used by `save` and
shared with `ampersand-sync`. If
`key` is an object, this parameter
is ignored.
@returns {Object} An XHR object. | [
"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 |
50,243 | 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: {
id: _this2[key].id,
type: _this2[key].type
}
};
}, this);
delete res.id;
return {
data: {
id: id,
type: this.type,
attributes: res,
relationships: relationships
}
};
} | 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: {
id: _this2[key].id,
type: _this2[key].type
}
};
}, this);
delete res.id;
return {
data: {
id: id,
type: this.type,
attributes: res,
relationships: relationships
}
};
} | [
"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",
":",
"{",
"id",
":",
"_this2",
"[",
"key",
"]",
".",
"id",
",",
"type",
":",
"_this2",
"[",
"key",
"]",
".",
"type",
"}",
"}",
";",
"}",
",",
"this",
")",
";",
"delete",
"res",
".",
"id",
";",
"return",
"{",
"data",
":",
"{",
"id",
":",
"id",
",",
"type",
":",
"this",
".",
"type",
",",
"attributes",
":",
"res",
",",
"relationships",
":",
"relationships",
"}",
"}",
";",
"}"
] | 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 |
50,244 | 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\"",
")",
";",
"}",
"if",
"(",
"body",
".",
"scrollHeight",
"-",
"body",
".",
"scrollTop",
">",
"body",
".",
"clientHeight",
")",
"{",
"$",
".",
"addClass",
"(",
"body",
",",
"\"bottom\"",
")",
";",
"}",
"else",
"{",
"$",
".",
"removeClass",
"(",
"body",
",",
"\"bottom\"",
")",
";",
"}",
"}"
] | 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",
"is",
"displayed",
".",
"If",
"the",
"user",
"can",
"scroll",
"down",
"a",
"thin",
"bottom",
"inset",
"shadow",
"is",
"displayed",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.modal.js#L261-L273 |
50,245 | 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",
"]",
";",
"if",
"(",
"node",
"&&",
"node",
".",
"length",
">=",
"3",
"&&",
"node",
"[",
"0",
"]",
"==",
"'='",
")",
"{",
"// looking for ['=', id, val]",
"runtime",
".",
"ast",
"(",
")",
"[",
"node",
"[",
"1",
"]",
"]",
"=",
"{",
"'ast'",
":",
"[",
"node",
"]",
"}",
";",
"runtime",
".",
"source",
"(",
")",
"[",
"node",
"[",
"1",
"]",
"]",
"=",
"source",
";",
"}",
"}",
"}"
] | 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 |
|
50,246 | 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);
}
};
mw.toString = function () {
return '<miniwrite-stream>';
};
return mw;
} | 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);
}
};
mw.toString = function () {
return '<miniwrite-stream>';
};
return mw;
} | [
"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",
")",
";",
"}",
"}",
";",
"mw",
".",
"toString",
"=",
"function",
"(",
")",
"{",
"return",
"'<miniwrite-stream>'",
";",
"}",
";",
"return",
"mw",
";",
"}"
] | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - node.js stream | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"node",
".",
"js",
"stream"
] | 0b716dfdd203e20bdf71b552d1776ade8a55ced5 | https://github.com/Bartvds/miniwrite/blob/0b716dfdd203e20bdf71b552d1776ade8a55ced5/lib/io.js#L44-L60 |
50,247 | 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">' + test_languages[i]['protocol'] + '</td>';
retval += '<td class="testInputLanguage">(' + test_languages[i][
'plaintext_regex'
].substr(0,16) + ', ' + test_languages[i]['plaintext_max_len'] + ')</td>';
if (test_languages[i]['protocol'] == "stream cipher") {
retval += '<td class="testInputLaguage">(^.+$, ' + test_languages[i]['ciphertext_max_len'] + ')</td>';
} else {
retval += '<td class="testInputLaguage">(-, ' + test_languages[i]['ciphertext_max_len'] + ')</td>';
}
retval += '<td class="testCost">';
retval += '-';
retval += '</td>';
retval += '<td class="testBandwidth">';
retval += '-';
retval += '</td>';
retval += '</tr>';
document.getElementById('FteBenchmarkResults').innerHTML += retval;
}
} | 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">' + test_languages[i]['protocol'] + '</td>';
retval += '<td class="testInputLanguage">(' + test_languages[i][
'plaintext_regex'
].substr(0,16) + ', ' + test_languages[i]['plaintext_max_len'] + ')</td>';
if (test_languages[i]['protocol'] == "stream cipher") {
retval += '<td class="testInputLaguage">(^.+$, ' + test_languages[i]['ciphertext_max_len'] + ')</td>';
} else {
retval += '<td class="testInputLaguage">(-, ' + test_languages[i]['ciphertext_max_len'] + ')</td>';
}
retval += '<td class="testCost">';
retval += '-';
retval += '</td>';
retval += '<td class="testBandwidth">';
retval += '-';
retval += '</td>';
retval += '</tr>';
document.getElementById('FteBenchmarkResults').innerHTML += retval;
}
} | [
"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\">'",
"+",
"test_languages",
"[",
"i",
"]",
"[",
"'protocol'",
"]",
"+",
"'</td>'",
";",
"retval",
"+=",
"'<td class=\"testInputLanguage\">('",
"+",
"test_languages",
"[",
"i",
"]",
"[",
"'plaintext_regex'",
"]",
".",
"substr",
"(",
"0",
",",
"16",
")",
"+",
"', '",
"+",
"test_languages",
"[",
"i",
"]",
"[",
"'plaintext_max_len'",
"]",
"+",
"')</td>'",
";",
"if",
"(",
"test_languages",
"[",
"i",
"]",
"[",
"'protocol'",
"]",
"==",
"\"stream cipher\"",
")",
"{",
"retval",
"+=",
"'<td class=\"testInputLaguage\">(^.+$, '",
"+",
"test_languages",
"[",
"i",
"]",
"[",
"'ciphertext_max_len'",
"]",
"+",
"')</td>'",
";",
"}",
"else",
"{",
"retval",
"+=",
"'<td class=\"testInputLaguage\">(-, '",
"+",
"test_languages",
"[",
"i",
"]",
"[",
"'ciphertext_max_len'",
"]",
"+",
"')</td>'",
";",
"}",
"retval",
"+=",
"'<td class=\"testCost\">'",
";",
"retval",
"+=",
"'-'",
";",
"retval",
"+=",
"'</td>'",
";",
"retval",
"+=",
"'<td class=\"testBandwidth\">'",
";",
"retval",
"+=",
"'-'",
";",
"retval",
"+=",
"'</td>'",
";",
"retval",
"+=",
"'</tr>'",
";",
"document",
".",
"getElementById",
"(",
"'FteBenchmarkResults'",
")",
".",
"innerHTML",
"+=",
"retval",
";",
"}",
"}"
] | 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 |
50,248 | 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 |
|
50,249 | 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[1] = start;
end = parseInt('' + args[2]);
if(isNaN(end)) throw IntegerRange;
args[2] = end;
}
} | 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[1] = start;
end = parseInt('' + args[2]);
if(isNaN(end)) throw IntegerRange;
args[2] = end;
}
} | [
"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",
"[",
"1",
"]",
"=",
"start",
";",
"end",
"=",
"parseInt",
"(",
"''",
"+",
"args",
"[",
"2",
"]",
")",
";",
"if",
"(",
"isNaN",
"(",
"end",
")",
")",
"throw",
"IntegerRange",
";",
"args",
"[",
"2",
"]",
"=",
"end",
";",
"}",
"}"
] | 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 |
50,250 | 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",
"=",
"c",
"[",
"'connect-sid'",
"]",
"debug",
"(",
"'serialized'",
",",
"sid",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"debug",
"(",
"e",
")",
"}",
"return",
"cookie",
"}"
] | 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 |
50,251 | 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",
"(",
"'connect.sid'",
",",
"cookies",
"[",
"'connect.sid'",
"]",
")",
"fs",
".",
"writeFileSync",
"(",
"cookiePath",
",",
"JSON",
".",
"stringify",
"(",
"cookies",
")",
")",
"}",
"catch",
"(",
"e",
")",
"{",
"debug",
"(",
"e",
")",
"}",
"}"
] | 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 |
50,252 | 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",
"=",
"ret",
".",
"conn",
"conn",
".",
"close",
"(",
")",
"}",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"conn",
")",
"{",
"var",
"conn",
"=",
"err",
".",
"conn",
"conn",
".",
"close",
"(",
")",
"}",
"console",
".",
"error",
"(",
"err",
".",
"err",
")",
"}",
")",
"}"
] | 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 |
50,253 | 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",
"(",
"','",
")",
"if",
"(",
"a",
"&&",
"a",
"[",
"1",
"]",
")",
"{",
"ret",
"=",
"parseInt",
"(",
"a",
"[",
"1",
"]",
")",
"}",
"else",
"{",
"return",
"null",
"}",
"if",
"(",
"isNaN",
"(",
"ret",
")",
")",
"{",
"return",
"null",
"}",
"return",
"ret",
"}"
] | 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 |
50,254 | 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",
"(",
"','",
")",
"if",
"(",
"a",
"&&",
"a",
"[",
"2",
"]",
")",
"{",
"ret",
"=",
"a",
"[",
"2",
"]",
"return",
"ret",
"}",
"else",
"{",
"return",
"null",
"}",
"if",
"(",
"isNaN",
"(",
"ret",
")",
")",
"{",
"return",
"null",
"}",
"return",
"ret",
"}"
] | 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 |
50,255 | 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",
".",
"split",
"(",
"','",
")",
"if",
"(",
"a",
"&&",
"a",
"[",
"0",
"]",
")",
"{",
"var",
"end",
"=",
"a",
"[",
"0",
"]",
"ret",
"=",
"parseInt",
"(",
"end",
")",
"return",
"ret",
"}",
"else",
"{",
"return",
"null",
"}",
"if",
"(",
"isNaN",
"(",
"ret",
")",
")",
"{",
"return",
"null",
"}",
"return",
"ret",
"}"
] | 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 |
50,256 | 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);
i++;
}
return result;
};
}
if (_.isArray(property)) return multisort(property);
debug('sorting by %s', property || '');
var sortOrder = 1;
// property may be preparsed object
if (_.isObject(property)) {
var propertyKey = _.keys(property)[0];
sortOrder = property[propertyKey];
property = propertyKey;
}
else if (property[0] === '-') {
sortOrder = -1;
property = property.substr(1);
}
function compare(a, b) {
var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
return result * sortOrder;
}
return compare;
} | 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);
i++;
}
return result;
};
}
if (_.isArray(property)) return multisort(property);
debug('sorting by %s', property || '');
var sortOrder = 1;
// property may be preparsed object
if (_.isObject(property)) {
var propertyKey = _.keys(property)[0];
sortOrder = property[propertyKey];
property = propertyKey;
}
else if (property[0] === '-') {
sortOrder = -1;
property = property.substr(1);
}
function compare(a, b) {
var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
return result * sortOrder;
}
return compare;
} | [
"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",
")",
";",
"i",
"++",
";",
"}",
"return",
"result",
";",
"}",
";",
"}",
"if",
"(",
"_",
".",
"isArray",
"(",
"property",
")",
")",
"return",
"multisort",
"(",
"property",
")",
";",
"debug",
"(",
"'sorting by %s'",
",",
"property",
"||",
"''",
")",
";",
"var",
"sortOrder",
"=",
"1",
";",
"// property may be preparsed object",
"if",
"(",
"_",
".",
"isObject",
"(",
"property",
")",
")",
"{",
"var",
"propertyKey",
"=",
"_",
".",
"keys",
"(",
"property",
")",
"[",
"0",
"]",
";",
"sortOrder",
"=",
"property",
"[",
"propertyKey",
"]",
";",
"property",
"=",
"propertyKey",
";",
"}",
"else",
"if",
"(",
"property",
"[",
"0",
"]",
"===",
"'-'",
")",
"{",
"sortOrder",
"=",
"-",
"1",
";",
"property",
"=",
"property",
".",
"substr",
"(",
"1",
")",
";",
"}",
"function",
"compare",
"(",
"a",
",",
"b",
")",
"{",
"var",
"result",
"=",
"(",
"a",
"[",
"property",
"]",
"<",
"b",
"[",
"property",
"]",
")",
"?",
"-",
"1",
":",
"(",
"a",
"[",
"property",
"]",
">",
"b",
"[",
"property",
"]",
")",
"?",
"1",
":",
"0",
";",
"return",
"result",
"*",
"sortOrder",
";",
"}",
"return",
"compare",
";",
"}"
] | 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 |
50,257 | 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",
";",
"while",
"(",
"result",
"===",
"0",
"&&",
"i",
"<",
"numberOfProperties",
")",
"{",
"result",
"=",
"sort",
"(",
"properties",
"[",
"i",
"]",
")",
"(",
"a",
",",
"b",
")",
";",
"i",
"++",
";",
"}",
"return",
"result",
";",
"}",
";",
"}"
] | sort by multiple properties | [
"sort",
"by",
"multiple",
"properties"
] | d1449f579dc4fa67be02b11f57aee74d40f3cf95 | https://github.com/Everyplay/backbone-db-local/blob/d1449f579dc4fa67be02b11f57aee74d40f3cf95/index.js#L53-L64 |
50,258 | 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",
",",
"error",
":",
"errorMessage",
",",
"details",
":",
"errorDetails",
",",
"}",
";",
"}"
] | `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 |
50,259 | 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",
",",
"host",
",",
"redisOpts",
")",
";",
"}",
"}"
] | 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 |
50,260 | jldec/pub-src-redis | pub-src-redis.js | clear | function clear(options, cb) {
if (typeof options === 'function') { cb = options; options = {}; }
debug('clear ' + key);
connect();
redis.del(key, cb);
} | javascript | function clear(options, cb) {
if (typeof options === 'function') { cb = options; options = {}; }
debug('clear ' + key);
connect();
redis.del(key, cb);
} | [
"function",
"clear",
"(",
"options",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"cb",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"debug",
"(",
"'clear '",
"+",
"key",
")",
";",
"connect",
"(",
")",
";",
"redis",
".",
"del",
"(",
"key",
",",
"cb",
")",
";",
"}"
] | redis-specific api - used for testing | [
"redis",
"-",
"specific",
"api",
"-",
"used",
"for",
"testing"
] | d18e13fde82ff969571f59790e15098a5edbd89e | https://github.com/jldec/pub-src-redis/blob/d18e13fde82ff969571f59790e15098a5edbd89e/pub-src-redis.js#L165-L170 |
50,261 | iamjamilspain/titanium-jsduck | titanium-jsduck.js | runHelp | function runHelp(){
var messageHelp = "Usage: titanium-jsduck [command] [parameters]\n\n";
messageHelp += "Commands:\n\tinstall \n\t\t- Installs JSDuck inside a Titanium Mobile Project.";
messageHelp += "\n\topen \n\t\t- Opens Documentation in Safari Browser";
messageHelp += "\n\topen firefox \n\t\t- Opens Documentation in Firefox Browser";
messageHelp += "\n\topen chrome \n\t\t- Opens Documentation in Google Chrome Browser";
messageHelp += "\n\trun \n\t\t- Runs jsduck to generate Documentation without compiling Mobile Project";
console.log(messageHelp);
console.log();
console.log();
process.exit();
} | javascript | function runHelp(){
var messageHelp = "Usage: titanium-jsduck [command] [parameters]\n\n";
messageHelp += "Commands:\n\tinstall \n\t\t- Installs JSDuck inside a Titanium Mobile Project.";
messageHelp += "\n\topen \n\t\t- Opens Documentation in Safari Browser";
messageHelp += "\n\topen firefox \n\t\t- Opens Documentation in Firefox Browser";
messageHelp += "\n\topen chrome \n\t\t- Opens Documentation in Google Chrome Browser";
messageHelp += "\n\trun \n\t\t- Runs jsduck to generate Documentation without compiling Mobile Project";
console.log(messageHelp);
console.log();
console.log();
process.exit();
} | [
"function",
"runHelp",
"(",
")",
"{",
"var",
"messageHelp",
"=",
"\"Usage: titanium-jsduck [command] [parameters]\\n\\n\"",
";",
"messageHelp",
"+=",
"\"Commands:\\n\\tinstall \\n\\t\\t- Installs JSDuck inside a Titanium Mobile Project.\"",
";",
"messageHelp",
"+=",
"\"\\n\\topen \\n\\t\\t- Opens Documentation in Safari Browser\"",
";",
"messageHelp",
"+=",
"\"\\n\\topen firefox \\n\\t\\t- Opens Documentation in Firefox Browser\"",
";",
"messageHelp",
"+=",
"\"\\n\\topen chrome \\n\\t\\t- Opens Documentation in Google Chrome Browser\"",
";",
"messageHelp",
"+=",
"\"\\n\\trun \\n\\t\\t- Runs jsduck to generate Documentation without compiling Mobile Project\"",
";",
"console",
".",
"log",
"(",
"messageHelp",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"process",
".",
"exit",
"(",
")",
";",
"}"
] | Main Command Methods | [
"Main",
"Command",
"Methods"
] | f79ffa1c6386c16dfb59710d9a6a94cfc66439f6 | https://github.com/iamjamilspain/titanium-jsduck/blob/f79ffa1c6386c16dfb59710d9a6a94cfc66439f6/titanium-jsduck.js#L151-L164 |
50,262 | tolokoban/ToloFrameWork | lib/pathutils.js | file | function file( path, content ) {
try {
if ( typeof content === 'undefined' ) {
if ( !FS.existsSync( path ) ) return null;
return FS.readFileSync( path );
}
const dir = Path.dirname( path );
mkdir( dir );
FS.writeFileSync( path, content );
return content;
} catch ( ex ) {
console.warn( "content:", content );
throw new Error( `${ex}\n...in pathutils/file("${path}", ${typeof content})` );
}
} | javascript | function file( path, content ) {
try {
if ( typeof content === 'undefined' ) {
if ( !FS.existsSync( path ) ) return null;
return FS.readFileSync( path );
}
const dir = Path.dirname( path );
mkdir( dir );
FS.writeFileSync( path, content );
return content;
} catch ( ex ) {
console.warn( "content:", content );
throw new Error( `${ex}\n...in pathutils/file("${path}", ${typeof content})` );
}
} | [
"function",
"file",
"(",
"path",
",",
"content",
")",
"{",
"try",
"{",
"if",
"(",
"typeof",
"content",
"===",
"'undefined'",
")",
"{",
"if",
"(",
"!",
"FS",
".",
"existsSync",
"(",
"path",
")",
")",
"return",
"null",
";",
"return",
"FS",
".",
"readFileSync",
"(",
"path",
")",
";",
"}",
"const",
"dir",
"=",
"Path",
".",
"dirname",
"(",
"path",
")",
";",
"mkdir",
"(",
"dir",
")",
";",
"FS",
".",
"writeFileSync",
"(",
"path",
",",
"content",
")",
";",
"return",
"content",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"console",
".",
"warn",
"(",
"\"content:\"",
",",
"content",
")",
";",
"throw",
"new",
"Error",
"(",
"`",
"${",
"ex",
"}",
"\\n",
"${",
"path",
"}",
"${",
"typeof",
"content",
"}",
"`",
")",
";",
"}",
"}"
] | Read or write the content of a file.
If `content` is undefined, the content is read, otherwise it is
written.
If the file to be written is in a non-existent subfolder, the whole
path will be created with the `mkdir`function.
@param {string} path - Path of the file to read or write.
@param {string} content - Optional. If omitted, we return the content of the file.
Otherwise, we save this content to the file.
@returns {string} The file content. | [
"Read",
"or",
"write",
"the",
"content",
"of",
"a",
"file",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/pathutils.js#L168-L182 |
50,263 | tolokoban/ToloFrameWork | lib/pathutils.js | touch | function touch( path ) {
if ( FS.existsSync( path ) ) {
const content = FS.readFileSync( path );
FS.writeFileSync( path, content );
console.log( `File has been touched: ${path.yellow} (${(size(path) * BYTES_TO_KB).toFixed(1)} kb)` );
return true;
}
return false;
} | javascript | function touch( path ) {
if ( FS.existsSync( path ) ) {
const content = FS.readFileSync( path );
FS.writeFileSync( path, content );
console.log( `File has been touched: ${path.yellow} (${(size(path) * BYTES_TO_KB).toFixed(1)} kb)` );
return true;
}
return false;
} | [
"function",
"touch",
"(",
"path",
")",
"{",
"if",
"(",
"FS",
".",
"existsSync",
"(",
"path",
")",
")",
"{",
"const",
"content",
"=",
"FS",
".",
"readFileSync",
"(",
"path",
")",
";",
"FS",
".",
"writeFileSync",
"(",
"path",
",",
"content",
")",
";",
"console",
".",
"log",
"(",
"`",
"${",
"path",
".",
"yellow",
"}",
"${",
"(",
"size",
"(",
"path",
")",
"*",
"BYTES_TO_KB",
")",
".",
"toFixed",
"(",
"1",
")",
"}",
"`",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Set current date as modification time to a file.
@param {string} path - Path of the file to touch.
@returns {boolean} `true` is the file exists. | [
"Set",
"current",
"date",
"as",
"modification",
"time",
"to",
"a",
"file",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/lib/pathutils.js#L207-L215 |
50,264 | RealGeeks/mallet | index.js | invokeArrayArg | function invokeArrayArg(arg, fn, context) {
if (Array.isArray(arg)) {
arg.forEach(context[fn], context);
return true;
}
return false;
} | javascript | function invokeArrayArg(arg, fn, context) {
if (Array.isArray(arg)) {
arg.forEach(context[fn], context);
return true;
}
return false;
} | [
"function",
"invokeArrayArg",
"(",
"arg",
",",
"fn",
",",
"context",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"arg",
")",
")",
"{",
"arg",
".",
"forEach",
"(",
"context",
"[",
"fn",
"]",
",",
"context",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | if the argument is an array, we want to execute the fn on each entry
if it aint an array we don't want to do a thing.
this is used by all the methods that accept a single and array argument.
@param {*|Array} arg
@param {String} fn
@param {Object} [context]
@returns {Boolean} | [
"if",
"the",
"argument",
"is",
"an",
"array",
"we",
"want",
"to",
"execute",
"the",
"fn",
"on",
"each",
"entry",
"if",
"it",
"aint",
"an",
"array",
"we",
"don",
"t",
"want",
"to",
"do",
"a",
"thing",
".",
"this",
"is",
"used",
"by",
"all",
"the",
"methods",
"that",
"accept",
"a",
"single",
"and",
"array",
"argument",
"."
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L40-L46 |
50,265 | RealGeeks/mallet | index.js | prefixed | function prefixed(obj, property) {
var prefix;
var prop;
var camelProp = property[0].toUpperCase() + property.slice(1);
var i = 0;
while (i < VENDOR_PREFIXES.length) {
prefix = VENDOR_PREFIXES[i];
prop = (prefix) ? prefix + camelProp : property;
if (prop in obj) {
return prop;
}
i++;
}
return undefined;
} | javascript | function prefixed(obj, property) {
var prefix;
var prop;
var camelProp = property[0].toUpperCase() + property.slice(1);
var i = 0;
while (i < VENDOR_PREFIXES.length) {
prefix = VENDOR_PREFIXES[i];
prop = (prefix) ? prefix + camelProp : property;
if (prop in obj) {
return prop;
}
i++;
}
return undefined;
} | [
"function",
"prefixed",
"(",
"obj",
",",
"property",
")",
"{",
"var",
"prefix",
";",
"var",
"prop",
";",
"var",
"camelProp",
"=",
"property",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"property",
".",
"slice",
"(",
"1",
")",
";",
"var",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"VENDOR_PREFIXES",
".",
"length",
")",
"{",
"prefix",
"=",
"VENDOR_PREFIXES",
"[",
"i",
"]",
";",
"prop",
"=",
"(",
"prefix",
")",
"?",
"prefix",
"+",
"camelProp",
":",
"property",
";",
"if",
"(",
"prop",
"in",
"obj",
")",
"{",
"return",
"prop",
";",
"}",
"i",
"++",
";",
"}",
"return",
"undefined",
";",
"}"
] | get the prefixed property
@param {Object} obj
@param {String} property
@returns {String|Undefined} prefixed | [
"get",
"the",
"prefixed",
"property"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L191-L207 |
50,266 | RealGeeks/mallet | index.js | computeInputData | function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// to compute scale and rotation we need to store the multiple touches
if (pointersLength > 1 && !session.firstMultiple) {
session.firstMultiple = simpleCloneInputData(input);
} else if (pointersLength === 1) {
session.firstMultiple = false;
}
var firstInput = session.firstInput;
var firstMultiple = session.firstMultiple;
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
var center = input.center = getCenter(pointers);
input.timeStamp = now();
input.deltaTime = input.timeStamp - firstInput.timeStamp;
input.angle = getAngle(offsetCenter, center);
input.distance = getDistance(offsetCenter, center);
computeDeltaXY(session, input);
input.offsetDirection = getDirection(input.deltaX, input.deltaY);
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
computeIntervalInputData(session, input);
// find the correct target
var target = manager.element;
if (hasParent(input.srcEvent.target, target)) {
target = input.srcEvent.target;
}
input.target = target;
} | javascript | function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// to compute scale and rotation we need to store the multiple touches
if (pointersLength > 1 && !session.firstMultiple) {
session.firstMultiple = simpleCloneInputData(input);
} else if (pointersLength === 1) {
session.firstMultiple = false;
}
var firstInput = session.firstInput;
var firstMultiple = session.firstMultiple;
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
var center = input.center = getCenter(pointers);
input.timeStamp = now();
input.deltaTime = input.timeStamp - firstInput.timeStamp;
input.angle = getAngle(offsetCenter, center);
input.distance = getDistance(offsetCenter, center);
computeDeltaXY(session, input);
input.offsetDirection = getDirection(input.deltaX, input.deltaY);
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
computeIntervalInputData(session, input);
// find the correct target
var target = manager.element;
if (hasParent(input.srcEvent.target, target)) {
target = input.srcEvent.target;
}
input.target = target;
} | [
"function",
"computeInputData",
"(",
"manager",
",",
"input",
")",
"{",
"var",
"session",
"=",
"manager",
".",
"session",
";",
"var",
"pointers",
"=",
"input",
".",
"pointers",
";",
"var",
"pointersLength",
"=",
"pointers",
".",
"length",
";",
"// store the first input to calculate the distance and direction",
"if",
"(",
"!",
"session",
".",
"firstInput",
")",
"{",
"session",
".",
"firstInput",
"=",
"simpleCloneInputData",
"(",
"input",
")",
";",
"}",
"// to compute scale and rotation we need to store the multiple touches",
"if",
"(",
"pointersLength",
">",
"1",
"&&",
"!",
"session",
".",
"firstMultiple",
")",
"{",
"session",
".",
"firstMultiple",
"=",
"simpleCloneInputData",
"(",
"input",
")",
";",
"}",
"else",
"if",
"(",
"pointersLength",
"===",
"1",
")",
"{",
"session",
".",
"firstMultiple",
"=",
"false",
";",
"}",
"var",
"firstInput",
"=",
"session",
".",
"firstInput",
";",
"var",
"firstMultiple",
"=",
"session",
".",
"firstMultiple",
";",
"var",
"offsetCenter",
"=",
"firstMultiple",
"?",
"firstMultiple",
".",
"center",
":",
"firstInput",
".",
"center",
";",
"var",
"center",
"=",
"input",
".",
"center",
"=",
"getCenter",
"(",
"pointers",
")",
";",
"input",
".",
"timeStamp",
"=",
"now",
"(",
")",
";",
"input",
".",
"deltaTime",
"=",
"input",
".",
"timeStamp",
"-",
"firstInput",
".",
"timeStamp",
";",
"input",
".",
"angle",
"=",
"getAngle",
"(",
"offsetCenter",
",",
"center",
")",
";",
"input",
".",
"distance",
"=",
"getDistance",
"(",
"offsetCenter",
",",
"center",
")",
";",
"computeDeltaXY",
"(",
"session",
",",
"input",
")",
";",
"input",
".",
"offsetDirection",
"=",
"getDirection",
"(",
"input",
".",
"deltaX",
",",
"input",
".",
"deltaY",
")",
";",
"input",
".",
"scale",
"=",
"firstMultiple",
"?",
"getScale",
"(",
"firstMultiple",
".",
"pointers",
",",
"pointers",
")",
":",
"1",
";",
"input",
".",
"rotation",
"=",
"firstMultiple",
"?",
"getRotation",
"(",
"firstMultiple",
".",
"pointers",
",",
"pointers",
")",
":",
"0",
";",
"computeIntervalInputData",
"(",
"session",
",",
"input",
")",
";",
"// find the correct target",
"var",
"target",
"=",
"manager",
".",
"element",
";",
"if",
"(",
"hasParent",
"(",
"input",
".",
"srcEvent",
".",
"target",
",",
"target",
")",
")",
"{",
"target",
"=",
"input",
".",
"srcEvent",
".",
"target",
";",
"}",
"input",
".",
"target",
"=",
"target",
";",
"}"
] | extend the data with some usable properties like scale, rotate, velocity etc
@param {Object} manager
@param {Object} input | [
"extend",
"the",
"data",
"with",
"some",
"usable",
"properties",
"like",
"scale",
"rotate",
"velocity",
"etc"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L363-L405 |
50,267 | RealGeeks/mallet | index.js | getDirection | function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
} | javascript | function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
} | [
"function",
"getDirection",
"(",
"x",
",",
"y",
")",
"{",
"if",
"(",
"x",
"===",
"y",
")",
"{",
"return",
"DIRECTION_NONE",
";",
"}",
"if",
"(",
"abs",
"(",
"x",
")",
">=",
"abs",
"(",
"y",
")",
")",
"{",
"return",
"x",
">",
"0",
"?",
"DIRECTION_LEFT",
":",
"DIRECTION_RIGHT",
";",
"}",
"return",
"y",
">",
"0",
"?",
"DIRECTION_UP",
":",
"DIRECTION_DOWN",
";",
"}"
] | get the direction between two points
@param {Number} x
@param {Number} y
@return {Number} direction | [
"get",
"the",
"direction",
"between",
"two",
"points"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L545-L554 |
50,268 | RealGeeks/mallet | index.js | getDistance | function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return Math.sqrt((x * x) + (y * y));
} | javascript | function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return Math.sqrt((x * x) + (y * y));
} | [
"function",
"getDistance",
"(",
"p1",
",",
"p2",
",",
"props",
")",
"{",
"if",
"(",
"!",
"props",
")",
"{",
"props",
"=",
"PROPS_XY",
";",
"}",
"var",
"x",
"=",
"p2",
"[",
"props",
"[",
"0",
"]",
"]",
"-",
"p1",
"[",
"props",
"[",
"0",
"]",
"]",
";",
"var",
"y",
"=",
"p2",
"[",
"props",
"[",
"1",
"]",
"]",
"-",
"p1",
"[",
"props",
"[",
"1",
"]",
"]",
";",
"return",
"Math",
".",
"sqrt",
"(",
"(",
"x",
"*",
"x",
")",
"+",
"(",
"y",
"*",
"y",
")",
")",
";",
"}"
] | calculate the absolute distance between two points
@param {Object} p1 {x, y}
@param {Object} p2 {x, y}
@param {Array} [props] containing x and y keys
@return {Number} distance | [
"calculate",
"the",
"absolute",
"distance",
"between",
"two",
"points"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L563-L571 |
50,269 | RealGeeks/mallet | index.js | getRotation | function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
} | javascript | function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
} | [
"function",
"getRotation",
"(",
"start",
",",
"end",
")",
"{",
"return",
"getAngle",
"(",
"end",
"[",
"1",
"]",
",",
"end",
"[",
"0",
"]",
",",
"PROPS_CLIENT_XY",
")",
"-",
"getAngle",
"(",
"start",
"[",
"1",
"]",
",",
"start",
"[",
"0",
"]",
",",
"PROPS_CLIENT_XY",
")",
";",
"}"
] | calculate the rotation degrees between two pointersets
@param {Array} start array of pointers
@param {Array} end array of pointers
@return {Number} rotation | [
"calculate",
"the",
"rotation",
"degrees",
"between",
"two",
"pointersets"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L595-L597 |
50,270 | RealGeeks/mallet | index.js | TouchMouseInput | function TouchMouseInput() {
Input.apply(this, arguments);
var handler = this.handler.bind(this);
this.touch = new TouchInput(this.manager, handler);
this.mouse = new MouseInput(this.manager, handler);
} | javascript | function TouchMouseInput() {
Input.apply(this, arguments);
var handler = this.handler.bind(this);
this.touch = new TouchInput(this.manager, handler);
this.mouse = new MouseInput(this.manager, handler);
} | [
"function",
"TouchMouseInput",
"(",
")",
"{",
"Input",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"handler",
"=",
"this",
".",
"handler",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"touch",
"=",
"new",
"TouchInput",
"(",
"this",
".",
"manager",
",",
"handler",
")",
";",
"this",
".",
"mouse",
"=",
"new",
"MouseInput",
"(",
"this",
".",
"manager",
",",
"handler",
")",
";",
"}"
] | Combined touch and mouse input
Touch has a higher priority then mouse, and while touching no mouse events are allowed.
This because touch devices also emit mouse events while doing a touch.
@constructor
@extends Input | [
"Combined",
"touch",
"and",
"mouse",
"input"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L935-L941 |
50,271 | RealGeeks/mallet | index.js | TMEhandler | function TMEhandler(manager, inputEvent, inputData) {
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH);
var isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
// when we're in a touch event, so block all upcoming mouse events
// most mobile browser also emit mouseevents, right after touchstart
if (isTouch) {
this.mouse.allow = false;
} else if (isMouse && !this.mouse.allow) {
return;
}
// reset the allowMouse when we're done
if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
this.mouse.allow = true;
}
this.callback(manager, inputEvent, inputData);
} | javascript | function TMEhandler(manager, inputEvent, inputData) {
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH);
var isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
// when we're in a touch event, so block all upcoming mouse events
// most mobile browser also emit mouseevents, right after touchstart
if (isTouch) {
this.mouse.allow = false;
} else if (isMouse && !this.mouse.allow) {
return;
}
// reset the allowMouse when we're done
if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
this.mouse.allow = true;
}
this.callback(manager, inputEvent, inputData);
} | [
"function",
"TMEhandler",
"(",
"manager",
",",
"inputEvent",
",",
"inputData",
")",
"{",
"var",
"isTouch",
"=",
"(",
"inputData",
".",
"pointerType",
"==",
"INPUT_TYPE_TOUCH",
")",
";",
"var",
"isMouse",
"=",
"(",
"inputData",
".",
"pointerType",
"==",
"INPUT_TYPE_MOUSE",
")",
";",
"// when we're in a touch event, so block all upcoming mouse events",
"// most mobile browser also emit mouseevents, right after touchstart",
"if",
"(",
"isTouch",
")",
"{",
"this",
".",
"mouse",
".",
"allow",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"isMouse",
"&&",
"!",
"this",
".",
"mouse",
".",
"allow",
")",
"{",
"return",
";",
"}",
"// reset the allowMouse when we're done",
"if",
"(",
"inputEvent",
"&",
"(",
"INPUT_END",
"|",
"INPUT_CANCEL",
")",
")",
"{",
"this",
".",
"mouse",
".",
"allow",
"=",
"true",
";",
"}",
"this",
".",
"callback",
"(",
"manager",
",",
"inputEvent",
",",
"inputData",
")",
";",
"}"
] | handle mouse and touch events
@param {Mallet} manager
@param {String} inputEvent
@param {Object} inputData | [
"handle",
"mouse",
"and",
"touch",
"events"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L950-L968 |
50,272 | RealGeeks/mallet | index.js | function (value) {
// find out the touch-action by the event handlers
if (value == TOUCH_ACTION_COMPUTE) {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
} | javascript | function (value) {
// find out the touch-action by the event handlers
if (value == TOUCH_ACTION_COMPUTE) {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
} | [
"function",
"(",
"value",
")",
"{",
"// find out the touch-action by the event handlers",
"if",
"(",
"value",
"==",
"TOUCH_ACTION_COMPUTE",
")",
"{",
"value",
"=",
"this",
".",
"compute",
"(",
")",
";",
"}",
"if",
"(",
"NATIVE_TOUCH_ACTION",
")",
"{",
"this",
".",
"manager",
".",
"element",
".",
"style",
"[",
"PREFIXED_TOUCH_ACTION",
"]",
"=",
"value",
";",
"}",
"this",
".",
"actions",
"=",
"value",
".",
"toLowerCase",
"(",
")",
".",
"trim",
"(",
")",
";",
"}"
] | set the touchAction value on the element or enable the polyfill
@param {String} value | [
"set",
"the",
"touchAction",
"value",
"on",
"the",
"element",
"or",
"enable",
"the",
"polyfill"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1007-L1017 |
|
50,273 | RealGeeks/mallet | index.js | function () {
var actions = [];
this.manager.recognizers.forEach(function (recognizer) {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
});
return cleanTouchActions(actions.join(' '));
} | javascript | function () {
var actions = [];
this.manager.recognizers.forEach(function (recognizer) {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
});
return cleanTouchActions(actions.join(' '));
} | [
"function",
"(",
")",
"{",
"var",
"actions",
"=",
"[",
"]",
";",
"this",
".",
"manager",
".",
"recognizers",
".",
"forEach",
"(",
"function",
"(",
"recognizer",
")",
"{",
"if",
"(",
"boolOrFn",
"(",
"recognizer",
".",
"options",
".",
"enable",
",",
"[",
"recognizer",
"]",
")",
")",
"{",
"actions",
"=",
"actions",
".",
"concat",
"(",
"recognizer",
".",
"getTouchAction",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"cleanTouchActions",
"(",
"actions",
".",
"join",
"(",
"' '",
")",
")",
";",
"}"
] | compute the value for the touchAction property based on the recognizer's settings
@returns {String} value | [
"compute",
"the",
"value",
"for",
"the",
"touchAction",
"property",
"based",
"on",
"the",
"recognizer",
"s",
"settings"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1030-L1038 |
|
50,274 | RealGeeks/mallet | index.js | function (input) {
// not needed with native support for the touchAction property
if (NATIVE_TOUCH_ACTION) {
return;
}
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
srcEvent.preventDefault();
return;
}
var actions = this.actions;
var hasNone = inStr(actions, TOUCH_ACTION_NONE);
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
if (hasNone ||
(hasPanY && direction & DIRECTION_HORIZONTAL) ||
(hasPanX && direction & DIRECTION_VERTICAL)) {
return this.preventSrc(srcEvent);
}
} | javascript | function (input) {
// not needed with native support for the touchAction property
if (NATIVE_TOUCH_ACTION) {
return;
}
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
srcEvent.preventDefault();
return;
}
var actions = this.actions;
var hasNone = inStr(actions, TOUCH_ACTION_NONE);
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
if (hasNone ||
(hasPanY && direction & DIRECTION_HORIZONTAL) ||
(hasPanX && direction & DIRECTION_VERTICAL)) {
return this.preventSrc(srcEvent);
}
} | [
"function",
"(",
"input",
")",
"{",
"// not needed with native support for the touchAction property",
"if",
"(",
"NATIVE_TOUCH_ACTION",
")",
"{",
"return",
";",
"}",
"var",
"srcEvent",
"=",
"input",
".",
"srcEvent",
";",
"var",
"direction",
"=",
"input",
".",
"offsetDirection",
";",
"// if the touch action did prevented once this session",
"if",
"(",
"this",
".",
"manager",
".",
"session",
".",
"prevented",
")",
"{",
"srcEvent",
".",
"preventDefault",
"(",
")",
";",
"return",
";",
"}",
"var",
"actions",
"=",
"this",
".",
"actions",
";",
"var",
"hasNone",
"=",
"inStr",
"(",
"actions",
",",
"TOUCH_ACTION_NONE",
")",
";",
"var",
"hasPanY",
"=",
"inStr",
"(",
"actions",
",",
"TOUCH_ACTION_PAN_Y",
")",
";",
"var",
"hasPanX",
"=",
"inStr",
"(",
"actions",
",",
"TOUCH_ACTION_PAN_X",
")",
";",
"if",
"(",
"hasNone",
"||",
"(",
"hasPanY",
"&&",
"direction",
"&",
"DIRECTION_HORIZONTAL",
")",
"||",
"(",
"hasPanX",
"&&",
"direction",
"&",
"DIRECTION_VERTICAL",
")",
")",
"{",
"return",
"this",
".",
"preventSrc",
"(",
"srcEvent",
")",
";",
"}",
"}"
] | this method is called on each input cycle and provides the preventing of the browser behavior
@param {Object} input | [
"this",
"method",
"is",
"called",
"on",
"each",
"input",
"cycle",
"and",
"provides",
"the",
"preventing",
"of",
"the",
"browser",
"behavior"
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1044-L1069 |
|
50,275 | RealGeeks/mallet | index.js | Mallet | function Mallet(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Mallet.defaults.preset);
return new Manager(element, options);
} | javascript | function Mallet(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Mallet.defaults.preset);
return new Manager(element, options);
} | [
"function",
"Mallet",
"(",
"element",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"recognizers",
"=",
"ifUndefined",
"(",
"options",
".",
"recognizers",
",",
"Mallet",
".",
"defaults",
".",
"preset",
")",
";",
"return",
"new",
"Manager",
"(",
"element",
",",
"options",
")",
";",
"}"
] | Simple way to create an manager with a default set of recognizers.
@param {HTMLElement} element
@param {Object} [options]
@constructor | [
"Simple",
"way",
"to",
"create",
"an",
"manager",
"with",
"a",
"default",
"set",
"of",
"recognizers",
"."
] | 12b8a1b0ab014386c1d0e7980a51afc2089ccdd4 | https://github.com/RealGeeks/mallet/blob/12b8a1b0ab014386c1d0e7980a51afc2089ccdd4/index.js#L1893-L1897 |
50,276 | pattern-library/pattern-library-utilities | lib/gulp-tasks/browsersync.js | function () {
'use strict';
// default options for pattern-importer
var options = {
environment: {
config: {
server: {
baseDir: './app'
},
host: 'localhost',
port: 8001,
debugInfo: false,
open: true
}
},
showConsoleLog: true,
dependencies: [] // gulp tasks which should be run before this task
};
return options;
} | javascript | function () {
'use strict';
// default options for pattern-importer
var options = {
environment: {
config: {
server: {
baseDir: './app'
},
host: 'localhost',
port: 8001,
debugInfo: false,
open: true
}
},
showConsoleLog: true,
dependencies: [] // gulp tasks which should be run before this task
};
return options;
} | [
"function",
"(",
")",
"{",
"'use strict'",
";",
"// default options for pattern-importer",
"var",
"options",
"=",
"{",
"environment",
":",
"{",
"config",
":",
"{",
"server",
":",
"{",
"baseDir",
":",
"'./app'",
"}",
",",
"host",
":",
"'localhost'",
",",
"port",
":",
"8001",
",",
"debugInfo",
":",
"false",
",",
"open",
":",
"true",
"}",
"}",
",",
"showConsoleLog",
":",
"true",
",",
"dependencies",
":",
"[",
"]",
"// gulp tasks which should be run before this task",
"}",
";",
"return",
"options",
";",
"}"
] | Function to get default options for an implementation of browser-sync
@return {Object} options an object of default browser-sync options | [
"Function",
"to",
"get",
"default",
"options",
"for",
"an",
"implementation",
"of",
"browser",
"-",
"sync"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/browsersync.js#L17-L40 |
|
50,277 | Nazariglez/perenquen | lib/pixi/src/filters/bloom/BloomFilter.js | BloomFilter | function BloomFilter()
{
core.AbstractFilter.call(this);
this.blurXFilter = new BlurXFilter();
this.blurYFilter = new BlurYFilter();
this.defaultFilter = new core.AbstractFilter();
} | javascript | function BloomFilter()
{
core.AbstractFilter.call(this);
this.blurXFilter = new BlurXFilter();
this.blurYFilter = new BlurYFilter();
this.defaultFilter = new core.AbstractFilter();
} | [
"function",
"BloomFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"blurXFilter",
"=",
"new",
"BlurXFilter",
"(",
")",
";",
"this",
".",
"blurYFilter",
"=",
"new",
"BlurYFilter",
"(",
")",
";",
"this",
".",
"defaultFilter",
"=",
"new",
"core",
".",
"AbstractFilter",
"(",
")",
";",
"}"
] | The BloomFilter applies a Gaussian blur to an object.
The strength of the blur can be set for x- and y-axis separately.
@class
@extends AbstractFilter
@memberof PIXI.filters | [
"The",
"BloomFilter",
"applies",
"a",
"Gaussian",
"blur",
"to",
"an",
"object",
".",
"The",
"strength",
"of",
"the",
"blur",
"can",
"be",
"set",
"for",
"x",
"-",
"and",
"y",
"-",
"axis",
"separately",
"."
] | e023964d05afeefebdcac4e2044819fdfa3899ae | https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/bloom/BloomFilter.js#L13-L21 |
50,278 | weekeight/gulp-joycss | joycss/lib/common/stdclass.js | on | function on(ev, fn, context){
var arg = arguments;
var slice = [].slice;
var evs = ev.split(',');
var i = 0;
var evt = '';
var __fn = fn;
fn = function wrapOn(e){
context = context || this;
__fn.apply(context, [e].concat(slice.call(arg, 3)));
};
while(evs[i]){
evt = evs[i].replace(TRIM_REG, '');
if (evt) Events.prototype.on.call(this, evt, fn);
i++;
}
return fn;
} | javascript | function on(ev, fn, context){
var arg = arguments;
var slice = [].slice;
var evs = ev.split(',');
var i = 0;
var evt = '';
var __fn = fn;
fn = function wrapOn(e){
context = context || this;
__fn.apply(context, [e].concat(slice.call(arg, 3)));
};
while(evs[i]){
evt = evs[i].replace(TRIM_REG, '');
if (evt) Events.prototype.on.call(this, evt, fn);
i++;
}
return fn;
} | [
"function",
"on",
"(",
"ev",
",",
"fn",
",",
"context",
")",
"{",
"var",
"arg",
"=",
"arguments",
";",
"var",
"slice",
"=",
"[",
"]",
".",
"slice",
";",
"var",
"evs",
"=",
"ev",
".",
"split",
"(",
"','",
")",
";",
"var",
"i",
"=",
"0",
";",
"var",
"evt",
"=",
"''",
";",
"var",
"__fn",
"=",
"fn",
";",
"fn",
"=",
"function",
"wrapOn",
"(",
"e",
")",
"{",
"context",
"=",
"context",
"||",
"this",
";",
"__fn",
".",
"apply",
"(",
"context",
",",
"[",
"e",
"]",
".",
"concat",
"(",
"slice",
".",
"call",
"(",
"arg",
",",
"3",
")",
")",
")",
";",
"}",
";",
"while",
"(",
"evs",
"[",
"i",
"]",
")",
"{",
"evt",
"=",
"evs",
"[",
"i",
"]",
".",
"replace",
"(",
"TRIM_REG",
",",
"''",
")",
";",
"if",
"(",
"evt",
")",
"Events",
".",
"prototype",
".",
"on",
".",
"call",
"(",
"this",
",",
"evt",
",",
"fn",
")",
";",
"i",
"++",
";",
"}",
"return",
"fn",
";",
"}"
] | the same to function on, bind event on self, the only
change is add the ability of bind mult event
@example this.on('a, b, c', fn);
@note the dismember is ', ', do not lost the blank space
@param ev {string} event string, dismember by ', ',semicolon add an
blank space
@param fn {function} function executed when the event is emit
@return fn {function} the callback function would be change, so you should
get the handle of the callback function by the return value | [
"the",
"same",
"to",
"function",
"on",
"bind",
"event",
"on",
"self",
"the",
"only",
"change",
"is",
"add",
"the",
"ability",
"of",
"bind",
"mult",
"event"
] | 5dc7a1276bcca878c2ac513efe6442fc47a36e29 | https://github.com/weekeight/gulp-joycss/blob/5dc7a1276bcca878c2ac513efe6442fc47a36e29/joycss/lib/common/stdclass.js#L201-L220 |
50,279 | cahangon/is-aksara | index.js | isSandhanganWyanjana | function isSandhanganWyanjana(position, input) {
var chr = input.charAt(position),
length = input.length,
prevChr = input.charAt(position - 1),
nextChr;
// pacar = false
if (position == length - 1) {
return false;
}
// paras = false
if (isSwara(prevChr)) {
return false;
}
// pra = true
// prahara = true
if (chr == 'r') {
nextChr = input.charAt(position + 1);
if (nextChr == 'a' || nextChr == 'e') {
return true;
}
return false;
} else if (chr == 'y') {
if (input.charAt(position + 1) == 'a') {
return true;
}
return false;
}
return false;
} | javascript | function isSandhanganWyanjana(position, input) {
var chr = input.charAt(position),
length = input.length,
prevChr = input.charAt(position - 1),
nextChr;
// pacar = false
if (position == length - 1) {
return false;
}
// paras = false
if (isSwara(prevChr)) {
return false;
}
// pra = true
// prahara = true
if (chr == 'r') {
nextChr = input.charAt(position + 1);
if (nextChr == 'a' || nextChr == 'e') {
return true;
}
return false;
} else if (chr == 'y') {
if (input.charAt(position + 1) == 'a') {
return true;
}
return false;
}
return false;
} | [
"function",
"isSandhanganWyanjana",
"(",
"position",
",",
"input",
")",
"{",
"var",
"chr",
"=",
"input",
".",
"charAt",
"(",
"position",
")",
",",
"length",
"=",
"input",
".",
"length",
",",
"prevChr",
"=",
"input",
".",
"charAt",
"(",
"position",
"-",
"1",
")",
",",
"nextChr",
";",
"// pacar = false",
"if",
"(",
"position",
"==",
"length",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"// paras = false",
"if",
"(",
"isSwara",
"(",
"prevChr",
")",
")",
"{",
"return",
"false",
";",
"}",
"// pra = true",
"// prahara = true",
"if",
"(",
"chr",
"==",
"'r'",
")",
"{",
"nextChr",
"=",
"input",
".",
"charAt",
"(",
"position",
"+",
"1",
")",
";",
"if",
"(",
"nextChr",
"==",
"'a'",
"||",
"nextChr",
"==",
"'e'",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"chr",
"==",
"'y'",
")",
"{",
"if",
"(",
"input",
".",
"charAt",
"(",
"position",
"+",
"1",
")",
"==",
"'a'",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] | Mendeteksi sisipan ra, re, ya
@param {Number} position Posisi dari karakter yang hendak diperiksa
@param {String} input Kalimat yang hendak diperiksa
@return {Boolean} | [
"Mendeteksi",
"sisipan",
"ra",
"re",
"ya"
] | a8ebc4d2bea00a2e3bc52c6699c9aa100c2964c3 | https://github.com/cahangon/is-aksara/blob/a8ebc4d2bea00a2e3bc52c6699c9aa100c2964c3/index.js#L126-L160 |
50,280 | byron-dupreez/rcc-ioredis-adapter | rcc-ioredis-adapter.js | isMovedError | function isMovedError(error) {
// Check if error message contains something like: "MOVED 14190 127.0.0.1:6379"
return !!isInstanceOf(error, ReplyError) && error.message && error.message.startsWith('MOVED ');
} | javascript | function isMovedError(error) {
// Check if error message contains something like: "MOVED 14190 127.0.0.1:6379"
return !!isInstanceOf(error, ReplyError) && error.message && error.message.startsWith('MOVED ');
} | [
"function",
"isMovedError",
"(",
"error",
")",
"{",
"// Check if error message contains something like: \"MOVED 14190 127.0.0.1:6379\"",
"return",
"!",
"!",
"isInstanceOf",
"(",
"error",
",",
"ReplyError",
")",
"&&",
"error",
".",
"message",
"&&",
"error",
".",
"message",
".",
"startsWith",
"(",
"'MOVED '",
")",
";",
"}"
] | Returns true if the given error indicates that the key attempted was moved to a new host and port; otherwise returns
false.
@param {Error|ReplyError} error - an error thrown by a RedisClient instance
@return {boolean} true if moved; false otherwise | [
"Returns",
"true",
"if",
"the",
"given",
"error",
"indicates",
"that",
"the",
"key",
"attempted",
"was",
"moved",
"to",
"a",
"new",
"host",
"and",
"port",
";",
"otherwise",
"returns",
"false",
"."
] | 8acf43bff7231d4d310abb2580bcfc75ab5c1e0b | https://github.com/byron-dupreez/rcc-ioredis-adapter/blob/8acf43bff7231d4d310abb2580bcfc75ab5c1e0b/rcc-ioredis-adapter.js#L107-L110 |
50,281 | byron-dupreez/rcc-ioredis-adapter | rcc-ioredis-adapter.js | resolveHostAndPortFromMovedError | function resolveHostAndPortFromMovedError(movedError) {
// Attempt to resolve the new host & port from the error message
if (isMovedError(movedError)) {
return movedError.message.substring(movedError.message.lastIndexOf(' ') + 1).split(':');
}
throw new Error(`Unexpected ioredis client "moved" ReplyError - ${movedError}`);
} | javascript | function resolveHostAndPortFromMovedError(movedError) {
// Attempt to resolve the new host & port from the error message
if (isMovedError(movedError)) {
return movedError.message.substring(movedError.message.lastIndexOf(' ') + 1).split(':');
}
throw new Error(`Unexpected ioredis client "moved" ReplyError - ${movedError}`);
} | [
"function",
"resolveHostAndPortFromMovedError",
"(",
"movedError",
")",
"{",
"// Attempt to resolve the new host & port from the error message",
"if",
"(",
"isMovedError",
"(",
"movedError",
")",
")",
"{",
"return",
"movedError",
".",
"message",
".",
"substring",
"(",
"movedError",
".",
"message",
".",
"lastIndexOf",
"(",
"' '",
")",
"+",
"1",
")",
".",
"split",
"(",
"':'",
")",
";",
"}",
"throw",
"new",
"Error",
"(",
"`",
"${",
"movedError",
"}",
"`",
")",
";",
"}"
] | Extracts the new host and port from the given RedisClient "moved" ReplyError.
@param {ReplyError|Error} movedError - a ReplyError thrown by a RedisClient instance that indicates the redis server
has moved
@return {[string, number|string]} the new host and port | [
"Extracts",
"the",
"new",
"host",
"and",
"port",
"from",
"the",
"given",
"RedisClient",
"moved",
"ReplyError",
"."
] | 8acf43bff7231d4d310abb2580bcfc75ab5c1e0b | https://github.com/byron-dupreez/rcc-ioredis-adapter/blob/8acf43bff7231d4d310abb2580bcfc75ab5c1e0b/rcc-ioredis-adapter.js#L118-L124 |
50,282 | lujintan/clitoolkit | src/PluginEngine.js | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
return true;
}
}
return false;
} | javascript | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
return true;
}
}
return false;
} | [
"function",
"(",
"name",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"_pluginList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"plugin",
"=",
"_pluginList",
"[",
"i",
"]",
";",
"if",
"(",
"name",
"===",
"plugin",
".",
"name",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | weather the plugin is exist in plugin's list or not
@param {String} name the plugin's name
@return {Boolean} | [
"weather",
"the",
"plugin",
"is",
"exist",
"in",
"plugin",
"s",
"list",
"or",
"not"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L18-L26 |
|
50,283 | lujintan/clitoolkit | src/PluginEngine.js | function(name, pa){
var pa = pa || name;
if (!this.isExist(name)){
var realPath = path.join(_pluginBase, pa, 'main.js');
var pluginReg;
if (!fs.existsSync(realPath)) {
pluginReg = require(pa);
} else {
pluginReg = require(fs.realpathSync(realPath));
}
_pluginList.push(new Plugin(name, pa, pluginReg));
pluginReg(PluginAPI);
}
} | javascript | function(name, pa){
var pa = pa || name;
if (!this.isExist(name)){
var realPath = path.join(_pluginBase, pa, 'main.js');
var pluginReg;
if (!fs.existsSync(realPath)) {
pluginReg = require(pa);
} else {
pluginReg = require(fs.realpathSync(realPath));
}
_pluginList.push(new Plugin(name, pa, pluginReg));
pluginReg(PluginAPI);
}
} | [
"function",
"(",
"name",
",",
"pa",
")",
"{",
"var",
"pa",
"=",
"pa",
"||",
"name",
";",
"if",
"(",
"!",
"this",
".",
"isExist",
"(",
"name",
")",
")",
"{",
"var",
"realPath",
"=",
"path",
".",
"join",
"(",
"_pluginBase",
",",
"pa",
",",
"'main.js'",
")",
";",
"var",
"pluginReg",
";",
"if",
"(",
"!",
"fs",
".",
"existsSync",
"(",
"realPath",
")",
")",
"{",
"pluginReg",
"=",
"require",
"(",
"pa",
")",
";",
"}",
"else",
"{",
"pluginReg",
"=",
"require",
"(",
"fs",
".",
"realpathSync",
"(",
"realPath",
")",
")",
";",
"}",
"_pluginList",
".",
"push",
"(",
"new",
"Plugin",
"(",
"name",
",",
"pa",
",",
"pluginReg",
")",
")",
";",
"pluginReg",
"(",
"PluginAPI",
")",
";",
"}",
"}"
] | register the plugin
@param {String} path the plugin's path
@return {void} | [
"register",
"the",
"plugin"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L33-L49 |
|
50,284 | lujintan/clitoolkit | src/PluginEngine.js | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
_pluginList.splice(i, 1);
return;
}
}
} | javascript | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
_pluginList.splice(i, 1);
return;
}
}
} | [
"function",
"(",
"name",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"_pluginList",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"plugin",
"=",
"_pluginList",
"[",
"i",
"]",
";",
"if",
"(",
"name",
"===",
"plugin",
".",
"name",
")",
"{",
"_pluginList",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"return",
";",
"}",
"}",
"}"
] | remove the plugin by name
@param {String} name plugin's name
@return {void} | [
"remove",
"the",
"plugin",
"by",
"name"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L56-L64 |
|
50,285 | lujintan/clitoolkit | src/PluginEngine.js | function(plugins, pluginBase){
var _this = this;
if (typeof pluginBase === 'string') {
_pluginBase = pluginBase;
}
plugins.forEach(function(plugin, index){
var name;
var path;
if (typeof plugin === 'string'){
name = plugin;
} else {
name = plugin.name;
path = plugin.path;
}
_this.register(name, plugin);
});
} | javascript | function(plugins, pluginBase){
var _this = this;
if (typeof pluginBase === 'string') {
_pluginBase = pluginBase;
}
plugins.forEach(function(plugin, index){
var name;
var path;
if (typeof plugin === 'string'){
name = plugin;
} else {
name = plugin.name;
path = plugin.path;
}
_this.register(name, plugin);
});
} | [
"function",
"(",
"plugins",
",",
"pluginBase",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"if",
"(",
"typeof",
"pluginBase",
"===",
"'string'",
")",
"{",
"_pluginBase",
"=",
"pluginBase",
";",
"}",
"plugins",
".",
"forEach",
"(",
"function",
"(",
"plugin",
",",
"index",
")",
"{",
"var",
"name",
";",
"var",
"path",
";",
"if",
"(",
"typeof",
"plugin",
"===",
"'string'",
")",
"{",
"name",
"=",
"plugin",
";",
"}",
"else",
"{",
"name",
"=",
"plugin",
".",
"name",
";",
"path",
"=",
"plugin",
".",
"path",
";",
"}",
"_this",
".",
"register",
"(",
"name",
",",
"plugin",
")",
";",
"}",
")",
";",
"}"
] | initial the plugins by plugin's config
@param {Object} plugins plugin's config
@return {Promise} | [
"initial",
"the",
"plugins",
"by",
"plugin",
"s",
"config"
] | 0745f6ebd5b290f5462c64fd49959f6374ec5c2a | https://github.com/lujintan/clitoolkit/blob/0745f6ebd5b290f5462c64fd49959f6374ec5c2a/src/PluginEngine.js#L71-L88 |
|
50,286 | Two-Screen/grunt-zipstream | tasks/lib/zipstream.js | callbackOnce | function callbackOnce(err, arg) {
var cb = callback;
callback = null;
if (cb) { cb(err, arg); }
} | javascript | function callbackOnce(err, arg) {
var cb = callback;
callback = null;
if (cb) { cb(err, arg); }
} | [
"function",
"callbackOnce",
"(",
"err",
",",
"arg",
")",
"{",
"var",
"cb",
"=",
"callback",
";",
"callback",
"=",
"null",
";",
"if",
"(",
"cb",
")",
"{",
"cb",
"(",
"err",
",",
"arg",
")",
";",
"}",
"}"
] | Helper to call back only once. | [
"Helper",
"to",
"call",
"back",
"only",
"once",
"."
] | c975cc1facafd56aad6db63c2462066481092fed | https://github.com/Two-Screen/grunt-zipstream/blob/c975cc1facafd56aad6db63c2462066481092fed/tasks/lib/zipstream.js#L30-L34 |
50,287 | Two-Screen/grunt-zipstream | tasks/lib/zipstream.js | createErrorHandler | function createErrorHandler(verb) {
return function(err) {
if (!callback) { return; }
grunt.verbose.error();
grunt.fail.warn("Failed to " + verb + ": " + err.message);
callbackOnce(err);
};
} | javascript | function createErrorHandler(verb) {
return function(err) {
if (!callback) { return; }
grunt.verbose.error();
grunt.fail.warn("Failed to " + verb + ": " + err.message);
callbackOnce(err);
};
} | [
"function",
"createErrorHandler",
"(",
"verb",
")",
"{",
"return",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"!",
"callback",
")",
"{",
"return",
";",
"}",
"grunt",
".",
"verbose",
".",
"error",
"(",
")",
";",
"grunt",
".",
"fail",
".",
"warn",
"(",
"\"Failed to \"",
"+",
"verb",
"+",
"\": \"",
"+",
"err",
".",
"message",
")",
";",
"callbackOnce",
"(",
"err",
")",
";",
"}",
";",
"}"
] | Helper to create a stream error handler function. | [
"Helper",
"to",
"create",
"a",
"stream",
"error",
"handler",
"function",
"."
] | c975cc1facafd56aad6db63c2462066481092fed | https://github.com/Two-Screen/grunt-zipstream/blob/c975cc1facafd56aad6db63c2462066481092fed/tasks/lib/zipstream.js#L37-L44 |
50,288 | andrewscwei/requiem | src/dom/getStyle.js | getStyle | function getStyle(element, key, isComputed, isolateUnits) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof isComputed !== 'boolean') isComputed = false;
if (typeof isolateUnits !== 'boolean') isolateUnits = false;
let value = (isComputed) ? window.getComputedStyle(element, null).getPropertyValue(key) : element.style[key];
let regex = new RegExp('^[+-]?[0-9]+.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)$', 'i');
if (value === '') return (isolateUnits ? { value: null, unit: null } : null);
if (!isNaN(Number(value))) return (isolateUnits ? { value: Number(value), unit: null } : Number(value));
if (regex.test(value)) {
if (isolateUnits) {
if (value.charAt(value.length-1) === '%') return { value: Number(value.substr(0, value.length-1)), unit: value.slice(-1) };
return { value: Number(value.substr(0, value.length-2)), unit: value.slice(-2) };
}
else {
return value;
}
}
return (isolateUnits ? { value: value, units: null } : value);
} | javascript | function getStyle(element, key, isComputed, isolateUnits) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof isComputed !== 'boolean') isComputed = false;
if (typeof isolateUnits !== 'boolean') isolateUnits = false;
let value = (isComputed) ? window.getComputedStyle(element, null).getPropertyValue(key) : element.style[key];
let regex = new RegExp('^[+-]?[0-9]+.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)$', 'i');
if (value === '') return (isolateUnits ? { value: null, unit: null } : null);
if (!isNaN(Number(value))) return (isolateUnits ? { value: Number(value), unit: null } : Number(value));
if (regex.test(value)) {
if (isolateUnits) {
if (value.charAt(value.length-1) === '%') return { value: Number(value.substr(0, value.length-1)), unit: value.slice(-1) };
return { value: Number(value.substr(0, value.length-2)), unit: value.slice(-2) };
}
else {
return value;
}
}
return (isolateUnits ? { value: value, units: null } : value);
} | [
"function",
"getStyle",
"(",
"element",
",",
"key",
",",
"isComputed",
",",
"isolateUnits",
")",
"{",
"assertType",
"(",
"element",
",",
"Node",
",",
"false",
",",
"'Invalid element specified'",
")",
";",
"if",
"(",
"typeof",
"isComputed",
"!==",
"'boolean'",
")",
"isComputed",
"=",
"false",
";",
"if",
"(",
"typeof",
"isolateUnits",
"!==",
"'boolean'",
")",
"isolateUnits",
"=",
"false",
";",
"let",
"value",
"=",
"(",
"isComputed",
")",
"?",
"window",
".",
"getComputedStyle",
"(",
"element",
",",
"null",
")",
".",
"getPropertyValue",
"(",
"key",
")",
":",
"element",
".",
"style",
"[",
"key",
"]",
";",
"let",
"regex",
"=",
"new",
"RegExp",
"(",
"'^[+-]?[0-9]+.?([0-9]+)?(px|em|ex|%|in|cm|mm|pt|pc)$'",
",",
"'i'",
")",
";",
"if",
"(",
"value",
"===",
"''",
")",
"return",
"(",
"isolateUnits",
"?",
"{",
"value",
":",
"null",
",",
"unit",
":",
"null",
"}",
":",
"null",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"Number",
"(",
"value",
")",
")",
")",
"return",
"(",
"isolateUnits",
"?",
"{",
"value",
":",
"Number",
"(",
"value",
")",
",",
"unit",
":",
"null",
"}",
":",
"Number",
"(",
"value",
")",
")",
";",
"if",
"(",
"regex",
".",
"test",
"(",
"value",
")",
")",
"{",
"if",
"(",
"isolateUnits",
")",
"{",
"if",
"(",
"value",
".",
"charAt",
"(",
"value",
".",
"length",
"-",
"1",
")",
"===",
"'%'",
")",
"return",
"{",
"value",
":",
"Number",
"(",
"value",
".",
"substr",
"(",
"0",
",",
"value",
".",
"length",
"-",
"1",
")",
")",
",",
"unit",
":",
"value",
".",
"slice",
"(",
"-",
"1",
")",
"}",
";",
"return",
"{",
"value",
":",
"Number",
"(",
"value",
".",
"substr",
"(",
"0",
",",
"value",
".",
"length",
"-",
"2",
")",
")",
",",
"unit",
":",
"value",
".",
"slice",
"(",
"-",
"2",
")",
"}",
";",
"}",
"else",
"{",
"return",
"value",
";",
"}",
"}",
"return",
"(",
"isolateUnits",
"?",
"{",
"value",
":",
"value",
",",
"units",
":",
"null",
"}",
":",
"value",
")",
";",
"}"
] | Gets the value of an inline CSS rule of a Node by its name.
@param {Node} element - Target element.
@param {string} key - Name of the CSS rule in camelCase.
@param {boolean} [isComputed=false] - Specifies whether the styles are
computed.
@param {boolean} [isolateUnits=false] - Specifies whether value and units are
separated. This affects the return
value type.
@return {*} Value of the style. If isolateUnits is set to true, this will
return an object containing both 'value' and 'unit' keys.
@alias module:requiem~dom.getStyle | [
"Gets",
"the",
"value",
"of",
"an",
"inline",
"CSS",
"rule",
"of",
"a",
"Node",
"by",
"its",
"name",
"."
] | c4182bfffc9841c6de5718f689ad3c2060511777 | https://github.com/andrewscwei/requiem/blob/c4182bfffc9841c6de5718f689ad3c2060511777/src/dom/getStyle.js#L23-L45 |
50,289 | fronteerio/node-embdr | lib/embdr.js | Embdr | function Embdr(key) {
if (!(this instanceof Embdr)) {
return new Embdr(key);
}
this._api = {
'auth': null,
'host': Embdr.DEFAULT_HOST,
'port': Embdr.DEFAULT_PORT,
'basePath': Embdr.DEFAULT_BASE_PATH,
'protocol': Embdr.DEFAULT_PROTOCOL
};
this.setApiKey(key);
this._exposeApis();
} | javascript | function Embdr(key) {
if (!(this instanceof Embdr)) {
return new Embdr(key);
}
this._api = {
'auth': null,
'host': Embdr.DEFAULT_HOST,
'port': Embdr.DEFAULT_PORT,
'basePath': Embdr.DEFAULT_BASE_PATH,
'protocol': Embdr.DEFAULT_PROTOCOL
};
this.setApiKey(key);
this._exposeApis();
} | [
"function",
"Embdr",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Embdr",
")",
")",
"{",
"return",
"new",
"Embdr",
"(",
"key",
")",
";",
"}",
"this",
".",
"_api",
"=",
"{",
"'auth'",
":",
"null",
",",
"'host'",
":",
"Embdr",
".",
"DEFAULT_HOST",
",",
"'port'",
":",
"Embdr",
".",
"DEFAULT_PORT",
",",
"'basePath'",
":",
"Embdr",
".",
"DEFAULT_BASE_PATH",
",",
"'protocol'",
":",
"Embdr",
".",
"DEFAULT_PROTOCOL",
"}",
";",
"this",
".",
"setApiKey",
"(",
"key",
")",
";",
"this",
".",
"_exposeApis",
"(",
")",
";",
"}"
] | Create a new Embdr instance
@constructor
@param {string} key The API key that allows for uploading to the Embdr REST API | [
"Create",
"a",
"new",
"Embdr",
"instance"
] | 050916baa37b069d894fdd4db3b80f110ad8c51e | https://github.com/fronteerio/node-embdr/blob/050916baa37b069d894fdd4db3b80f110ad8c51e/lib/embdr.js#L42-L57 |
50,290 | pinicarus/piquouze | examples/node6.js | function (a, b, c, d, e, ...args) {
return [a, b, c, d, e].concat(args);
} | javascript | function (a, b, c, d, e, ...args) {
return [a, b, c, d, e].concat(args);
} | [
"function",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"...",
"args",
")",
"{",
"return",
"[",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
"]",
".",
"concat",
"(",
"args",
")",
";",
"}"
] | Override a dependency. | [
"Override",
"a",
"dependency",
"."
] | 608e3a0a655d0504831a092ecee90ff66b0ce752 | https://github.com/pinicarus/piquouze/blob/608e3a0a655d0504831a092ecee90ff66b0ce752/examples/node6.js#L25-L27 |
|
50,291 | raitucarp/flattenr | index.js | flat | function flat(current, name, object, separator) {
var data = {}
// iterate object
for (var x in object) {
var key = [name, x].join(separator)
data[key] = object[x]
}
// iterate through data
for (var i in data) {
if (typeof data[i] !== "object") {
current[i] = data[i]
} else {
current = flat(current, i, data[i], separator)
}
}
// returning current value
return current
} | javascript | function flat(current, name, object, separator) {
var data = {}
// iterate object
for (var x in object) {
var key = [name, x].join(separator)
data[key] = object[x]
}
// iterate through data
for (var i in data) {
if (typeof data[i] !== "object") {
current[i] = data[i]
} else {
current = flat(current, i, data[i], separator)
}
}
// returning current value
return current
} | [
"function",
"flat",
"(",
"current",
",",
"name",
",",
"object",
",",
"separator",
")",
"{",
"var",
"data",
"=",
"{",
"}",
"// iterate object",
"for",
"(",
"var",
"x",
"in",
"object",
")",
"{",
"var",
"key",
"=",
"[",
"name",
",",
"x",
"]",
".",
"join",
"(",
"separator",
")",
"data",
"[",
"key",
"]",
"=",
"object",
"[",
"x",
"]",
"}",
"// iterate through data",
"for",
"(",
"var",
"i",
"in",
"data",
")",
"{",
"if",
"(",
"typeof",
"data",
"[",
"i",
"]",
"!==",
"\"object\"",
")",
"{",
"current",
"[",
"i",
"]",
"=",
"data",
"[",
"i",
"]",
"}",
"else",
"{",
"current",
"=",
"flat",
"(",
"current",
",",
"i",
",",
"data",
"[",
"i",
"]",
",",
"separator",
")",
"}",
"}",
"// returning current value",
"return",
"current",
"}"
] | flat an object to be more save use | [
"flat",
"an",
"object",
"to",
"be",
"more",
"save",
"use"
] | ea9adac2c3092c884c056ef72bbdd40a812cb19d | https://github.com/raitucarp/flattenr/blob/ea9adac2c3092c884c056ef72bbdd40a812cb19d/index.js#L2-L21 |
50,292 | raitucarp/flattenr | index.js | function(data, pattern) {
var result = {}
// iterate thorough data
for (var i in data) {
// create context data
var _data = data[i]
// if key match with pattern
if (i.match(pattern)) {
// add matched data
result[i] = _data
}
// if value match with pattern
if (_data.toString().match(pattern)) {
result[i] = _data
}
}
// result
return result
} | javascript | function(data, pattern) {
var result = {}
// iterate thorough data
for (var i in data) {
// create context data
var _data = data[i]
// if key match with pattern
if (i.match(pattern)) {
// add matched data
result[i] = _data
}
// if value match with pattern
if (_data.toString().match(pattern)) {
result[i] = _data
}
}
// result
return result
} | [
"function",
"(",
"data",
",",
"pattern",
")",
"{",
"var",
"result",
"=",
"{",
"}",
"// iterate thorough data",
"for",
"(",
"var",
"i",
"in",
"data",
")",
"{",
"// create context data",
"var",
"_data",
"=",
"data",
"[",
"i",
"]",
"// if key match with pattern",
"if",
"(",
"i",
".",
"match",
"(",
"pattern",
")",
")",
"{",
"// add matched data",
"result",
"[",
"i",
"]",
"=",
"_data",
"}",
"// if value match with pattern",
"if",
"(",
"_data",
".",
"toString",
"(",
")",
".",
"match",
"(",
"pattern",
")",
")",
"{",
"result",
"[",
"i",
"]",
"=",
"_data",
"}",
"}",
"// result",
"return",
"result",
"}"
] | matchPattern find pattern in data | [
"matchPattern",
"find",
"pattern",
"in",
"data"
] | ea9adac2c3092c884c056ef72bbdd40a812cb19d | https://github.com/raitucarp/flattenr/blob/ea9adac2c3092c884c056ef72bbdd40a812cb19d/index.js#L28-L48 |
|
50,293 | 0of/ver-iterator | lib/iterator.js | VersionIterable | function VersionIterable(task) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var name = _ref.name;
var _ref$range = _ref.range;
var range = _ref$range === undefined ? '*' : _ref$range;
var _ref$dir = _ref.dir;
var dir = _ref$dir === undefined ? '.' : _ref$dir;
var _ref$restore = _ref.restore;
var restore = _ref$restore === undefined ? true : _ref$restore;
_classCallCheck(this, VersionIterable);
_get(Object.getPrototypeOf(VersionIterable.prototype), 'constructor', this).call(this);
if (typeof task !== 'function') throw new TypeError('expects task as a function');
var versionFilter = typeof range === 'function' ? range : function (v) {
return (0, _semver.satisfies)(v, range);
};
var _url$parse = _url2['default'].parse(name);
var pathname = _url$parse.pathname;
if (_path2['default'].extname(pathname) == '.git') {
// check the name is kind of git repo url
var repoName = _path2['default'].basename(pathname, '.git');
this.name = repoName;
this.source = makeGitSource(repoName, name, /* passing url */versionFilter, dir, restore);
this.sourceName = 'git';
} else {
this.name = pathname;
this.source = makeNPMPackageSource(pathname, versionFilter, dir, restore);
this.sourceName = 'npm';
}
this.task = task;
} | javascript | function VersionIterable(task) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var name = _ref.name;
var _ref$range = _ref.range;
var range = _ref$range === undefined ? '*' : _ref$range;
var _ref$dir = _ref.dir;
var dir = _ref$dir === undefined ? '.' : _ref$dir;
var _ref$restore = _ref.restore;
var restore = _ref$restore === undefined ? true : _ref$restore;
_classCallCheck(this, VersionIterable);
_get(Object.getPrototypeOf(VersionIterable.prototype), 'constructor', this).call(this);
if (typeof task !== 'function') throw new TypeError('expects task as a function');
var versionFilter = typeof range === 'function' ? range : function (v) {
return (0, _semver.satisfies)(v, range);
};
var _url$parse = _url2['default'].parse(name);
var pathname = _url$parse.pathname;
if (_path2['default'].extname(pathname) == '.git') {
// check the name is kind of git repo url
var repoName = _path2['default'].basename(pathname, '.git');
this.name = repoName;
this.source = makeGitSource(repoName, name, /* passing url */versionFilter, dir, restore);
this.sourceName = 'git';
} else {
this.name = pathname;
this.source = makeNPMPackageSource(pathname, versionFilter, dir, restore);
this.sourceName = 'npm';
}
this.task = task;
} | [
"function",
"VersionIterable",
"(",
"task",
")",
"{",
"var",
"_ref",
"=",
"arguments",
".",
"length",
"<=",
"1",
"||",
"arguments",
"[",
"1",
"]",
"===",
"undefined",
"?",
"{",
"}",
":",
"arguments",
"[",
"1",
"]",
";",
"var",
"name",
"=",
"_ref",
".",
"name",
";",
"var",
"_ref$range",
"=",
"_ref",
".",
"range",
";",
"var",
"range",
"=",
"_ref$range",
"===",
"undefined",
"?",
"'*'",
":",
"_ref$range",
";",
"var",
"_ref$dir",
"=",
"_ref",
".",
"dir",
";",
"var",
"dir",
"=",
"_ref$dir",
"===",
"undefined",
"?",
"'.'",
":",
"_ref$dir",
";",
"var",
"_ref$restore",
"=",
"_ref",
".",
"restore",
";",
"var",
"restore",
"=",
"_ref$restore",
"===",
"undefined",
"?",
"true",
":",
"_ref$restore",
";",
"_classCallCheck",
"(",
"this",
",",
"VersionIterable",
")",
";",
"_get",
"(",
"Object",
".",
"getPrototypeOf",
"(",
"VersionIterable",
".",
"prototype",
")",
",",
"'constructor'",
",",
"this",
")",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"typeof",
"task",
"!==",
"'function'",
")",
"throw",
"new",
"TypeError",
"(",
"'expects task as a function'",
")",
";",
"var",
"versionFilter",
"=",
"typeof",
"range",
"===",
"'function'",
"?",
"range",
":",
"function",
"(",
"v",
")",
"{",
"return",
"(",
"0",
",",
"_semver",
".",
"satisfies",
")",
"(",
"v",
",",
"range",
")",
";",
"}",
";",
"var",
"_url$parse",
"=",
"_url2",
"[",
"'default'",
"]",
".",
"parse",
"(",
"name",
")",
";",
"var",
"pathname",
"=",
"_url$parse",
".",
"pathname",
";",
"if",
"(",
"_path2",
"[",
"'default'",
"]",
".",
"extname",
"(",
"pathname",
")",
"==",
"'.git'",
")",
"{",
"// check the name is kind of git repo url",
"var",
"repoName",
"=",
"_path2",
"[",
"'default'",
"]",
".",
"basename",
"(",
"pathname",
",",
"'.git'",
")",
";",
"this",
".",
"name",
"=",
"repoName",
";",
"this",
".",
"source",
"=",
"makeGitSource",
"(",
"repoName",
",",
"name",
",",
"/* passing url */",
"versionFilter",
",",
"dir",
",",
"restore",
")",
";",
"this",
".",
"sourceName",
"=",
"'git'",
";",
"}",
"else",
"{",
"this",
".",
"name",
"=",
"pathname",
";",
"this",
".",
"source",
"=",
"makeNPMPackageSource",
"(",
"pathname",
",",
"versionFilter",
",",
"dir",
",",
"restore",
")",
";",
"this",
".",
"sourceName",
"=",
"'npm'",
";",
"}",
"this",
".",
"task",
"=",
"task",
";",
"}"
] | construct iterable published versions via npm
@param {Function} [task] ({name, version}) => {}
@param {Object} [opts]
@param {String} [opts.name] package name or git URL
@param {String|Function} [opts.range] iterating version ranges in semver format
or customized version filter
@param {String} [opts.dir] installing package directory
@public | [
"construct",
"iterable",
"published",
"versions",
"via",
"npm"
] | a51726c02dfd14488190860f4d90903574ed8e37 | https://github.com/0of/ver-iterator/blob/a51726c02dfd14488190860f4d90903574ed8e37/lib/iterator.js#L64-L101 |
50,294 | mikolalysenko/splat-points-2d | splat.js | splatPoints | function splatPoints(out, points, weights, radius) {
doSplat(
points.hi(points.shape[0], 1),
ndarray(weights.data,
[weights.shape[0], 1],
[weights.stride[0], 0],
weights.offset),
out,
radius,
dirichlet)
} | javascript | function splatPoints(out, points, weights, radius) {
doSplat(
points.hi(points.shape[0], 1),
ndarray(weights.data,
[weights.shape[0], 1],
[weights.stride[0], 0],
weights.offset),
out,
radius,
dirichlet)
} | [
"function",
"splatPoints",
"(",
"out",
",",
"points",
",",
"weights",
",",
"radius",
")",
"{",
"doSplat",
"(",
"points",
".",
"hi",
"(",
"points",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
",",
"ndarray",
"(",
"weights",
".",
"data",
",",
"[",
"weights",
".",
"shape",
"[",
"0",
"]",
",",
"1",
"]",
",",
"[",
"weights",
".",
"stride",
"[",
"0",
"]",
",",
"0",
"]",
",",
"weights",
".",
"offset",
")",
",",
"out",
",",
"radius",
",",
"dirichlet",
")",
"}"
] | Splat a list of points to a grid with the given weights | [
"Splat",
"a",
"list",
"of",
"points",
"to",
"a",
"grid",
"with",
"the",
"given",
"weights"
] | 1a5b151df78e370877c1117ceabb70c32b309591 | https://github.com/mikolalysenko/splat-points-2d/blob/1a5b151df78e370877c1117ceabb70c32b309591/splat.js#L44-L54 |
50,295 | warncke/immutable-core | lib/immutable-function.js | functionWrapperFunction | function functionWrapperFunction () {
// call original function - catching errors for logging
try {
var res = functionObj.apply(this, arguments)
}
catch (error) {
var err = error
}
// if log client then do logging
if (options.logClient) {
// get number of arguments
var argsLength = arguments.length
// copy of arguments
var args = []
// create copy of arguments
for (var i=0; i < argsLength; i++) {
args[i] = arguments[i]
}
// log call
options.logClient.log('functionCall', {
functionName: functionName,
args: args,
res: err || res,
isError: (err ? true : false),
moduleCallId: (this ? this.moduleCallId : undefined),
requestId: (this ? this.requestId : undefined),
})
}
// if result was an error then throw original error
if (err) {
throw err
}
// otherwise return original result
else {
return res
}
} | javascript | function functionWrapperFunction () {
// call original function - catching errors for logging
try {
var res = functionObj.apply(this, arguments)
}
catch (error) {
var err = error
}
// if log client then do logging
if (options.logClient) {
// get number of arguments
var argsLength = arguments.length
// copy of arguments
var args = []
// create copy of arguments
for (var i=0; i < argsLength; i++) {
args[i] = arguments[i]
}
// log call
options.logClient.log('functionCall', {
functionName: functionName,
args: args,
res: err || res,
isError: (err ? true : false),
moduleCallId: (this ? this.moduleCallId : undefined),
requestId: (this ? this.requestId : undefined),
})
}
// if result was an error then throw original error
if (err) {
throw err
}
// otherwise return original result
else {
return res
}
} | [
"function",
"functionWrapperFunction",
"(",
")",
"{",
"// call original function - catching errors for logging",
"try",
"{",
"var",
"res",
"=",
"functionObj",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"}",
"catch",
"(",
"error",
")",
"{",
"var",
"err",
"=",
"error",
"}",
"// if log client then do logging",
"if",
"(",
"options",
".",
"logClient",
")",
"{",
"// get number of arguments",
"var",
"argsLength",
"=",
"arguments",
".",
"length",
"// copy of arguments",
"var",
"args",
"=",
"[",
"]",
"// create copy of arguments",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"argsLength",
";",
"i",
"++",
")",
"{",
"args",
"[",
"i",
"]",
"=",
"arguments",
"[",
"i",
"]",
"}",
"// log call",
"options",
".",
"logClient",
".",
"log",
"(",
"'functionCall'",
",",
"{",
"functionName",
":",
"functionName",
",",
"args",
":",
"args",
",",
"res",
":",
"err",
"||",
"res",
",",
"isError",
":",
"(",
"err",
"?",
"true",
":",
"false",
")",
",",
"moduleCallId",
":",
"(",
"this",
"?",
"this",
".",
"moduleCallId",
":",
"undefined",
")",
",",
"requestId",
":",
"(",
"this",
"?",
"this",
".",
"requestId",
":",
"undefined",
")",
",",
"}",
")",
"}",
"// if result was an error then throw original error",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
"}",
"// otherwise return original result",
"else",
"{",
"return",
"res",
"}",
"}"
] | create wrapper function that will do logging and call original | [
"create",
"wrapper",
"function",
"that",
"will",
"do",
"logging",
"and",
"call",
"original"
] | fd8f6c2194ee98b61c5e79b534fb5fb3f6f20d3d | https://github.com/warncke/immutable-core/blob/fd8f6c2194ee98b61c5e79b534fb5fb3f6f20d3d/lib/immutable-function.js#L48-L84 |
50,296 | pattern-library/pattern-library-utilities | lib/gulp-tasks/doxx.js | function () {
'use strict';
// default options for doxx gulp task
var options = {
config: {
title: 'Project Title',
urlPrefix: null,
template: path.join(__dirname, '../templates/doxx.template.jade')
},
src: [
'!./node_modules/**/*',
'./**/*.js'
],
dest: './docs',
dependencies: [] // gulp tasks which should be run before this task
};
return options;
} | javascript | function () {
'use strict';
// default options for doxx gulp task
var options = {
config: {
title: 'Project Title',
urlPrefix: null,
template: path.join(__dirname, '../templates/doxx.template.jade')
},
src: [
'!./node_modules/**/*',
'./**/*.js'
],
dest: './docs',
dependencies: [] // gulp tasks which should be run before this task
};
return options;
} | [
"function",
"(",
")",
"{",
"'use strict'",
";",
"// default options for doxx gulp task",
"var",
"options",
"=",
"{",
"config",
":",
"{",
"title",
":",
"'Project Title'",
",",
"urlPrefix",
":",
"null",
",",
"template",
":",
"path",
".",
"join",
"(",
"__dirname",
",",
"'../templates/doxx.template.jade'",
")",
"}",
",",
"src",
":",
"[",
"'!./node_modules/**/*'",
",",
"'./**/*.js'",
"]",
",",
"dest",
":",
"'./docs'",
",",
"dependencies",
":",
"[",
"]",
"// gulp tasks which should be run before this task",
"}",
";",
"return",
"options",
";",
"}"
] | Function to get default options for an implementation of gulp-doxx
@return {Object} options an object of default doxx options | [
"Function",
"to",
"get",
"default",
"options",
"for",
"an",
"implementation",
"of",
"gulp",
"-",
"doxx"
] | a0198f7bb698eb5b859576b11afa3d0ebd3e5911 | https://github.com/pattern-library/pattern-library-utilities/blob/a0198f7bb698eb5b859576b11afa3d0ebd3e5911/lib/gulp-tasks/doxx.js#L18-L39 |
|
50,297 | derdesign/protos | lib/controller.js | function(v, o) {
if (re.test(v)) {
o[k] = v; // Set params to be returned when matching
return true;
} else {
return false;
}
} | javascript | function(v, o) {
if (re.test(v)) {
o[k] = v; // Set params to be returned when matching
return true;
} else {
return false;
}
} | [
"function",
"(",
"v",
",",
"o",
")",
"{",
"if",
"(",
"re",
".",
"test",
"(",
"v",
")",
")",
"{",
"o",
"[",
"k",
"]",
"=",
"v",
";",
"// Set params to be returned when matching",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | new closure, to maintain value | [
"new",
"closure",
"to",
"maintain",
"value"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/lib/controller.js#L733-L740 |
|
50,298 | tolokoban/ToloFrameWork | ker/mod/wdg.js | Widget | function Widget(options) {
this.__data = {};
try {
var e;
if (typeof options === 'undefined') options = {};
if (typeof options.innerHTML !== 'undefined' && typeof options.childNodes !== 'undefined') {
// On passe directement un élément.
options = {element: options};
}
if (typeof options.tag === 'undefined') options.tag = "div";
if (options.element) {
this.element(options.element);
} else if (typeof options.id !== 'undefined') {
e = window.document.getElementById(options.id);
if (!e) {
throw Error("Can't find element with id: \"" + options.id + "\"!");
}
this.element(e);
} else {
this.element(window.document.createElement(options.tag));
this.addClass("wdg", "custom");
}
}
catch (ex) {
console.error("[widget] ", ex);
console.error("[Widget] ", JSON.stringify(options));
throw Error(ex);
}
} | javascript | function Widget(options) {
this.__data = {};
try {
var e;
if (typeof options === 'undefined') options = {};
if (typeof options.innerHTML !== 'undefined' && typeof options.childNodes !== 'undefined') {
// On passe directement un élément.
options = {element: options};
}
if (typeof options.tag === 'undefined') options.tag = "div";
if (options.element) {
this.element(options.element);
} else if (typeof options.id !== 'undefined') {
e = window.document.getElementById(options.id);
if (!e) {
throw Error("Can't find element with id: \"" + options.id + "\"!");
}
this.element(e);
} else {
this.element(window.document.createElement(options.tag));
this.addClass("wdg", "custom");
}
}
catch (ex) {
console.error("[widget] ", ex);
console.error("[Widget] ", JSON.stringify(options));
throw Error(ex);
}
} | [
"function",
"Widget",
"(",
"options",
")",
"{",
"this",
".",
"__data",
"=",
"{",
"}",
";",
"try",
"{",
"var",
"e",
";",
"if",
"(",
"typeof",
"options",
"===",
"'undefined'",
")",
"options",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"options",
".",
"innerHTML",
"!==",
"'undefined'",
"&&",
"typeof",
"options",
".",
"childNodes",
"!==",
"'undefined'",
")",
"{",
"// On passe directement un élément.",
"options",
"=",
"{",
"element",
":",
"options",
"}",
";",
"}",
"if",
"(",
"typeof",
"options",
".",
"tag",
"===",
"'undefined'",
")",
"options",
".",
"tag",
"=",
"\"div\"",
";",
"if",
"(",
"options",
".",
"element",
")",
"{",
"this",
".",
"element",
"(",
"options",
".",
"element",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"options",
".",
"id",
"!==",
"'undefined'",
")",
"{",
"e",
"=",
"window",
".",
"document",
".",
"getElementById",
"(",
"options",
".",
"id",
")",
";",
"if",
"(",
"!",
"e",
")",
"{",
"throw",
"Error",
"(",
"\"Can't find element with id: \\\"\"",
"+",
"options",
".",
"id",
"+",
"\"\\\"!\"",
")",
";",
"}",
"this",
".",
"element",
"(",
"e",
")",
";",
"}",
"else",
"{",
"this",
".",
"element",
"(",
"window",
".",
"document",
".",
"createElement",
"(",
"options",
".",
"tag",
")",
")",
";",
"this",
".",
"addClass",
"(",
"\"wdg\"",
",",
"\"custom\"",
")",
";",
"}",
"}",
"catch",
"(",
"ex",
")",
"{",
"console",
".",
"error",
"(",
"\"[widget] \"",
",",
"ex",
")",
";",
"console",
".",
"error",
"(",
"\"[Widget] \"",
",",
"JSON",
".",
"stringify",
"(",
"options",
")",
")",
";",
"throw",
"Error",
"(",
"ex",
")",
";",
"}",
"}"
] | Widgets inherit this class. | [
"Widgets",
"inherit",
"this",
"class",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L6-L34 |
50,299 | tolokoban/ToloFrameWork | ker/mod/wdg.js | function(v) {
if (v === undefined) return this._element;
if (typeof v === 'string') {
v = window.document.querySelector(v);
}
this._element = v;
return this;
} | javascript | function(v) {
if (v === undefined) return this._element;
if (typeof v === 'string') {
v = window.document.querySelector(v);
}
this._element = v;
return this;
} | [
"function",
"(",
"v",
")",
"{",
"if",
"(",
"v",
"===",
"undefined",
")",
"return",
"this",
".",
"_element",
";",
"if",
"(",
"typeof",
"v",
"===",
"'string'",
")",
"{",
"v",
"=",
"window",
".",
"document",
".",
"querySelector",
"(",
"v",
")",
";",
"}",
"this",
".",
"_element",
"=",
"v",
";",
"return",
"this",
";",
"}"
] | Accessor for attribute element
@return element | [
"Accessor",
"for",
"attribute",
"element"
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/wdg.js#L41-L48 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.