repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jackzampolin/influx-express | index.js | makePoint | function makePoint() {
// Pull start time from req and log responseTime
var responseTime = Date.now() - req.start;
// Add the new point to the batch of points
batch.points.push({
measurement: "requests",
"tags": {
"path": req.path,
"host": req.hostname,... | javascript | function makePoint() {
// Pull start time from req and log responseTime
var responseTime = Date.now() - req.start;
// Add the new point to the batch of points
batch.points.push({
measurement: "requests",
"tags": {
"path": req.path,
"host": req.hostname,... | [
"function",
"makePoint",
"(",
")",
"{",
"// Pull start time from req and log responseTime",
"var",
"responseTime",
"=",
"Date",
".",
"now",
"(",
")",
"-",
"req",
".",
"start",
";",
"// Add the new point to the batch of points",
"batch",
".",
"points",
".",
"push",
"... | Make line protocol point and add to batcher | [
"Make",
"line",
"protocol",
"point",
"and",
"add",
"to",
"batcher"
] | 599ba9a2485fc6fd2f6bcd434f9d6818c094a497 | https://github.com/jackzampolin/influx-express/blob/599ba9a2485fc6fd2f6bcd434f9d6818c094a497/index.js#L60-L80 | train |
WebReflection/wru | src/wru.DOM.functions.js | isGonnaBeLegen | function isGonnaBeLegen() {
current = shift.call(queue);
if (current) {
if (typeof current == "function") {
current = {name: current[NAME] || "anonymous", test: current};
}
(node = putItThereAndGimmeBack(
putItThereAndGimmeBack(wru.node... | javascript | function isGonnaBeLegen() {
current = shift.call(queue);
if (current) {
if (typeof current == "function") {
current = {name: current[NAME] || "anonymous", test: current};
}
(node = putItThereAndGimmeBack(
putItThereAndGimmeBack(wru.node... | [
"function",
"isGonnaBeLegen",
"(",
")",
"{",
"current",
"=",
"shift",
".",
"call",
"(",
"queue",
")",
";",
"if",
"(",
"current",
")",
"{",
"if",
"(",
"typeof",
"current",
"==",
"\"function\"",
")",
"{",
"current",
"=",
"{",
"name",
":",
"current",
"[... | DOM specific version | [
"DOM",
"specific",
"version"
] | 705b9629ce0eb1f86989f88fde4dc39796c1d545 | https://github.com/WebReflection/wru/blob/705b9629ce0eb1f86989f88fde4dc39796c1d545/src/wru.DOM.functions.js#L2-L28 | train |
fgnass/tamper | index.js | patch | function patch(obj, properties) {
var old = {};
for (var name in properties) {
old[name] = obj[name];
obj[name] = properties[name];
}
return old;
} | javascript | function patch(obj, properties) {
var old = {};
for (var name in properties) {
old[name] = obj[name];
obj[name] = properties[name];
}
return old;
} | [
"function",
"patch",
"(",
"obj",
",",
"properties",
")",
"{",
"var",
"old",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"name",
"in",
"properties",
")",
"{",
"old",
"[",
"name",
"]",
"=",
"obj",
"[",
"name",
"]",
";",
"obj",
"[",
"name",
"]",
"=",
... | Overwrites properties of the given object and returns the old values | [
"Overwrites",
"properties",
"of",
"the",
"given",
"object",
"and",
"returns",
"the",
"old",
"values"
] | ae46c87dee0510298571f0343bf647116f9868de | https://github.com/fgnass/tamper/blob/ae46c87dee0510298571f0343bf647116f9868de/index.js#L67-L74 | train |
WebReflection/wru | src/wru.functions.js | giveItATry | function giveItATry(name) {
if (iHasIt(current, name)) {
try {
current[name](tmp);
} catch(doooodeThisIsBAD) {
push.call(fatal, EMPTY + doooodeThisIsBAD);
}
}
} | javascript | function giveItATry(name) {
if (iHasIt(current, name)) {
try {
current[name](tmp);
} catch(doooodeThisIsBAD) {
push.call(fatal, EMPTY + doooodeThisIsBAD);
}
}
} | [
"function",
"giveItATry",
"(",
"name",
")",
"{",
"if",
"(",
"iHasIt",
"(",
"current",
",",
"name",
")",
")",
"{",
"try",
"{",
"current",
"[",
"name",
"]",
"(",
"tmp",
")",
";",
"}",
"catch",
"(",
"doooodeThisIsBAD",
")",
"{",
"push",
".",
"call",
... | common functions for all versions | [
"common",
"functions",
"for",
"all",
"versions"
] | 705b9629ce0eb1f86989f88fde4dc39796c1d545 | https://github.com/WebReflection/wru/blob/705b9629ce0eb1f86989f88fde4dc39796c1d545/src/wru.functions.js#L2-L10 | train |
WebReflection/wru | src/wru.console.functions.js | isGonnaBeLegen | function isGonnaBeLegen() {
current = shift.call(queue);
if (current) {
if (typeof current == "function") {
current = {name: current[NAME] || "anonymous", test: current};
}
log(OUTPUT_SEPARATOR);
log(
(iHasIt(current, NAME) ... | javascript | function isGonnaBeLegen() {
current = shift.call(queue);
if (current) {
if (typeof current == "function") {
current = {name: current[NAME] || "anonymous", test: current};
}
log(OUTPUT_SEPARATOR);
log(
(iHasIt(current, NAME) ... | [
"function",
"isGonnaBeLegen",
"(",
")",
"{",
"current",
"=",
"shift",
".",
"call",
"(",
"queue",
")",
";",
"if",
"(",
"current",
")",
"{",
"if",
"(",
"typeof",
"current",
"==",
"\"function\"",
")",
"{",
"current",
"=",
"{",
"name",
":",
"current",
"[... | console specific version | [
"console",
"specific",
"version"
] | 705b9629ce0eb1f86989f88fde4dc39796c1d545 | https://github.com/WebReflection/wru/blob/705b9629ce0eb1f86989f88fde4dc39796c1d545/src/wru.console.functions.js#L2-L26 | train |
luxp/jqmath | src/jqmath.js | checkVertStretch | function checkVertStretch (up, dn, g, doP) /* non-MathML */ {
if (g.nodeName.toLowerCase() == 'mo' && g.childNodes.length == 1) {
var c = g.firstChild, s = c.data;
if (c.nodeType == 3 /* Text */ && (up > 0.9 || dn > 0.9)
&& (M.prefix_[s] < 25 || M.postfix_[s] < 25
|| '|\u2016\u221A' /* ‖ √... | javascript | function checkVertStretch (up, dn, g, doP) /* non-MathML */ {
if (g.nodeName.toLowerCase() == 'mo' && g.childNodes.length == 1) {
var c = g.firstChild, s = c.data;
if (c.nodeType == 3 /* Text */ && (up > 0.9 || dn > 0.9)
&& (M.prefix_[s] < 25 || M.postfix_[s] < 25
|| '|\u2016\u221A' /* ‖ √... | [
"function",
"checkVertStretch",
"(",
"up",
",",
"dn",
",",
"g",
",",
"doP",
")",
"/* non-MathML */",
"{",
"if",
"(",
"g",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
"==",
"'mo'",
"&&",
"g",
".",
"childNodes",
".",
"length",
"==",
"1",
")",
"{",
... | fmUp is mid-x to outer top, fmDn is mid-x to outer bottom, both approx. & in parent ems | [
"fmUp",
"is",
"mid",
"-",
"x",
"to",
"outer",
"top",
"fmDn",
"is",
"mid",
"-",
"x",
"to",
"outer",
"bottom",
"both",
"approx",
".",
"&",
"in",
"parent",
"ems"
] | 7a6051159c11e69e0f6ecba6e3f89801ef7e3984 | https://github.com/luxp/jqmath/blob/7a6051159c11e69e0f6ecba6e3f89801ef7e3984/src/jqmath.js#L258-L275 | train |
luxp/jqmath | src/jqmath.js | parse_table_tokP | function parse_table_tokP (dtableQ) {
if (dtableQ === undefined) dtableQ = M.dtableQ;
var mtrs = [];
while (true) {
var mtrP_tokP = parse_mtr_tokP(mtrs.length == 0), mtrP = mtrP_tokP[0],
tokP = mtrP_tokP[1] || scanTokP();
if (mtrP) mtrs.push(mtrP);
if (!(tokP && tokP[1] == ';'))
return [n... | javascript | function parse_table_tokP (dtableQ) {
if (dtableQ === undefined) dtableQ = M.dtableQ;
var mtrs = [];
while (true) {
var mtrP_tokP = parse_mtr_tokP(mtrs.length == 0), mtrP = mtrP_tokP[0],
tokP = mtrP_tokP[1] || scanTokP();
if (mtrP) mtrs.push(mtrP);
if (!(tokP && tokP[1] == ';'))
return [n... | [
"function",
"parse_table_tokP",
"(",
"dtableQ",
")",
"{",
"if",
"(",
"dtableQ",
"===",
"undefined",
")",
"dtableQ",
"=",
"M",
".",
"dtableQ",
";",
"var",
"mtrs",
"=",
"[",
"]",
";",
"while",
"(",
"true",
")",
"{",
"var",
"mtrP_tokP",
"=",
"parse_mtr_to... | whether \table defaults to \dtable | [
"whether",
"\\",
"table",
"defaults",
"to",
"\\",
"dtable"
] | 7a6051159c11e69e0f6ecba6e3f89801ef7e3984 | https://github.com/luxp/jqmath/blob/7a6051159c11e69e0f6ecba6e3f89801ef7e3984/src/jqmath.js#L1101-L1113 | train |
mhkeller/joiner | dist/joiner.node.js | listCacheSet$1 | function listCacheSet$1(key, value) {
var data = this.__data__,
index = assocIndexOf$4(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
} | javascript | function listCacheSet$1(key, value) {
var data = this.__data__,
index = assocIndexOf$4(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
} | [
"function",
"listCacheSet$1",
"(",
"key",
",",
"value",
")",
"{",
"var",
"data",
"=",
"this",
".",
"__data__",
",",
"index",
"=",
"assocIndexOf$4",
"(",
"data",
",",
"key",
")",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"++",
"this",
".",
"size"... | Sets the list cache `key` to `value`.
@private
@name set
@memberOf ListCache
@param {string} key The key of the value to set.
@param {*} value The value to set.
@returns {Object} Returns the list cache instance. | [
"Sets",
"the",
"list",
"cache",
"key",
"to",
"value",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L162-L173 | train |
mhkeller/joiner | dist/joiner.node.js | hashDelete$1 | function hashDelete$1(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
} | javascript | function hashDelete$1(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
} | [
"function",
"hashDelete$1",
"(",
"key",
")",
"{",
"var",
"result",
"=",
"this",
".",
"has",
"(",
"key",
")",
"&&",
"delete",
"this",
".",
"__data__",
"[",
"key",
"]",
";",
"this",
".",
"size",
"-=",
"result",
"?",
"1",
":",
"0",
";",
"return",
"r... | Removes `key` and its value from the hash.
@private
@name delete
@memberOf Hash
@param {Object} hash The hash to modify.
@param {string} key The key of the value to remove.
@returns {boolean} Returns `true` if the entry was removed, else `false`. | [
"Removes",
"key",
"and",
"its",
"value",
"from",
"the",
"hash",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L647-L651 | train |
mhkeller/joiner | dist/joiner.node.js | getMapData$1 | function getMapData$1(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
} | javascript | function getMapData$1(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
} | [
"function",
"getMapData$1",
"(",
"map",
",",
"key",
")",
"{",
"var",
"data",
"=",
"map",
".",
"__data__",
";",
"return",
"isKeyable",
"(",
"key",
")",
"?",
"data",
"[",
"typeof",
"key",
"==",
"'string'",
"?",
"'string'",
":",
"'hash'",
"]",
":",
"dat... | Gets the data for `map`.
@private
@param {Object} map The map to query.
@param {string} key The reference key.
@returns {*} Returns the map data. | [
"Gets",
"the",
"data",
"for",
"map",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L813-L816 | train |
mhkeller/joiner | dist/joiner.node.js | arrayEach$1 | function arrayEach$1(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
} | javascript | function arrayEach$1(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
} | [
"function",
"arrayEach$1",
"(",
"array",
",",
"iteratee",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
... | A specialized version of `_.forEach` for arrays without support for
iteratee shorthands.
@private
@param {Array} [array] The array to iterate over.
@param {Function} iteratee The function invoked per iteration.
@returns {Array} Returns `array`. | [
"A",
"specialized",
"version",
"of",
"_",
".",
"forEach",
"for",
"arrays",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L1001-L1011 | train |
mhkeller/joiner | dist/joiner.node.js | copyArray$1 | function copyArray$1(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
} | javascript | function copyArray$1(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
} | [
"function",
"copyArray$1",
"(",
"source",
",",
"array",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"source",
".",
"length",
";",
"array",
"||",
"(",
"array",
"=",
"Array",
"(",
"length",
")",
")",
";",
"while",
"(",
"++",
"index",... | Copies the values of `source` to `array`.
@private
@param {Array} source The array to copy values from.
@param {Array} [array=[]] The array to copy values to.
@returns {Array} Returns `array`. | [
"Copies",
"the",
"values",
"of",
"source",
"to",
"array",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L1851-L1860 | train |
mhkeller/joiner | dist/joiner.node.js | arrayPush$1 | function arrayPush$1(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
} | javascript | function arrayPush$1(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
} | [
"function",
"arrayPush$1",
"(",
"array",
",",
"values",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"values",
".",
"length",
",",
"offset",
"=",
"array",
".",
"length",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"ar... | Appends the elements of `values` to `array`.
@private
@param {Array} array The array to modify.
@param {Array} values The values to append.
@returns {Array} Returns `array`. | [
"Appends",
"the",
"elements",
"of",
"values",
"to",
"array",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L1970-L1979 | train |
mhkeller/joiner | dist/joiner.node.js | setToArray$1 | function setToArray$1(set) {
var index = -1,
result = Array(set.size);
set.forEach(function (value) {
result[++index] = value;
});
return result;
} | javascript | function setToArray$1(set) {
var index = -1,
result = Array(set.size);
set.forEach(function (value) {
result[++index] = value;
});
return result;
} | [
"function",
"setToArray$1",
"(",
"set",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"result",
"=",
"Array",
"(",
"set",
".",
"size",
")",
";",
"set",
".",
"forEach",
"(",
"function",
"(",
"value",
")",
"{",
"result",
"[",
"++",
"index",
"]",
"=... | Converts `set` to an array of its values.
@private
@param {Object} set The set to convert.
@returns {Array} Returns the values. | [
"Converts",
"set",
"to",
"an",
"array",
"of",
"its",
"values",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L2375-L2383 | train |
mhkeller/joiner | dist/joiner.node.js | arrayMap$1 | function arrayMap$1(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
} | javascript | function arrayMap$1(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
} | [
"function",
"arrayMap$1",
"(",
"array",
",",
"iteratee",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
"==",
"null",
"?",
"0",
":",
"array",
".",
"length",
",",
"result",
"=",
"Array",
"(",
"length",
")",
";",
"while",
"(",
... | A specialized version of `_.map` for arrays without support for iteratee
shorthands.
@private
@param {Array} [array] The array to iterate over.
@param {Function} iteratee The function invoked per iteration.
@returns {Array} Returns the new mapped array. | [
"A",
"specialized",
"version",
"of",
"_",
".",
"map",
"for",
"arrays",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L2940-L2949 | train |
mhkeller/joiner | dist/joiner.node.js | baseSet$1 | function baseSet$1(object, path, value, customizer) {
if (!isObject$6(object)) {
return object;
}
path = castPath$2(path, object);
var index = -1,
length = path.length,
lastIndex = length - 1,
nested = object;
while (nested != null && ++index < length) {
var key = toKey$2(path[inde... | javascript | function baseSet$1(object, path, value, customizer) {
if (!isObject$6(object)) {
return object;
}
path = castPath$2(path, object);
var index = -1,
length = path.length,
lastIndex = length - 1,
nested = object;
while (nested != null && ++index < length) {
var key = toKey$2(path[inde... | [
"function",
"baseSet$1",
"(",
"object",
",",
"path",
",",
"value",
",",
"customizer",
")",
"{",
"if",
"(",
"!",
"isObject$6",
"(",
"object",
")",
")",
"{",
"return",
"object",
";",
"}",
"path",
"=",
"castPath$2",
"(",
"path",
",",
"object",
")",
";",... | The base implementation of `_.set`.
@private
@param {Object} object The object to modify.
@param {Array|string} path The path of the property to set.
@param {*} value The value to set.
@param {Function} [customizer] The function to customize path creation.
@returns {Object} Returns `object`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"set",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3139-L3165 | train |
mhkeller/joiner | dist/joiner.node.js | baseSlice$1 | function baseSlice$1(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : length + start;
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : end - start >>> 0;
start >>>= 0;
var result = ... | javascript | function baseSlice$1(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : length + start;
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : end - start >>> 0;
start >>>= 0;
var result = ... | [
"function",
"baseSlice$1",
"(",
"array",
",",
"start",
",",
"end",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"start",
"=",
"-",
"start",
">",
"length",
"?",
... | The base implementation of `_.slice` without an iteratee call guard.
@private
@param {Array} array The array to slice.
@param {number} [start=0] The start position.
@param {number} [end=array.length] The end position.
@returns {Array} Returns the slice of `array`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"slice",
"without",
"an",
"iteratee",
"call",
"guard",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3235-L3254 | train |
mhkeller/joiner | dist/joiner.node.js | baseUnset$1 | function baseUnset$1(object, path) {
path = castPath$3(path, object);
object = parent(object, path);
return object == null || delete object[toKey$3(last(path))];
} | javascript | function baseUnset$1(object, path) {
path = castPath$3(path, object);
object = parent(object, path);
return object == null || delete object[toKey$3(last(path))];
} | [
"function",
"baseUnset$1",
"(",
"object",
",",
"path",
")",
"{",
"path",
"=",
"castPath$3",
"(",
"path",
",",
"object",
")",
";",
"object",
"=",
"parent",
"(",
"object",
",",
"path",
")",
";",
"return",
"object",
"==",
"null",
"||",
"delete",
"object",... | The base implementation of `_.unset`.
@private
@param {Object} object The object to modify.
@param {Array|string} path The property path to unset.
@returns {boolean} Returns `true` if the property is deleted, else `false`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"unset",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3288-L3292 | train |
mhkeller/joiner | dist/joiner.node.js | baseFindIndex$1 | function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while (fromRight ? index-- : ++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
} | javascript | function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while (fromRight ? index-- : ++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
} | [
"function",
"baseFindIndex$1",
"(",
"array",
",",
"predicate",
",",
"fromIndex",
",",
"fromRight",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
",",
"index",
"=",
"fromIndex",
"+",
"(",
"fromRight",
"?",
"1",
":",
"-",
"1",
")",
";",
"while"... | The base implementation of `_.findIndex` and `_.findLastIndex` without
support for iteratee shorthands.
@private
@param {Array} array The array to inspect.
@param {Function} predicate The function invoked per iteration.
@param {number} fromIndex The index to search from.
@param {boolean} [fromRight] Specify iterating ... | [
"The",
"base",
"implementation",
"of",
"_",
".",
"findIndex",
"and",
"_",
".",
"findLastIndex",
"without",
"support",
"for",
"iteratee",
"shorthands",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3405-L3415 | train |
mhkeller/joiner | dist/joiner.node.js | baseIndexOf$1 | function baseIndexOf$1(array, value, fromIndex) {
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
} | javascript | function baseIndexOf$1(array, value, fromIndex) {
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
} | [
"function",
"baseIndexOf$1",
"(",
"array",
",",
"value",
",",
"fromIndex",
")",
"{",
"return",
"value",
"===",
"value",
"?",
"strictIndexOf",
"(",
"array",
",",
"value",
",",
"fromIndex",
")",
":",
"baseFindIndex",
"(",
"array",
",",
"baseIsNaN",
",",
"fro... | The base implementation of `_.indexOf` without `fromIndex` bounds checks.
@private
@param {Array} array The array to inspect.
@param {*} value The value to search for.
@param {number} fromIndex The index to search from.
@returns {number} Returns the index of the matched value, else `-1`. | [
"The",
"base",
"implementation",
"of",
"_",
".",
"indexOf",
"without",
"fromIndex",
"bounds",
"checks",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3469-L3471 | train |
mhkeller/joiner | dist/joiner.node.js | shortOut$1 | function shortOut$1(func) {
var count = 0,
lastCalled = 0;
return function () {
var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count =... | javascript | function shortOut$1(func) {
var count = 0,
lastCalled = 0;
return function () {
var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count =... | [
"function",
"shortOut$1",
"(",
"func",
")",
"{",
"var",
"count",
"=",
"0",
",",
"lastCalled",
"=",
"0",
";",
"return",
"function",
"(",
")",
"{",
"var",
"stamp",
"=",
"nativeNow",
"(",
")",
",",
"remaining",
"=",
"HOT_SPAN",
"-",
"(",
"stamp",
"-",
... | Creates a function that'll short out and invoke `identity` instead
of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
milliseconds.
@private
@param {Function} func The function to restrict.
@returns {Function} Returns the new shortable function. | [
"Creates",
"a",
"function",
"that",
"ll",
"short",
"out",
"and",
"invoke",
"identity",
"instead",
"of",
"func",
"when",
"it",
"s",
"called",
"HOT_COUNT",
"or",
"more",
"times",
"in",
"HOT_SPAN",
"milliseconds",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3747-L3765 | train |
mhkeller/joiner | dist/joiner.node.js | baseDifference$1 | function baseDifference$1(array, values, iteratee, comparator) {
var index = -1,
includes = arrayIncludes$2,
isCommon = true,
length = array.length,
result = [],
valuesLength = values.length;
if (!length) {
return result;
}
if (iteratee) {
values = arrayMap$4(values, baseU... | javascript | function baseDifference$1(array, values, iteratee, comparator) {
var index = -1,
includes = arrayIncludes$2,
isCommon = true,
length = array.length,
result = [],
valuesLength = values.length;
if (!length) {
return result;
}
if (iteratee) {
values = arrayMap$4(values, baseU... | [
"function",
"baseDifference$1",
"(",
"array",
",",
"values",
",",
"iteratee",
",",
"comparator",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"includes",
"=",
"arrayIncludes$2",
",",
"isCommon",
"=",
"true",
",",
"length",
"=",
"array",
".",
"length",
"... | The base implementation of methods like `_.difference` without support
for excluding multiple arrays or iteratee shorthands.
@private
@param {Array} array The array to inspect.
@param {Array} values The values to exclude.
@param {Function} [iteratee] The iteratee invoked per element.
@param {Function} [comparator] The... | [
"The",
"base",
"implementation",
"of",
"methods",
"like",
"_",
".",
"difference",
"without",
"support",
"for",
"excluding",
"multiple",
"arrays",
"or",
"iteratee",
"shorthands",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3901-L3941 | train |
mhkeller/joiner | dist/joiner.node.js | baseFlatten$1 | function baseFlatten$1(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
/... | javascript | function baseFlatten$1(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
/... | [
"function",
"baseFlatten$1",
"(",
"array",
",",
"depth",
",",
"predicate",
",",
"isStrict",
",",
"result",
")",
"{",
"var",
"index",
"=",
"-",
"1",
",",
"length",
"=",
"array",
".",
"length",
";",
"predicate",
"||",
"(",
"predicate",
"=",
"isFlattenable"... | The base implementation of `_.flatten` with support for restricting flattening.
@private
@param {Array} array The array to flatten.
@param {number} depth The maximum recursion depth.
@param {boolean} [predicate=isFlattenable] The function invoked per iteration.
@param {boolean} [isStrict] Restrict to values that pass ... | [
"The",
"base",
"implementation",
"of",
"_",
".",
"flatten",
"with",
"support",
"for",
"restricting",
"flattening",
"."
] | 97d3010f8b61e8899a4ca068cbf8d467de6dc4e6 | https://github.com/mhkeller/joiner/blob/97d3010f8b61e8899a4ca068cbf8d467de6dc4e6/dist/joiner.node.js#L3979-L4000 | train |
krauskopf/node-red-contrib-avr-yamaha | avr-yamaha.js | function() {
if (node.debug) {
node.log('STARTING event listener');
}
var net = require('net');
var dgram = require('dgram');
node.inputSocket = dgram.createSocket({type:'udp4', reuseAddr: true});
node.inputSocket.on('notify', function (event) {
if (node.debug) {
... | javascript | function() {
if (node.debug) {
node.log('STARTING event listener');
}
var net = require('net');
var dgram = require('dgram');
node.inputSocket = dgram.createSocket({type:'udp4', reuseAddr: true});
node.inputSocket.on('notify', function (event) {
if (node.debug) {
... | [
"function",
"(",
")",
"{",
"if",
"(",
"node",
".",
"debug",
")",
"{",
"node",
".",
"log",
"(",
"'STARTING event listener'",
")",
";",
"}",
"var",
"net",
"=",
"require",
"(",
"'net'",
")",
";",
"var",
"dgram",
"=",
"require",
"(",
"'dgram'",
")",
";... | Internal sub routines | [
"Internal",
"sub",
"routines"
] | 88c66f4831c3b739c75173756bf62883cdf9391d | https://github.com/krauskopf/node-red-contrib-avr-yamaha/blob/88c66f4831c3b739c75173756bf62883cdf9391d/avr-yamaha.js#L318-L548 | train | |
doowb/unlazy-loader | index.js | transform | function transform(str) {
str = str.split(/^lazy\(/gm).join('require(');
var lines = str.split(/\r\n|\n/);
var len = lines.length;
var re = regex();
var idx = 0;
var start = false;
var isExported = false;
var namespace;
var res = '';
while (idx < len) {
var line = lines[idx++];
res += '\n'... | javascript | function transform(str) {
str = str.split(/^lazy\(/gm).join('require(');
var lines = str.split(/\r\n|\n/);
var len = lines.length;
var re = regex();
var idx = 0;
var start = false;
var isExported = false;
var namespace;
var res = '';
while (idx < len) {
var line = lines[idx++];
res += '\n'... | [
"function",
"transform",
"(",
"str",
")",
"{",
"str",
"=",
"str",
".",
"split",
"(",
"/",
"^lazy\\(",
"/",
"gm",
")",
".",
"join",
"(",
"'require('",
")",
";",
"var",
"lines",
"=",
"str",
".",
"split",
"(",
"/",
"\\r\\n|\\n",
"/",
")",
";",
"var"... | Transform source code containing lazy-cache statements into a requirable file usable with webpack.
@param {String} `source` Source code.
@return {String} Transformed source code. | [
"Transform",
"source",
"code",
"containing",
"lazy",
"-",
"cache",
"statements",
"into",
"a",
"requirable",
"file",
"usable",
"with",
"webpack",
"."
] | 52bc36ef8ce08a72d2181f25b7370f5f5271ea47 | https://github.com/doowb/unlazy-loader/blob/52bc36ef8ce08a72d2181f25b7370f5f5271ea47/index.js#L48-L107 | train |
doowb/unlazy-loader | index.js | camelcase | function camelcase(str) {
if (!/[\s\W]/.test(str)) return str;
if (str.length === 1) {
return str.toLowerCase();
}
str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase();
return str.replace(/[\W_]+(\w|$)/g, function(_, ch) {
return ch.toUpperCase();
});
} | javascript | function camelcase(str) {
if (!/[\s\W]/.test(str)) return str;
if (str.length === 1) {
return str.toLowerCase();
}
str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase();
return str.replace(/[\W_]+(\w|$)/g, function(_, ch) {
return ch.toUpperCase();
});
} | [
"function",
"camelcase",
"(",
"str",
")",
"{",
"if",
"(",
"!",
"/",
"[\\s\\W]",
"/",
".",
"test",
"(",
"str",
")",
")",
"return",
"str",
";",
"if",
"(",
"str",
".",
"length",
"===",
"1",
")",
"{",
"return",
"str",
".",
"toLowerCase",
"(",
")",
... | Used to camelcase the module if a variable is not defined.
@param {String} `str` String containing `_`, `.`, `-` or whitespace that will be camelcased.
@return {String} camelcased string. | [
"Used",
"to",
"camelcase",
"the",
"module",
"if",
"a",
"variable",
"is",
"not",
"defined",
"."
] | 52bc36ef8ce08a72d2181f25b7370f5f5271ea47 | https://github.com/doowb/unlazy-loader/blob/52bc36ef8ce08a72d2181f25b7370f5f5271ea47/index.js#L133-L142 | train |
dongsik-yoo/assemblyscript-live-loader | lib/index.js | createWasmModule | function createWasmModule(source, wasm) {
var length = wasm.length;
var buffer = [];
for (var i = 0; i < length; i += 1) {
buffer.push(wasm[i]);
}
var module = "var buffer = new ArrayBuffer(" + wasm.length + ");\n var uint8 = new Uint8Array(buffer);\n uint8.set([" + buffer.join... | javascript | function createWasmModule(source, wasm) {
var length = wasm.length;
var buffer = [];
for (var i = 0; i < length; i += 1) {
buffer.push(wasm[i]);
}
var module = "var buffer = new ArrayBuffer(" + wasm.length + ");\n var uint8 = new Uint8Array(buffer);\n uint8.set([" + buffer.join... | [
"function",
"createWasmModule",
"(",
"source",
",",
"wasm",
")",
"{",
"var",
"length",
"=",
"wasm",
".",
"length",
";",
"var",
"buffer",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"+=",
"1",
")",
"{... | Create a module using WebAssembly.Module
@param {string} source assemblyscript source
@param {Buffer} wasm WebAssembly Buffer
@returns {string} module string | [
"Create",
"a",
"module",
"using",
"WebAssembly",
".",
"Module"
] | f1b5b4b28a66d2a8534224d0a962ff90bd3741a0 | https://github.com/dongsik-yoo/assemblyscript-live-loader/blob/f1b5b4b28a66d2a8534224d0a962ff90bd3741a0/lib/index.js#L37-L45 | train |
dongsik-yoo/assemblyscript-live-loader | lib/index.js | createJsModule | function createJsModule(source) {
var compilerOptions = {
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
alwaysStrict: false
}
};
var transpiled = ts.transpileModule(source, compilerOptions);
return transpiled.outputTex... | javascript | function createJsModule(source) {
var compilerOptions = {
compilerOptions: {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.CommonJS,
alwaysStrict: false
}
};
var transpiled = ts.transpileModule(source, compilerOptions);
return transpiled.outputTex... | [
"function",
"createJsModule",
"(",
"source",
")",
"{",
"var",
"compilerOptions",
"=",
"{",
"compilerOptions",
":",
"{",
"target",
":",
"ts",
".",
"ScriptTarget",
".",
"ES5",
",",
"module",
":",
"ts",
".",
"ModuleKind",
".",
"CommonJS",
",",
"alwaysStrict",
... | Creates commonjs module for javascript
@param {string} source assemblyscript source
@returns {string} module string | [
"Creates",
"commonjs",
"module",
"for",
"javascript"
] | f1b5b4b28a66d2a8534224d0a962ff90bd3741a0 | https://github.com/dongsik-yoo/assemblyscript-live-loader/blob/f1b5b4b28a66d2a8534224d0a962ff90bd3741a0/lib/index.js#L51-L61 | train |
dongsik-yoo/assemblyscript-live-loader | lib/index.js | AssemblyScriptLiveLoader | function AssemblyScriptLiveLoader(source) {
var jsModule;
var wasmModule;
if (this.cacheable) {
this.cacheable();
}
this.addDependency(wasmFooterPath);
jsModule = createJsModule(source);
wasmModule = createWasmModule(source, compile(source));
return createCompatibleModule(jsModul... | javascript | function AssemblyScriptLiveLoader(source) {
var jsModule;
var wasmModule;
if (this.cacheable) {
this.cacheable();
}
this.addDependency(wasmFooterPath);
jsModule = createJsModule(source);
wasmModule = createWasmModule(source, compile(source));
return createCompatibleModule(jsModul... | [
"function",
"AssemblyScriptLiveLoader",
"(",
"source",
")",
"{",
"var",
"jsModule",
";",
"var",
"wasmModule",
";",
"if",
"(",
"this",
".",
"cacheable",
")",
"{",
"this",
".",
"cacheable",
"(",
")",
";",
"}",
"this",
".",
"addDependency",
"(",
"wasmFooterPa... | Webpack loader for assemblyscript to transform wasm and bundle it
@param {string} source - assemblyscript source file
@returns {string} module string | [
"Webpack",
"loader",
"for",
"assemblyscript",
"to",
"transform",
"wasm",
"and",
"bundle",
"it"
] | f1b5b4b28a66d2a8534224d0a962ff90bd3741a0 | https://github.com/dongsik-yoo/assemblyscript-live-loader/blob/f1b5b4b28a66d2a8534224d0a962ff90bd3741a0/lib/index.js#L89-L99 | train |
otothea/node-twitchcmd | lib/helpers.js | createTimeout | function createTimeout(timer, i, callback) {
return setTimeout(function() {
callback(timer, i);
}, timer.seconds * 1000);
} | javascript | function createTimeout(timer, i, callback) {
return setTimeout(function() {
callback(timer, i);
}, timer.seconds * 1000);
} | [
"function",
"createTimeout",
"(",
"timer",
",",
"i",
",",
"callback",
")",
"{",
"return",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"callback",
"(",
"timer",
",",
"i",
")",
";",
"}",
",",
"timer",
".",
"seconds",
"*",
"1000",
")",
";",
"}"
] | Create a new timeout
@param timer {object} - timer to use for the timeout
@param i {number} - index of the timer object
@param callback {function} - function to call when the timeout triggers | [
"Create",
"a",
"new",
"timeout"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/lib/helpers.js#L78-L82 | train |
otothea/node-twitchcmd | index.js | init | function init(_config) {
if (initialized)
return;
// Validate the config
config = helpers.validateConfig(_config);
// Create a user for the bot
users[config.name] = helpers.createUser(true);
// Create a user for the channel owner
var name = config.channel.replace('#', '');
users[name] = helpers.c... | javascript | function init(_config) {
if (initialized)
return;
// Validate the config
config = helpers.validateConfig(_config);
// Create a user for the bot
users[config.name] = helpers.createUser(true);
// Create a user for the channel owner
var name = config.channel.replace('#', '');
users[name] = helpers.c... | [
"function",
"init",
"(",
"_config",
")",
"{",
"if",
"(",
"initialized",
")",
"return",
";",
"// Validate the config",
"config",
"=",
"helpers",
".",
"validateConfig",
"(",
"_config",
")",
";",
"// Create a user for the bot",
"users",
"[",
"config",
".",
"name",
... | Init the twitch bot
@param _config {object} - config to init the bot with | [
"Init",
"the",
"twitch",
"bot"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L43-L98 | train |
otothea/node-twitchcmd | index.js | exit | function exit() {
if (!initialized || exited)
return;
log('Exiting...', true);
// Leave the twitch channel
if (ircClient)
ircClient.part(config.channel);
// Leave discord
if (discordClient)
discordClient.disconnect();
// Clear the stream check interval
if (streamInterval)
clearInterv... | javascript | function exit() {
if (!initialized || exited)
return;
log('Exiting...', true);
// Leave the twitch channel
if (ircClient)
ircClient.part(config.channel);
// Leave discord
if (discordClient)
discordClient.disconnect();
// Clear the stream check interval
if (streamInterval)
clearInterv... | [
"function",
"exit",
"(",
")",
"{",
"if",
"(",
"!",
"initialized",
"||",
"exited",
")",
"return",
";",
"log",
"(",
"'Exiting...'",
",",
"true",
")",
";",
"// Leave the twitch channel",
"if",
"(",
"ircClient",
")",
"ircClient",
".",
"part",
"(",
"config",
... | Exit the twitch bot | [
"Exit",
"the",
"twitch",
"bot"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L103-L127 | train |
otothea/node-twitchcmd | index.js | isSpam | function isSpam(from, message) {
if (!config.filterSpam)
return false;
// Skip if this is a mod
if (users[from] && users[from].mod)
return false;
// Check for capital letter spam
var uppercaseCount = message.replace(/[^A-Z]/g, '').length;
if (uppercaseCount >= 10 && uppercaseCount >= message.lengt... | javascript | function isSpam(from, message) {
if (!config.filterSpam)
return false;
// Skip if this is a mod
if (users[from] && users[from].mod)
return false;
// Check for capital letter spam
var uppercaseCount = message.replace(/[^A-Z]/g, '').length;
if (uppercaseCount >= 10 && uppercaseCount >= message.lengt... | [
"function",
"isSpam",
"(",
"from",
",",
"message",
")",
"{",
"if",
"(",
"!",
"config",
".",
"filterSpam",
")",
"return",
"false",
";",
"// Skip if this is a mod",
"if",
"(",
"users",
"[",
"from",
"]",
"&&",
"users",
"[",
"from",
"]",
".",
"mod",
")",
... | Helper functions
Check if message is spam
@param from {string} - nickname of user who sent the message
@param message {string} - message being sent
@returns {boolean} - true if spam, false if not | [
"Helper",
"functions",
"Check",
"if",
"message",
"is",
"spam"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L367-L383 | train |
otothea/node-twitchcmd | index.js | timeoutUser | function timeoutUser(name, seconds, reason) {
// Create a user if it doesn't exist
users[name] = users[name] || helpers.createUser();
users[name].offenses++;
var offenses = users[name].offenses;
if (offenses > config.maxOffenses)
banUser(name);
else {
seconds = seconds || (offenses === 1 ? 10 : 60... | javascript | function timeoutUser(name, seconds, reason) {
// Create a user if it doesn't exist
users[name] = users[name] || helpers.createUser();
users[name].offenses++;
var offenses = users[name].offenses;
if (offenses > config.maxOffenses)
banUser(name);
else {
seconds = seconds || (offenses === 1 ? 10 : 60... | [
"function",
"timeoutUser",
"(",
"name",
",",
"seconds",
",",
"reason",
")",
"{",
"// Create a user if it doesn't exist",
"users",
"[",
"name",
"]",
"=",
"users",
"[",
"name",
"]",
"||",
"helpers",
".",
"createUser",
"(",
")",
";",
"users",
"[",
"name",
"]"... | Timeout a user in chat
@param name {string} - nickname of the user to timeout
@param seconds {number|null} - number of seconds to timeout
@param reason {string} - the reason for the timeout | [
"Timeout",
"a",
"user",
"in",
"chat"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L406-L419 | train |
otothea/node-twitchcmd | index.js | say | function say(message, channelId) {
channelId = channelId || false;
if (channelId) {
sendDiscordMessage(channelId, message);
return;
}
if (!ircClient || typeof message !== 'string')
return;
ircClient.say(config.channel, message);
} | javascript | function say(message, channelId) {
channelId = channelId || false;
if (channelId) {
sendDiscordMessage(channelId, message);
return;
}
if (!ircClient || typeof message !== 'string')
return;
ircClient.say(config.channel, message);
} | [
"function",
"say",
"(",
"message",
",",
"channelId",
")",
"{",
"channelId",
"=",
"channelId",
"||",
"false",
";",
"if",
"(",
"channelId",
")",
"{",
"sendDiscordMessage",
"(",
"channelId",
",",
"message",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"i... | Say a message to chat
@param message {string} - send a message to chat
@param [channelId] {string} - id of discord channel | [
"Say",
"a",
"message",
"to",
"chat"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L436-L448 | train |
otothea/node-twitchcmd | index.js | sendDiscordMessage | function sendDiscordMessage(id, message) {
if (!discordClient || typeof id !== 'string' || typeof message !== 'string')
return;
discordClient.sendMessage({
to: id,
message: message,
});
} | javascript | function sendDiscordMessage(id, message) {
if (!discordClient || typeof id !== 'string' || typeof message !== 'string')
return;
discordClient.sendMessage({
to: id,
message: message,
});
} | [
"function",
"sendDiscordMessage",
"(",
"id",
",",
"message",
")",
"{",
"if",
"(",
"!",
"discordClient",
"||",
"typeof",
"id",
"!==",
"'string'",
"||",
"typeof",
"message",
"!==",
"'string'",
")",
"return",
";",
"discordClient",
".",
"sendMessage",
"(",
"{",
... | Send a message to Discord channel
@param id {string} - id of the channel to send message
@param message {string} - message to send to channel | [
"Send",
"a",
"message",
"to",
"Discord",
"channel"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L456-L464 | train |
otothea/node-twitchcmd | index.js | logChat | function logChat(from, message) {
if (typeof config.log !== 'string' || !from || typeof message !== 'string')
return;
// Get the current moment
var now = moment();
// Create the file name
var file = path.join(config.log, now.format('YYYY-MM-DD') + '-' + 'chat.log');
// Create the text to log based on... | javascript | function logChat(from, message) {
if (typeof config.log !== 'string' || !from || typeof message !== 'string')
return;
// Get the current moment
var now = moment();
// Create the file name
var file = path.join(config.log, now.format('YYYY-MM-DD') + '-' + 'chat.log');
// Create the text to log based on... | [
"function",
"logChat",
"(",
"from",
",",
"message",
")",
"{",
"if",
"(",
"typeof",
"config",
".",
"log",
"!==",
"'string'",
"||",
"!",
"from",
"||",
"typeof",
"message",
"!==",
"'string'",
")",
"return",
";",
"// Get the current moment",
"var",
"now",
"=",... | Log message to chat logs
@param from {string} - name of person sending the message
@param message {string} - the message sent | [
"Log",
"message",
"to",
"chat",
"logs"
] | 8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638 | https://github.com/otothea/node-twitchcmd/blob/8fd3e0ceda2e9ee179721bc53b9ce8f31ca6f638/index.js#L472-L490 | train |
jfairbank/marionette.component | src/marionette.component.js | function(region) {
if (this._isShown) {
throw new Error('This component is already shown in a region.');
}
if (!region) {
throw new Error('Please supply a region to show inside.');
}
this.region = region;
this.triggerMethod('before:show');
this._showView();
this._isShown ... | javascript | function(region) {
if (this._isShown) {
throw new Error('This component is already shown in a region.');
}
if (!region) {
throw new Error('Please supply a region to show inside.');
}
this.region = region;
this.triggerMethod('before:show');
this._showView();
this._isShown ... | [
"function",
"(",
"region",
")",
"{",
"if",
"(",
"this",
".",
"_isShown",
")",
"{",
"throw",
"new",
"Error",
"(",
"'This component is already shown in a region.'",
")",
";",
"}",
"if",
"(",
"!",
"region",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Please sup... | Show this component inside a region | [
"Show",
"this",
"component",
"inside",
"a",
"region"
] | 590c12ea65add290b46f44cdf465b5f2cc9d1e2e | https://github.com/jfairbank/marionette.component/blob/590c12ea65add290b46f44cdf465b5f2cc9d1e2e/src/marionette.component.js#L18-L35 | train | |
jfairbank/marionette.component | src/marionette.component.js | function() {
var view = this.view = this._getView();
this._initializeViewEvents();
// Trigger show:view after the view is shown in the region
this.listenTo(view, 'show', _.partial(this.triggerMethod, 'show:view'));
// Trigger before:show before the region shows the view
this.triggerMethod('be... | javascript | function() {
var view = this.view = this._getView();
this._initializeViewEvents();
// Trigger show:view after the view is shown in the region
this.listenTo(view, 'show', _.partial(this.triggerMethod, 'show:view'));
// Trigger before:show before the region shows the view
this.triggerMethod('be... | [
"function",
"(",
")",
"{",
"var",
"view",
"=",
"this",
".",
"view",
"=",
"this",
".",
"_getView",
"(",
")",
";",
"this",
".",
"_initializeViewEvents",
"(",
")",
";",
"// Trigger show:view after the view is shown in the region",
"this",
".",
"listenTo",
"(",
"v... | Show the view in the region | [
"Show",
"the",
"view",
"in",
"the",
"region"
] | 590c12ea65add290b46f44cdf465b5f2cc9d1e2e | https://github.com/jfairbank/marionette.component/blob/590c12ea65add290b46f44cdf465b5f2cc9d1e2e/src/marionette.component.js#L55-L72 | train | |
yamadapc/mocha-spec-cov-alt | bin/index.js | any | function any(target, fn) {
var keys = Object.keys(target);
for(var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
var value = target[key];
if(fn(value, key)) return true;
}
return false;
} | javascript | function any(target, fn) {
var keys = Object.keys(target);
for(var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
var value = target[key];
if(fn(value, key)) return true;
}
return false;
} | [
"function",
"any",
"(",
"target",
",",
"fn",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"target",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"keys",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
... | Applies a predicate to collection and returns true if any of the items match
it | [
"Applies",
"a",
"predicate",
"to",
"collection",
"and",
"returns",
"true",
"if",
"any",
"of",
"the",
"items",
"match",
"it"
] | 2f834c58e15bc186441cf21d0e2c586de13c6e9b | https://github.com/yamadapc/mocha-spec-cov-alt/blob/2f834c58e15bc186441cf21d0e2c586de13c6e9b/bin/index.js#L65-L73 | train |
yamadapc/mocha-spec-cov-alt | bin/index.js | extend | function extend(target, source) {
var keys = Object.keys(source);
for(var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
target[key] = source[key];
}
return target;
} | javascript | function extend(target, source) {
var keys = Object.keys(source);
for(var i = 0, len = keys.length; i < len; i++) {
var key = keys[i];
target[key] = source[key];
}
return target;
} | [
"function",
"extend",
"(",
"target",
",",
"source",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"source",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"keys",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
... | Merges two objects together, overwriting the second's properties onto the
first.
@param {Object} target
@param {Object} source
@return {Object} result The modified `target` parameter | [
"Merges",
"two",
"objects",
"together",
"overwriting",
"the",
"second",
"s",
"properties",
"onto",
"the",
"first",
"."
] | 2f834c58e15bc186441cf21d0e2c586de13c6e9b | https://github.com/yamadapc/mocha-spec-cov-alt/blob/2f834c58e15bc186441cf21d0e2c586de13c6e9b/bin/index.js#L84-L91 | train |
Xaxis/jquery.eye | src/jquery.eye.js | function() {
$.each(watched_props, function(index, value) {
if (index != '_interval' && index != '_interval_func' && index != '_element' && index != '_speed' && index != '_status' && index != '_load') {
var new_value = value.orig_value;
// Are we returning a jQuery function value... | javascript | function() {
$.each(watched_props, function(index, value) {
if (index != '_interval' && index != '_interval_func' && index != '_element' && index != '_speed' && index != '_status' && index != '_load') {
var new_value = value.orig_value;
// Are we returning a jQuery function value... | [
"function",
"(",
")",
"{",
"$",
".",
"each",
"(",
"watched_props",
",",
"function",
"(",
"index",
",",
"value",
")",
"{",
"if",
"(",
"index",
"!=",
"'_interval'",
"&&",
"index",
"!=",
"'_interval_func'",
"&&",
"index",
"!=",
"'_element'",
"&&",
"index",
... | Reference the interval function | [
"Reference",
"the",
"interval",
"function"
] | 4abf914194c04cd0536f65d110b03d226e9cacdc | https://github.com/Xaxis/jquery.eye/blob/4abf914194c04cd0536f65d110b03d226e9cacdc/src/jquery.eye.js#L124-L187 | train | |
numbers1311407/mongoose-friends | lib/plugin.js | function (query, update, fship) {
var options = { new: false };
return function (done) {
this.findOneAndUpdate(query, update, options, function (err, res) {
done(err, fship);
});
}
} | javascript | function (query, update, fship) {
var options = { new: false };
return function (done) {
this.findOneAndUpdate(query, update, options, function (err, res) {
done(err, fship);
});
}
} | [
"function",
"(",
"query",
",",
"update",
",",
"fship",
")",
"{",
"var",
"options",
"=",
"{",
"new",
":",
"false",
"}",
";",
"return",
"function",
"(",
"done",
")",
"{",
"this",
".",
"findOneAndUpdate",
"(",
"query",
",",
"update",
",",
"options",
","... | The work function which pushes or updates embedded friend objects
for two documents, returns a function
@api private | [
"The",
"work",
"function",
"which",
"pushes",
"or",
"updates",
"embedded",
"friend",
"objects",
"for",
"two",
"documents",
"returns",
"a",
"function"
] | da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc | https://github.com/numbers1311407/mongoose-friends/blob/da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc/lib/plugin.js#L66-L74 | train | |
numbers1311407/mongoose-friends | lib/plugin.js | function (m1, m2, fship) {
var query = {_id: m1};
query[pathName] = {$elemMatch: {_id: m2}};
var updater = {$set: {}};
updater.$set[pathName+".$.status"] = fship.status;
return _update(query, updater, fship);
} | javascript | function (m1, m2, fship) {
var query = {_id: m1};
query[pathName] = {$elemMatch: {_id: m2}};
var updater = {$set: {}};
updater.$set[pathName+".$.status"] = fship.status;
return _update(query, updater, fship);
} | [
"function",
"(",
"m1",
",",
"m2",
",",
"fship",
")",
"{",
"var",
"query",
"=",
"{",
"_id",
":",
"m1",
"}",
";",
"query",
"[",
"pathName",
"]",
"=",
"{",
"$elemMatch",
":",
"{",
"_id",
":",
"m2",
"}",
"}",
";",
"var",
"updater",
"=",
"{",
"$se... | Return a function to update a friendship between two parties
@api private | [
"Return",
"a",
"function",
"to",
"update",
"a",
"friendship",
"between",
"two",
"parties"
] | da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc | https://github.com/numbers1311407/mongoose-friends/blob/da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc/lib/plugin.js#L81-L89 | train | |
numbers1311407/mongoose-friends | lib/plugin.js | function (m1, m2, fship) {
var query = {_id: m1};
fship.added = new Date();
var updater = {$push: {}};
updater.$push[pathName] = fship;
return _update(query, updater, fship);
} | javascript | function (m1, m2, fship) {
var query = {_id: m1};
fship.added = new Date();
var updater = {$push: {}};
updater.$push[pathName] = fship;
return _update(query, updater, fship);
} | [
"function",
"(",
"m1",
",",
"m2",
",",
"fship",
")",
"{",
"var",
"query",
"=",
"{",
"_id",
":",
"m1",
"}",
";",
"fship",
".",
"added",
"=",
"new",
"Date",
"(",
")",
";",
"var",
"updater",
"=",
"{",
"$push",
":",
"{",
"}",
"}",
";",
"updater",... | Return a function to create a new friendship between two parties
@api private | [
"Return",
"a",
"function",
"to",
"create",
"a",
"new",
"friendship",
"between",
"two",
"parties"
] | da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc | https://github.com/numbers1311407/mongoose-friends/blob/da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc/lib/plugin.js#L97-L106 | train | |
numbers1311407/mongoose-friends | lib/plugin.js | function (done) {
var select = {};
select[pathName] = 1;
Model.findOne({_id: model}, select, function (err, doc) {
if (err) return done(err);
if (!doc) return done(null, []);
done(null, doc[pathName].reduce(function (o, friend) {
... | javascript | function (done) {
var select = {};
select[pathName] = 1;
Model.findOne({_id: model}, select, function (err, doc) {
if (err) return done(err);
if (!doc) return done(null, []);
done(null, doc[pathName].reduce(function (o, friend) {
... | [
"function",
"(",
"done",
")",
"{",
"var",
"select",
"=",
"{",
"}",
";",
"select",
"[",
"pathName",
"]",
"=",
"1",
";",
"Model",
".",
"findOne",
"(",
"{",
"_id",
":",
"model",
"}",
",",
"select",
",",
"function",
"(",
"err",
",",
"doc",
")",
"{"... | Reduce local friend docs to map which will be populated and then combined with the queried remote friends to generate the resulting array | [
"Reduce",
"local",
"friend",
"docs",
"to",
"map",
"which",
"will",
"be",
"populated",
"and",
"then",
"combined",
"with",
"the",
"queried",
"remote",
"friends",
"to",
"generate",
"the",
"resulting",
"array"
] | da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc | https://github.com/numbers1311407/mongoose-friends/blob/da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc/lib/plugin.js#L308-L321 | train | |
numbers1311407/mongoose-friends | lib/plugin.js | defaults | function defaults(options, defaultOptions) {
options || (options = {});
for (var opt in defaultOptions) {
if (defaultOptions.hasOwnProperty(opt) && !options.hasOwnProperty(opt)) {
options[opt] = defaultOptions[opt];
}
}
return options;
} | javascript | function defaults(options, defaultOptions) {
options || (options = {});
for (var opt in defaultOptions) {
if (defaultOptions.hasOwnProperty(opt) && !options.hasOwnProperty(opt)) {
options[opt] = defaultOptions[opt];
}
}
return options;
} | [
"function",
"defaults",
"(",
"options",
",",
"defaultOptions",
")",
"{",
"options",
"||",
"(",
"options",
"=",
"{",
"}",
")",
";",
"for",
"(",
"var",
"opt",
"in",
"defaultOptions",
")",
"{",
"if",
"(",
"defaultOptions",
".",
"hasOwnProperty",
"(",
"opt",... | simple function for extending an object with defaults
@api private | [
"simple",
"function",
"for",
"extending",
"an",
"object",
"with",
"defaults"
] | da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc | https://github.com/numbers1311407/mongoose-friends/blob/da567ac5c0e3c83fa3cbaa4f52ae1d7c7e3949cc/lib/plugin.js#L491-L501 | train |
thlorenz/hha | lib/storyboard.js | resetSeat | function resetSeat(s) {
const street = this.street
const stage = this.stage
const preflop = street === 'preflop'
const chipsName = 'chips' + street[0].toUpperCase() + street.slice(1)
const p = script.players[s.playerIdx]
const chips = p[chipsName]
return Object.assign({}, seats[p.seatno], ... | javascript | function resetSeat(s) {
const street = this.street
const stage = this.stage
const preflop = street === 'preflop'
const chipsName = 'chips' + street[0].toUpperCase() + street.slice(1)
const p = script.players[s.playerIdx]
const chips = p[chipsName]
return Object.assign({}, seats[p.seatno], ... | [
"function",
"resetSeat",
"(",
"s",
")",
"{",
"const",
"street",
"=",
"this",
".",
"street",
"const",
"stage",
"=",
"this",
".",
"stage",
"const",
"preflop",
"=",
"street",
"===",
"'preflop'",
"const",
"chipsName",
"=",
"'chips'",
"+",
"street",
"[",
"0",... | From now on we always map seats even though we reuse the variable in order to avoid affecting previous states | [
"From",
"now",
"on",
"we",
"always",
"map",
"seats",
"even",
"though",
"we",
"reuse",
"the",
"variable",
"in",
"order",
"to",
"avoid",
"affecting",
"previous",
"states"
] | 28ae03e9d422881ad8a3b3dba9de32e01d8ac04c | https://github.com/thlorenz/hha/blob/28ae03e9d422881ad8a3b3dba9de32e01d8ac04c/lib/storyboard.js#L72-L89 | train |
alexyoung/ico | src/normaliser.js | function() {
var min = typeof this.options.start_value !== 'undefined' && this.min >= 0 ? this.options.start_value : this.min,
start_value = this.round(min, 1);
/* This is a boundary condition */
if (this.min > 0 && start_value > this.min) {
return 0;
}
if (this.min === this.max) {
... | javascript | function() {
var min = typeof this.options.start_value !== 'undefined' && this.min >= 0 ? this.options.start_value : this.min,
start_value = this.round(min, 1);
/* This is a boundary condition */
if (this.min > 0 && start_value > this.min) {
return 0;
}
if (this.min === this.max) {
... | [
"function",
"(",
")",
"{",
"var",
"min",
"=",
"typeof",
"this",
".",
"options",
".",
"start_value",
"!==",
"'undefined'",
"&&",
"this",
".",
"min",
">=",
"0",
"?",
"this",
".",
"options",
".",
"start_value",
":",
"this",
".",
"min",
",",
"start_value",... | Calculates the start value. This is often 0.
@returns {Float} The start value | [
"Calculates",
"the",
"start",
"value",
".",
"This",
"is",
"often",
"0",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/normaliser.js#L30-L44 | train | |
alexyoung/ico | src/normaliser.js | function(value) {
return Math.pow(10, Math.round((Math.log(value) / Math.LN10)) - 1);
} | javascript | function(value) {
return Math.pow(10, Math.round((Math.log(value) / Math.LN10)) - 1);
} | [
"function",
"(",
"value",
")",
"{",
"return",
"Math",
".",
"pow",
"(",
"10",
",",
"Math",
".",
"round",
"(",
"(",
"Math",
".",
"log",
"(",
"value",
")",
"/",
"Math",
".",
"LN10",
")",
")",
"-",
"1",
")",
";",
"}"
] | Calculates the label step value.
@param {Float} value A value to convert to a label position
@returns {Float} The rounded label step result | [
"Calculates",
"the",
"label",
"step",
"value",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/normaliser.js#L76-L78 | train | |
alexyoung/ico | src/graphs/bar.js | function(data, options) {
if (typeof data.length !== 'undefined') {
if (typeof data[0].length !== 'undefined') {
this.grouped = true;
// TODO: Find longest?
this.group_size = data[0].length;
var o = {}, k, i = 0;
for (k in options.labels) {
k = options.labels... | javascript | function(data, options) {
if (typeof data.length !== 'undefined') {
if (typeof data[0].length !== 'undefined') {
this.grouped = true;
// TODO: Find longest?
this.group_size = data[0].length;
var o = {}, k, i = 0;
for (k in options.labels) {
k = options.labels... | [
"function",
"(",
"data",
",",
"options",
")",
"{",
"if",
"(",
"typeof",
"data",
".",
"length",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"typeof",
"data",
"[",
"0",
"]",
".",
"length",
"!==",
"'undefined'",
")",
"{",
"this",
".",
"grouped",
"=",
"... | Overridden to handle grouped bar graphs | [
"Overridden",
"to",
"handle",
"grouped",
"bar",
"graphs"
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/graphs/bar.js#L13-L33 | train | |
alexyoung/ico | src/graphs/bar.js | function() {
// Make sure the true largest value is used for max
return this.options.line ? { start_value: 0, max: Helpers.max([Helpers.max(this.options.line), Helpers.max(this.flat_data)]) } : { start_value: 0 };
} | javascript | function() {
// Make sure the true largest value is used for max
return this.options.line ? { start_value: 0, max: Helpers.max([Helpers.max(this.options.line), Helpers.max(this.flat_data)]) } : { start_value: 0 };
} | [
"function",
"(",
")",
"{",
"// Make sure the true largest value is used for max",
"return",
"this",
".",
"options",
".",
"line",
"?",
"{",
"start_value",
":",
"0",
",",
"max",
":",
"Helpers",
".",
"max",
"(",
"[",
"Helpers",
".",
"max",
"(",
"this",
".",
"... | Ensures the normalises is always 0. | [
"Ensures",
"the",
"normalises",
"is",
"always",
"0",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/graphs/bar.js#L45-L48 | train | |
alexyoung/ico | src/graphs/bar.js | function() {
this.bar_padding = this.options.bar_padding || 5;
this.bar_width = this.options.bar_size || this.calculateBarWidth();
if (this.options.bar_size && !this.options.bar_padding) {
this.bar_padding = this.graph_width / this.data_size;
}
this.options.plot_padding = (this.bar_width / 2... | javascript | function() {
this.bar_padding = this.options.bar_padding || 5;
this.bar_width = this.options.bar_size || this.calculateBarWidth();
if (this.options.bar_size && !this.options.bar_padding) {
this.bar_padding = this.graph_width / this.data_size;
}
this.options.plot_padding = (this.bar_width / 2... | [
"function",
"(",
")",
"{",
"this",
".",
"bar_padding",
"=",
"this",
".",
"options",
".",
"bar_padding",
"||",
"5",
";",
"this",
".",
"bar_width",
"=",
"this",
".",
"options",
".",
"bar_size",
"||",
"this",
".",
"calculateBarWidth",
"(",
")",
";",
"if",... | Options specific to BarGraph. | [
"Options",
"specific",
"to",
"BarGraph",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/graphs/bar.js#L53-L65 | train | |
alexyoung/ico | src/graphs/bar.js | function() {
var width = (this.graph_width / this.data_size) - this.bar_padding;
if (this.grouped) {
//width = width / this.group_size - (this.bar_padding * this.group_size);
}
if (this.options.max_bar_size && width > this.options.max_bar_size) {
width = this.options.max_bar_size;
th... | javascript | function() {
var width = (this.graph_width / this.data_size) - this.bar_padding;
if (this.grouped) {
//width = width / this.group_size - (this.bar_padding * this.group_size);
}
if (this.options.max_bar_size && width > this.options.max_bar_size) {
width = this.options.max_bar_size;
th... | [
"function",
"(",
")",
"{",
"var",
"width",
"=",
"(",
"this",
".",
"graph_width",
"/",
"this",
".",
"data_size",
")",
"-",
"this",
".",
"bar_padding",
";",
"if",
"(",
"this",
".",
"grouped",
")",
"{",
"//width = width / this.group_size - (this.bar_padding * thi... | Calculates the width of each bar.
@returns {Integer} The bar width | [
"Calculates",
"the",
"width",
"of",
"each",
"bar",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/graphs/bar.js#L72-L85 | train | |
alexyoung/ico | src/graphs/bar.js | function(index, pathString, x, y, colour) {
if (this.options.highlight_colours && this.options.highlight_colours.hasOwnProperty(index)) {
colour = this.options.highlight_colours[index];
}
x = x + this.bar_padding;
pathString += 'M' + x + ',' + this.start_y;
pathString += 'L' + x + ',' + y;
... | javascript | function(index, pathString, x, y, colour) {
if (this.options.highlight_colours && this.options.highlight_colours.hasOwnProperty(index)) {
colour = this.options.highlight_colours[index];
}
x = x + this.bar_padding;
pathString += 'M' + x + ',' + this.start_y;
pathString += 'L' + x + ',' + y;
... | [
"function",
"(",
"index",
",",
"pathString",
",",
"x",
",",
"y",
",",
"colour",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"highlight_colours",
"&&",
"this",
".",
"options",
".",
"highlight_colours",
".",
"hasOwnProperty",
"(",
"index",
")",
")",
... | Generates paths for Raphael.
@param {Integer} index The index of the data value to plot
@param {String} pathString The pathString so far
@param {Integer} x The x-coord to plot
@param {Integer} y The y-coord to plot
@param {String} colour A string that represents a colour
@returns {String} The resulting path string | [
"Generates",
"paths",
"for",
"Raphael",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/graphs/bar.js#L106-L119 | train | |
alexyoung/ico | docs/prettify.js | attribToHtml | function attribToHtml(str) {
return str.replace(pr_amp, '&')
.replace(pr_lt, '<')
.replace(pr_gt, '>')
.replace(pr_quot, '"');
} | javascript | function attribToHtml(str) {
return str.replace(pr_amp, '&')
.replace(pr_lt, '<')
.replace(pr_gt, '>')
.replace(pr_quot, '"');
} | [
"function",
"attribToHtml",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"pr_amp",
",",
"'&'",
")",
".",
"replace",
"(",
"pr_lt",
",",
"'<'",
")",
".",
"replace",
"(",
"pr_gt",
",",
"'>'",
")",
".",
"replace",
"(",
"pr_quot",
... | like textToHtml but escapes double quotes to be attribute safe. | [
"like",
"textToHtml",
"but",
"escapes",
"double",
"quotes",
"to",
"be",
"attribute",
"safe",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L229-L234 | train |
alexyoung/ico | docs/prettify.js | htmlToText | function htmlToText(html) {
var pos = html.indexOf('&');
if (pos < 0) { return html; }
// Handle numeric entities specially. We can't use functional substitution
// since that doesn't work in older versions of Safari.
// These should be rare since most browsers convert them to normal chars.
for... | javascript | function htmlToText(html) {
var pos = html.indexOf('&');
if (pos < 0) { return html; }
// Handle numeric entities specially. We can't use functional substitution
// since that doesn't work in older versions of Safari.
// These should be rare since most browsers convert them to normal chars.
for... | [
"function",
"htmlToText",
"(",
"html",
")",
"{",
"var",
"pos",
"=",
"html",
".",
"indexOf",
"(",
"'&'",
")",
";",
"if",
"(",
"pos",
"<",
"0",
")",
"{",
"return",
"html",
";",
"}",
"// Handle numeric entities specially. We can't use functional substitution",
"... | unescapes html to plain text. | [
"unescapes",
"html",
"to",
"plain",
"text",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L251-L280 | train |
alexyoung/ico | docs/prettify.js | isPreformatted | function isPreformatted(node, content) {
// PRE means preformatted, and is a very common case, so don't create
// unnecessary computed style objects.
if ('PRE' === node.tagName) { return true; }
if (!newlineRe.test(content)) { return true; } // Don't care
var whitespace = '';
// For disconnecte... | javascript | function isPreformatted(node, content) {
// PRE means preformatted, and is a very common case, so don't create
// unnecessary computed style objects.
if ('PRE' === node.tagName) { return true; }
if (!newlineRe.test(content)) { return true; } // Don't care
var whitespace = '';
// For disconnecte... | [
"function",
"isPreformatted",
"(",
"node",
",",
"content",
")",
"{",
"// PRE means preformatted, and is a very common case, so don't create",
"// unnecessary computed style objects.",
"if",
"(",
"'PRE'",
"===",
"node",
".",
"tagName",
")",
"{",
"return",
"true",
";",
"}",... | Are newlines and adjacent spaces significant in the given node's innerHTML? | [
"Are",
"newlines",
"and",
"adjacent",
"spaces",
"significant",
"in",
"the",
"given",
"node",
"s",
"innerHTML?"
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L291-L306 | train |
alexyoung/ico | docs/prettify.js | makeTabExpander | function makeTabExpander(tabWidth) {
var SPACES = ' ';
var charInLine = 0;
return function (plainText) {
// walk over each character looking for tabs and newlines.
// On tabs, expand them. On newlines, reset charInLine.
// Otherwise increment charInLine
var out = nul... | javascript | function makeTabExpander(tabWidth) {
var SPACES = ' ';
var charInLine = 0;
return function (plainText) {
// walk over each character looking for tabs and newlines.
// On tabs, expand them. On newlines, reset charInLine.
// Otherwise increment charInLine
var out = nul... | [
"function",
"makeTabExpander",
"(",
"tabWidth",
")",
"{",
"var",
"SPACES",
"=",
"' '",
";",
"var",
"charInLine",
"=",
"0",
";",
"return",
"function",
"(",
"plainText",
")",
"{",
"// walk over each character looking for tabs and newlines.",
"// On tabs, ex... | returns a function that expand tabs to spaces. This function can be fed
successive chunks of text, and will maintain its own internal state to
keep track of how tabs are expanded.
@return {function (string) : string} a function that takes
plain text and return the text with tabs expanded.
@private | [
"returns",
"a",
"function",
"that",
"expand",
"tabs",
"to",
"spaces",
".",
"This",
"function",
"can",
"be",
"fed",
"successive",
"chunks",
"of",
"text",
"and",
"will",
"maintain",
"its",
"own",
"internal",
"state",
"to",
"keep",
"track",
"of",
"how",
"tabs... | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L613-L652 | train |
alexyoung/ico | docs/prettify.js | function (job) {
var sourceCode = job.source, basePos = job.basePos;
/** Even entries are positions in source in ascending order. Odd enties
* are style markers (e.g., PR_COMMENT) that run from that position until
* the end.
* @type {Array.<number|string>}
*/
var decor... | javascript | function (job) {
var sourceCode = job.source, basePos = job.basePos;
/** Even entries are positions in source in ascending order. Odd enties
* are style markers (e.g., PR_COMMENT) that run from that position until
* the end.
* @type {Array.<number|string>}
*/
var decor... | [
"function",
"(",
"job",
")",
"{",
"var",
"sourceCode",
"=",
"job",
".",
"source",
",",
"basePos",
"=",
"job",
".",
"basePos",
";",
"/** Even entries are positions in source in ascending order. Odd enties\n * are style markers (e.g., PR_COMMENT) that run from that position... | Lexes job.source and produces an output array job.decorations of style
classes preceded by the position at which they start in job.source in
order.
@param {Object} job an object like {@code
source: {string} sourceText plain text,
basePos: {int} position of job.source in the larger chunk of
sourceCode.
} | [
"Lexes",
"job",
".",
"source",
"and",
"produces",
"an",
"output",
"array",
"job",
".",
"decorations",
"of",
"style",
"classes",
"preceded",
"by",
"the",
"position",
"at",
"which",
"they",
"start",
"in",
"job",
".",
"source",
"in",
"order",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L849-L934 | train | |
alexyoung/ico | docs/prettify.js | sourceDecorator | function sourceDecorator(options) {
var shortcutStylePatterns = [], fallthroughStylePatterns = [];
if (options['tripleQuotedStrings']) {
// '''multi-line-string''', 'single-line-string', and double-quoted
shortcutStylePatterns.push(
[PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\... | javascript | function sourceDecorator(options) {
var shortcutStylePatterns = [], fallthroughStylePatterns = [];
if (options['tripleQuotedStrings']) {
// '''multi-line-string''', 'single-line-string', and double-quoted
shortcutStylePatterns.push(
[PR_STRING, /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\... | [
"function",
"sourceDecorator",
"(",
"options",
")",
"{",
"var",
"shortcutStylePatterns",
"=",
"[",
"]",
",",
"fallthroughStylePatterns",
"=",
"[",
"]",
";",
"if",
"(",
"options",
"[",
"'tripleQuotedStrings'",
"]",
")",
"{",
"// '''multi-line-string''', 'single-line-... | returns a function that produces a list of decorations from source text.
This code treats ", ', and ` as string delimiters, and \ as a string
escape. It does not recognize perl's qq() style strings.
It has no special handling for double delimiter escapes as in basic, or
the tripled delimiters used in python, but shou... | [
"returns",
"a",
"function",
"that",
"produces",
"a",
"list",
"of",
"decorations",
"from",
"source",
"text",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L953-L1045 | train |
alexyoung/ico | docs/prettify.js | emitTextUpTo | function emitTextUpTo(sourceIdx) {
if (sourceIdx > outputIdx) {
if (openDecoration && openDecoration !== currentDecoration) {
// Close the current decoration
html.push('</span>');
openDecoration = null;
}
if (!openDecoration && currentDecoration) {
o... | javascript | function emitTextUpTo(sourceIdx) {
if (sourceIdx > outputIdx) {
if (openDecoration && openDecoration !== currentDecoration) {
// Close the current decoration
html.push('</span>');
openDecoration = null;
}
if (!openDecoration && currentDecoration) {
o... | [
"function",
"emitTextUpTo",
"(",
"sourceIdx",
")",
"{",
"if",
"(",
"sourceIdx",
">",
"outputIdx",
")",
"{",
"if",
"(",
"openDecoration",
"&&",
"openDecoration",
"!==",
"currentDecoration",
")",
"{",
"// Close the current decoration",
"html",
".",
"push",
"(",
"'... | A helper function that is responsible for opening sections of decoration and outputing properly escaped chunks of source | [
"A",
"helper",
"function",
"that",
"is",
"responsible",
"for",
"opening",
"sections",
"of",
"decoration",
"and",
"outputing",
"properly",
"escaped",
"chunks",
"of",
"source"
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/docs/prettify.js#L1135-L1164 | train |
sockethub/sockethub-platform-xmpp | lib/incoming-handlers.js | referenceProtection | function referenceProtection(session) {
function checkScope(funcName) {
return (msg) => {
if (typeof session[funcName] === 'function') {
session[funcName](msg);
}
}
}
return {
actor: session.actor,
debug: checkScope('debug'),
sendToClient: checkScope('sendToClient')
}
} | javascript | function referenceProtection(session) {
function checkScope(funcName) {
return (msg) => {
if (typeof session[funcName] === 'function') {
session[funcName](msg);
}
}
}
return {
actor: session.actor,
debug: checkScope('debug'),
sendToClient: checkScope('sendToClient')
}
} | [
"function",
"referenceProtection",
"(",
"session",
")",
"{",
"function",
"checkScope",
"(",
"funcName",
")",
"{",
"return",
"(",
"msg",
")",
"=>",
"{",
"if",
"(",
"typeof",
"session",
"[",
"funcName",
"]",
"===",
"'function'",
")",
"{",
"session",
"[",
"... | if the platform throws an exception, the worker will kill & restart it, however if a callback comes in there could be a race condition which tries to still access session functions which have already been terminated by the worker. this function wrapper only calls the session functions if they still exist. | [
"if",
"the",
"platform",
"throws",
"an",
"exception",
"the",
"worker",
"will",
"kill",
"&",
"restart",
"it",
"however",
"if",
"a",
"callback",
"comes",
"in",
"there",
"could",
"be",
"a",
"race",
"condition",
"which",
"tries",
"to",
"still",
"access",
"sess... | 1a7f50b77320bedf9555a1e8cb546e92c6b19132 | https://github.com/sockethub/sockethub-platform-xmpp/blob/1a7f50b77320bedf9555a1e8cb546e92c6b19132/lib/incoming-handlers.js#L11-L24 | train |
chenboxiang/fdfs-client | lib/protocol.js | function(raw) {
var result = {}
var md = raw.split(protocol.FDFS_RECORD_SEPERATOR)
md.forEach(function(item) {
var arr = item.split(protocol.FDFS_FIELD_SEPERATOR)
var key = helpers.trim(arr[0])
var value = helpers.trim(arr[1])
result[key] = value
... | javascript | function(raw) {
var result = {}
var md = raw.split(protocol.FDFS_RECORD_SEPERATOR)
md.forEach(function(item) {
var arr = item.split(protocol.FDFS_FIELD_SEPERATOR)
var key = helpers.trim(arr[0])
var value = helpers.trim(arr[1])
result[key] = value
... | [
"function",
"(",
"raw",
")",
"{",
"var",
"result",
"=",
"{",
"}",
"var",
"md",
"=",
"raw",
".",
"split",
"(",
"protocol",
".",
"FDFS_RECORD_SEPERATOR",
")",
"md",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"arr",
"=",
"item",
".... | raw meta data to structure
@param raw | [
"raw",
"meta",
"data",
"to",
"structure"
] | bca7eb8db6c0b732c6a2dc43decac3c4c71d8a5a | https://github.com/chenboxiang/fdfs-client/blob/bca7eb8db6c0b732c6a2dc43decac3c4c71d8a5a/lib/protocol.js#L301-L312 | train | |
alexyoung/ico | src/helpers.js | getStyle | function getStyle(el, styleProp) {
if (typeof window === 'undefined') {
return;
}
var style;
if (el.currentStyle) {
style = el.currentStyle[styleProp];
} else if (window.getComputedStyle) {
style = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
}
if (style && sty... | javascript | function getStyle(el, styleProp) {
if (typeof window === 'undefined') {
return;
}
var style;
if (el.currentStyle) {
style = el.currentStyle[styleProp];
} else if (window.getComputedStyle) {
style = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
}
if (style && sty... | [
"function",
"getStyle",
"(",
"el",
",",
"styleProp",
")",
"{",
"if",
"(",
"typeof",
"window",
"===",
"'undefined'",
")",
"{",
"return",
";",
"}",
"var",
"style",
";",
"if",
"(",
"el",
".",
"currentStyle",
")",
"{",
"style",
"=",
"el",
".",
"currentSt... | Gets a CSS style property.
@param {Object} el A DOM element
@param {String} styleProp The name of a style property
@returns {Object} The style value | [
"Gets",
"a",
"CSS",
"style",
"property",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/src/helpers.js#L19-L34 | train |
solid/solid-web-client | src/util/graph-util.js | parseGraph | function parseGraph (rdf, baseUrl, rdfSource, contentType) {
let parsedGraph = rdf.graph()
rdf.parse(rdfSource, parsedGraph, baseUrl, contentType)
return parsedGraph
} | javascript | function parseGraph (rdf, baseUrl, rdfSource, contentType) {
let parsedGraph = rdf.graph()
rdf.parse(rdfSource, parsedGraph, baseUrl, contentType)
return parsedGraph
} | [
"function",
"parseGraph",
"(",
"rdf",
",",
"baseUrl",
",",
"rdfSource",
",",
"contentType",
")",
"{",
"let",
"parsedGraph",
"=",
"rdf",
".",
"graph",
"(",
")",
"rdf",
".",
"parse",
"(",
"rdfSource",
",",
"parsedGraph",
",",
"baseUrl",
",",
"contentType",
... | Parses a given graph, from text rdfSource, as a given content type.
Returns parsed graph.
@method parseGraph
@param rdf {RDF} RDF library such as rdflib.js
@param baseUrl {string}
@param rdfSource {string} Text source code
@param contentType {string} Mime Type (determines which parser to use)
@return {Graph} | [
"Parses",
"a",
"given",
"graph",
"from",
"text",
"rdfSource",
"as",
"a",
"given",
"content",
"type",
".",
"Returns",
"parsed",
"graph",
"."
] | 1b3a9b333a68c3a288125acd29cff07d397c15b4 | https://github.com/solid/solid-web-client/blob/1b3a9b333a68c3a288125acd29cff07d397c15b4/src/util/graph-util.js#L60-L66 | train |
alexyoung/ico | ico.js | function(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
} | javascript | function(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
} | [
"function",
"(",
"num",
",",
"dec",
")",
"{",
"var",
"result",
"=",
"Math",
".",
"round",
"(",
"num",
"*",
"Math",
".",
"pow",
"(",
"10",
",",
"dec",
")",
")",
"/",
"Math",
".",
"pow",
"(",
"10",
",",
"dec",
")",
";",
"return",
"result",
";",... | Rounds a float to the specified number of decimal places.
@param {Float} num A number to round
@param {Integer} dec The number of decimal places
@returns {Float} The rounded result | [
"Rounds",
"a",
"float",
"to",
"the",
"specified",
"number",
"of",
"decimal",
"places",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/ico.js#L21-L24 | train | |
alexyoung/ico | ico.js | function(data) {
var values = [],
i = 0;
for (i = 0; i < data.length; i++) {
values.push(this.normalise(data[i]));
}
return values;
} | javascript | function(data) {
var values = [],
i = 0;
for (i = 0; i < data.length; i++) {
values.push(this.normalise(data[i]));
}
return values;
} | [
"function",
"(",
"data",
")",
"{",
"var",
"values",
"=",
"[",
"]",
",",
"i",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"values",
".",
"push",
"(",
"this",
".",
"normalise",
"("... | Runs this.normalise on each value.
@param {Array} data Values to normalise
@returns {Array} Normalised values | [
"Runs",
"this",
".",
"normalise",
"on",
"each",
"value",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/ico.js#L234-L241 | train | |
alexyoung/ico | ico.js | function(data) {
var flat_data = [];
if (typeof data.length === 'undefined') {
if (typeof data === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key))
flat_data = flat_data.concat(this.flatten(data[key]));
}
} else {
return [];
}
... | javascript | function(data) {
var flat_data = [];
if (typeof data.length === 'undefined') {
if (typeof data === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key))
flat_data = flat_data.concat(this.flatten(data[key]));
}
} else {
return [];
}
... | [
"function",
"(",
"data",
")",
"{",
"var",
"flat_data",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"data",
".",
"length",
"===",
"'undefined'",
")",
"{",
"if",
"(",
"typeof",
"data",
"===",
"'object'",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"data",... | Flattens objects into an array.
@param {Object} data Values to flatten
@returns {Array} Flattened values | [
"Flattens",
"objects",
"into",
"an",
"array",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/ico.js#L249-L271 | train | |
alexyoung/ico | ico.js | function(start, end, options) {
var values = [], i;
for (i = start; i < end; i++) {
if (options && options.skip) {
if (i % options.skip === 0) {
values.push(i);
} else {
values.push(undefined);
}
} else {
values.push(i);
}
}
return va... | javascript | function(start, end, options) {
var values = [], i;
for (i = start; i < end; i++) {
if (options && options.skip) {
if (i % options.skip === 0) {
values.push(i);
} else {
values.push(undefined);
}
} else {
values.push(i);
}
}
return va... | [
"function",
"(",
"start",
",",
"end",
",",
"options",
")",
"{",
"var",
"values",
"=",
"[",
"]",
",",
"i",
";",
"for",
"(",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"skip",
... | Handy method to produce an array of numbers.
@param {Integer} start A number to start at
@param {Integer} end A number to end at
@returns {Array} An array of values | [
"Handy",
"method",
"to",
"produce",
"an",
"array",
"of",
"numbers",
"."
] | b2f296660e0ae7814024f2d839b2dea2270c378f | https://github.com/alexyoung/ico/blob/b2f296660e0ae7814024f2d839b2dea2270c378f/ico.js#L280-L294 | train | |
thlorenz/hha | lib/summary.js | summary | function summary(hand) {
const res = {}
if (hand.players == null || hand.players.length === 0) return res
const bb = hand.info.bb
res.header = getHeader(hand)
const seatsInfo = getSeats(hand)
res.seats = seatsInfo.seats
res.chipStackRatio = seatsInfo.hero != null
? getChipStackRatio(res.header.gamet... | javascript | function summary(hand) {
const res = {}
if (hand.players == null || hand.players.length === 0) return res
const bb = hand.info.bb
res.header = getHeader(hand)
const seatsInfo = getSeats(hand)
res.seats = seatsInfo.seats
res.chipStackRatio = seatsInfo.hero != null
? getChipStackRatio(res.header.gamet... | [
"function",
"summary",
"(",
"hand",
")",
"{",
"const",
"res",
"=",
"{",
"}",
"if",
"(",
"hand",
".",
"players",
"==",
"null",
"||",
"hand",
".",
"players",
".",
"length",
"===",
"0",
")",
"return",
"res",
"const",
"bb",
"=",
"hand",
".",
"info",
... | Converts a hand that was analyzed and then scripted to a summary representation.
The summary has the following properties:
- header: contains game info, like room, pokertype, blinds, etc.
- seats: lists the seats of the players including pos, chips and hero indicators
- chipsStackRatio: hero's M for tournaments, his ... | [
"Converts",
"a",
"hand",
"that",
"was",
"analyzed",
"and",
"then",
"scripted",
"to",
"a",
"summary",
"representation",
"."
] | 28ae03e9d422881ad8a3b3dba9de32e01d8ac04c | https://github.com/thlorenz/hha/blob/28ae03e9d422881ad8a3b3dba9de32e01d8ac04c/lib/summary.js#L236-L270 | train |
urbancups/node-sheets | src/sheets.js | sheetToTable | function sheetToTable(sheet) {
if (sheet.data.length === 0 || sheet.data[0].rowData === undefined) {
return {
title: sheet.properties.title,
headers: [],
formats: [],
rows: []
};
}
const gridData = sheet.data[0]; // first (unique) range
const headers = gridData.rowData[0].values ... | javascript | function sheetToTable(sheet) {
if (sheet.data.length === 0 || sheet.data[0].rowData === undefined) {
return {
title: sheet.properties.title,
headers: [],
formats: [],
rows: []
};
}
const gridData = sheet.data[0]; // first (unique) range
const headers = gridData.rowData[0].values ... | [
"function",
"sheetToTable",
"(",
"sheet",
")",
"{",
"if",
"(",
"sheet",
".",
"data",
".",
"length",
"===",
"0",
"||",
"sheet",
".",
"data",
"[",
"0",
"]",
".",
"rowData",
"===",
"undefined",
")",
"{",
"return",
"{",
"title",
":",
"sheet",
".",
"pro... | Converter from google sheet format to node-sheets format | [
"Converter",
"from",
"google",
"sheet",
"format",
"to",
"node",
"-",
"sheets",
"format"
] | 28078439fd71afc3cfd40ef060bd44c0e9366853 | https://github.com/urbancups/node-sheets/blob/28078439fd71afc3cfd40ef060bd44c0e9366853/src/sheets.js#L183-L217 | train |
urbancups/node-sheets | src/sheets.js | getRanges | async function getRanges(
auth,
spreadsheetId,
ranges,
fields = 'properties.title,sheets.properties,sheets.data(rowData.values.effectiveValue,rowData.values.formattedValue,rowData.values.effectiveFormat.numberFormat)'
) {
var sheets = google.sheets('v4');
const response = await Q.ninvoke(sheets.spreadsheets... | javascript | async function getRanges(
auth,
spreadsheetId,
ranges,
fields = 'properties.title,sheets.properties,sheets.data(rowData.values.effectiveValue,rowData.values.formattedValue,rowData.values.effectiveFormat.numberFormat)'
) {
var sheets = google.sheets('v4');
const response = await Q.ninvoke(sheets.spreadsheets... | [
"async",
"function",
"getRanges",
"(",
"auth",
",",
"spreadsheetId",
",",
"ranges",
",",
"fields",
"=",
"'properties.title,sheets.properties,sheets.data(rowData.values.effectiveValue,rowData.values.formattedValue,rowData.values.effectiveFormat.numberFormat)'",
")",
"{",
"var",
"sheet... | Utility function to get a range from a spreadsheet | [
"Utility",
"function",
"to",
"get",
"a",
"range",
"from",
"a",
"spreadsheet"
] | 28078439fd71afc3cfd40ef060bd44c0e9366853 | https://github.com/urbancups/node-sheets/blob/28078439fd71afc3cfd40ef060bd44c0e9366853/src/sheets.js#L295-L312 | train |
behrad/mqtt-nedb-store | mqtt-nedb-store.js | function (options) {
if (!(this instanceof Store)) {
return new Store(options)
}
this._opts = options || {}
this.db = new Datastore({ filename: this._opts.filename, autoload: true })
} | javascript | function (options) {
if (!(this instanceof Store)) {
return new Store(options)
}
this._opts = options || {}
this.db = new Datastore({ filename: this._opts.filename, autoload: true })
} | [
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Store",
")",
")",
"{",
"return",
"new",
"Store",
"(",
"options",
")",
"}",
"this",
".",
"_opts",
"=",
"options",
"||",
"{",
"}",
"this",
".",
"db",
"=",
"new",
"Dat... | NeDB implementation of the message store | [
"NeDB",
"implementation",
"of",
"the",
"message",
"store"
] | 91c64e9c0ac39b3ebc96aa861327f66e208b0326 | https://github.com/behrad/mqtt-nedb-store/blob/91c64e9c0ac39b3ebc96aa861327f66e208b0326/mqtt-nedb-store.js#L14-L21 | train | |
audiojs/audio-gain | direct.js | gain | function gain(options) {
// gain()
if (options == null) options = {volume: 1};
// gain(Function)
// gain(Number)
else if (typeof options === 'function' || typeof options === 'number') options = {volume: options};
var volume;
if (options.mode === 'tan') {
volume = Math.tan(options.volume);
} else {
volume... | javascript | function gain(options) {
// gain()
if (options == null) options = {volume: 1};
// gain(Function)
// gain(Number)
else if (typeof options === 'function' || typeof options === 'number') options = {volume: options};
var volume;
if (options.mode === 'tan') {
volume = Math.tan(options.volume);
} else {
volume... | [
"function",
"gain",
"(",
"options",
")",
"{",
"// gain()",
"if",
"(",
"options",
"==",
"null",
")",
"options",
"=",
"{",
"volume",
":",
"1",
"}",
";",
"// gain(Function)",
"// gain(Number)",
"else",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
"||"... | Create pcm volume controller.
@function | [
"Create",
"pcm",
"volume",
"controller",
"."
] | 0ac4ef52335c275a519940aaf20d0d6a45c42f9d | https://github.com/audiojs/audio-gain/blob/0ac4ef52335c275a519940aaf20d0d6a45c42f9d/direct.js#L17-L36 | train |
chenboxiang/fdfs-client | lib/helpers.js | function(fileId) {
var pos = fileId.indexOf('/')
return {
group: fileId.substring(0, pos),
filename: fileId.substring(pos + 1)
}
} | javascript | function(fileId) {
var pos = fileId.indexOf('/')
return {
group: fileId.substring(0, pos),
filename: fileId.substring(pos + 1)
}
} | [
"function",
"(",
"fileId",
")",
"{",
"var",
"pos",
"=",
"fileId",
".",
"indexOf",
"(",
"'/'",
")",
"return",
"{",
"group",
":",
"fileId",
".",
"substring",
"(",
"0",
",",
"pos",
")",
",",
"filename",
":",
"fileId",
".",
"substring",
"(",
"pos",
"+"... | file id conver to group and filename
@param fileId
@returns {{group: string, filename: string}} | [
"file",
"id",
"conver",
"to",
"group",
"and",
"filename"
] | bca7eb8db6c0b732c6a2dc43decac3c4c71d8a5a | https://github.com/chenboxiang/fdfs-client/blob/bca7eb8db6c0b732c6a2dc43decac3c4c71d8a5a/lib/helpers.js#L84-L90 | train | |
Sixthdim/angular-vertilize | angular-vertilize.js | function(){
var clone = element.clone()
.removeAttr('vertilize')
.css({
height: '',
width: element.outerWidth(),
position: 'fixed',
top: 0,
left: 0,
visibility: 'hidden'
... | javascript | function(){
var clone = element.clone()
.removeAttr('vertilize')
.css({
height: '',
width: element.outerWidth(),
position: 'fixed',
top: 0,
left: 0,
visibility: 'hidden'
... | [
"function",
"(",
")",
"{",
"var",
"clone",
"=",
"element",
".",
"clone",
"(",
")",
".",
"removeAttr",
"(",
"'vertilize'",
")",
".",
"css",
"(",
"{",
"height",
":",
"''",
",",
"width",
":",
"element",
".",
"outerWidth",
"(",
")",
",",
"position",
":... | Get my real height by cloning so my height is not affected. | [
"Get",
"my",
"real",
"height",
"by",
"cloning",
"so",
"my",
"height",
"is",
"not",
"affected",
"."
] | 860c0dd22f90eebfcc392d176e8d9cb5c3ef6ee1 | https://github.com/Sixthdim/angular-vertilize/blob/860c0dd22f90eebfcc392d176e8d9cb5c3ef6ee1/angular-vertilize.js#L67-L82 | train | |
kchapelier/cellular-automata | lib/cellular-automata.js | neighbourhoodSorter | function neighbourhoodSorter (a, b) {
a = a.join(',');
b = b.join(',');
return a > b ? 1 : a < b ? -1 : 0;
} | javascript | function neighbourhoodSorter (a, b) {
a = a.join(',');
b = b.join(',');
return a > b ? 1 : a < b ? -1 : 0;
} | [
"function",
"neighbourhoodSorter",
"(",
"a",
",",
"b",
")",
"{",
"a",
"=",
"a",
".",
"join",
"(",
"','",
")",
";",
"b",
"=",
"b",
".",
"join",
"(",
"','",
")",
";",
"return",
"a",
">",
"b",
"?",
"1",
":",
"a",
"<",
"b",
"?",
"-",
"1",
":"... | Sort the neighbourhood from left to right, top to bottom, ...
@param {Array} a First neighbour
@param {Array} b Second neighbour
@returns {number} | [
"Sort",
"the",
"neighbourhood",
"from",
"left",
"to",
"right",
"top",
"to",
"bottom",
"..."
] | 1f21a7a15fad262c92e84eee834d2308bdba48c2 | https://github.com/kchapelier/cellular-automata/blob/1f21a7a15fad262c92e84eee834d2308bdba48c2/lib/cellular-automata.js#L95-L99 | train |
StyleT/js-acl | src/index.js | getRules | function getRules (resource, role, create) {
resource = typeof resource === 'undefined' ? null : resource;
role = typeof role === 'undefined' ? null : role;
create = typeof create === 'undefined' ? false : create;
var visitor;
// follow $resource
do {
if (re... | javascript | function getRules (resource, role, create) {
resource = typeof resource === 'undefined' ? null : resource;
role = typeof role === 'undefined' ? null : role;
create = typeof create === 'undefined' ? false : create;
var visitor;
// follow $resource
do {
if (re... | [
"function",
"getRules",
"(",
"resource",
",",
"role",
",",
"create",
")",
"{",
"resource",
"=",
"typeof",
"resource",
"===",
"'undefined'",
"?",
"null",
":",
"resource",
";",
"role",
"=",
"typeof",
"role",
"===",
"'undefined'",
"?",
"null",
":",
"role",
... | Returns the rules associated with a Resource and a Role, or null if no such rules exist
If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
respectively. Both can be null to return the default rule set for all Resources and all Roles.
If the $create parameter i... | [
"Returns",
"the",
"rules",
"associated",
"with",
"a",
"Resource",
"and",
"a",
"Role",
"or",
"null",
"if",
"no",
"such",
"rules",
"exist"
] | 63eeb77866e99831611c900fcb4db3f73f72148b | https://github.com/StyleT/js-acl/blob/63eeb77866e99831611c900fcb4db3f73f72148b/src/index.js#L783-L826 | train |
StyleT/js-acl | src/index.js | getRuleType | function getRuleType(resource, role, privilege) {
resource = typeof resource === 'undefined' ? null : resource;
role = typeof role === 'undefined' ? null : role;
privilege = typeof privilege === 'undefined' ? null : privilege;
// get the rules for the $resource and $role
var ru... | javascript | function getRuleType(resource, role, privilege) {
resource = typeof resource === 'undefined' ? null : resource;
role = typeof role === 'undefined' ? null : role;
privilege = typeof privilege === 'undefined' ? null : privilege;
// get the rules for the $resource and $role
var ru... | [
"function",
"getRuleType",
"(",
"resource",
",",
"role",
",",
"privilege",
")",
"{",
"resource",
"=",
"typeof",
"resource",
"===",
"'undefined'",
"?",
"null",
":",
"resource",
";",
"role",
"=",
"typeof",
"role",
"===",
"'undefined'",
"?",
"null",
":",
"rol... | Returns the rule type associated with the specified Resource, Role, and privilege
combination.
If a rule does not exist or its attached assertion fails, which means that
the rule is not applicable, then this method returns null. Otherwise, the
rule type applies and is returned as either TYPE_ALLOW or TYPE_DENY.
If $r... | [
"Returns",
"the",
"rule",
"type",
"associated",
"with",
"the",
"specified",
"Resource",
"Role",
"and",
"privilege",
"combination",
"."
] | 63eeb77866e99831611c900fcb4db3f73f72148b | https://github.com/StyleT/js-acl/blob/63eeb77866e99831611c900fcb4db3f73f72148b/src/index.js#L1007-L1053 | train |
StyleT/js-acl | src/index.js | getChildResources | function getChildResources(resource){
var result = [], children = _resources[resource].children;
children.forEach(function (child) {
var childReturn = getChildResources(child);
childReturn.push(child);
result = result.concat(childReturn);
});
return r... | javascript | function getChildResources(resource){
var result = [], children = _resources[resource].children;
children.forEach(function (child) {
var childReturn = getChildResources(child);
childReturn.push(child);
result = result.concat(childReturn);
});
return r... | [
"function",
"getChildResources",
"(",
"resource",
")",
"{",
"var",
"result",
"=",
"[",
"]",
",",
"children",
"=",
"_resources",
"[",
"resource",
"]",
".",
"children",
";",
"children",
".",
"forEach",
"(",
"function",
"(",
"child",
")",
"{",
"var",
"child... | Returns all child resources from the given resource.
@param {string} resource
@return [] | [
"Returns",
"all",
"child",
"resources",
"from",
"the",
"given",
"resource",
"."
] | 63eeb77866e99831611c900fcb4db3f73f72148b | https://github.com/StyleT/js-acl/blob/63eeb77866e99831611c900fcb4db3f73f72148b/src/index.js#L1061-L1070 | train |
Havelaer/node-orientdb-http | lib/Base.js | function(evname, callback, context) {
this._events = this._events || {};
var a = this._events[evname] = this._events[evname] || [];
a.push({
cb: callback,
ctxt: context || this
});
return this;
} | javascript | function(evname, callback, context) {
this._events = this._events || {};
var a = this._events[evname] = this._events[evname] || [];
a.push({
cb: callback,
ctxt: context || this
});
return this;
} | [
"function",
"(",
"evname",
",",
"callback",
",",
"context",
")",
"{",
"this",
".",
"_events",
"=",
"this",
".",
"_events",
"||",
"{",
"}",
";",
"var",
"a",
"=",
"this",
".",
"_events",
"[",
"evname",
"]",
"=",
"this",
".",
"_events",
"[",
"evname",... | Bind event listener
@param {string} name of event
@param {function} callback if event is triggered
@param {object} context in which callback is called
@return {this} | [
"Bind",
"event",
"listener"
] | b76a50b070643d34485941eef9a610e100737b7b | https://github.com/Havelaer/node-orientdb-http/blob/b76a50b070643d34485941eef9a610e100737b7b/lib/Base.js#L187-L195 | train | |
Havelaer/node-orientdb-http | lib/Base.js | function(evname, callback, context) {
var self = this, args = arguments;
this.on(evname, function() {
callback.apply(context, arguments);
self.off.apply(self, args);
});
return this;
} | javascript | function(evname, callback, context) {
var self = this, args = arguments;
this.on(evname, function() {
callback.apply(context, arguments);
self.off.apply(self, args);
});
return this;
} | [
"function",
"(",
"evname",
",",
"callback",
",",
"context",
")",
"{",
"var",
"self",
"=",
"this",
",",
"args",
"=",
"arguments",
";",
"this",
".",
"on",
"(",
"evname",
",",
"function",
"(",
")",
"{",
"callback",
".",
"apply",
"(",
"context",
",",
"... | Bind event listener and only fire once
@param {string} name of event
@param {function} callback if event is triggered
@param {object} context in which callback is called
@return {this} | [
"Bind",
"event",
"listener",
"and",
"only",
"fire",
"once"
] | b76a50b070643d34485941eef9a610e100737b7b | https://github.com/Havelaer/node-orientdb-http/blob/b76a50b070643d34485941eef9a610e100737b7b/lib/Base.js#L205-L212 | train | |
Havelaer/node-orientdb-http | lib/Base.js | function(evname) {
var fns = this._events && this._events[evname] || [],
args = __slice.call(arguments, 1);
for (var i = 0, ii = fns.length; i < ii; i++) {
fns[i].cb.apply(fns[i].ctxt, args);
}
} | javascript | function(evname) {
var fns = this._events && this._events[evname] || [],
args = __slice.call(arguments, 1);
for (var i = 0, ii = fns.length; i < ii; i++) {
fns[i].cb.apply(fns[i].ctxt, args);
}
} | [
"function",
"(",
"evname",
")",
"{",
"var",
"fns",
"=",
"this",
".",
"_events",
"&&",
"this",
".",
"_events",
"[",
"evname",
"]",
"||",
"[",
"]",
",",
"args",
"=",
"__slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"for",
"(",
"var",
... | Trigger event on object
@param {string} name of event
@param {array} array of arguments
@return {this} | [
"Trigger",
"event",
"on",
"object"
] | b76a50b070643d34485941eef9a610e100737b7b | https://github.com/Havelaer/node-orientdb-http/blob/b76a50b070643d34485941eef9a610e100737b7b/lib/Base.js#L248-L254 | train | |
Havelaer/node-orientdb-http | lib/Base.js | function(other, evname, callback) {
other.on(evname, callback, this);
var a = this._listeningTo = this._listeningTo || {},
b = a[other._cid] = other;
} | javascript | function(other, evname, callback) {
other.on(evname, callback, this);
var a = this._listeningTo = this._listeningTo || {},
b = a[other._cid] = other;
} | [
"function",
"(",
"other",
",",
"evname",
",",
"callback",
")",
"{",
"other",
".",
"on",
"(",
"evname",
",",
"callback",
",",
"this",
")",
";",
"var",
"a",
"=",
"this",
".",
"_listeningTo",
"=",
"this",
".",
"_listeningTo",
"||",
"{",
"}",
",",
"b",... | Bind event listener on an other object
@param {object} object to listen to
@param {string} name of event
@param {function} callback
@return {this} | [
"Bind",
"event",
"listener",
"on",
"an",
"other",
"object"
] | b76a50b070643d34485941eef9a610e100737b7b | https://github.com/Havelaer/node-orientdb-http/blob/b76a50b070643d34485941eef9a610e100737b7b/lib/Base.js#L264-L268 | train | |
Havelaer/node-orientdb-http | lib/Base.js | function(other, evname, callback) {
if (!this._listeningTo) return;
if (!other) {
for (var cid in this._listeningTo) {
this.stopListening(this._listeningTo[cid], evname, callback);
}
} else {
other.off(evname, callback, this);
// TODO: remove local listener tracker
}
} | javascript | function(other, evname, callback) {
if (!this._listeningTo) return;
if (!other) {
for (var cid in this._listeningTo) {
this.stopListening(this._listeningTo[cid], evname, callback);
}
} else {
other.off(evname, callback, this);
// TODO: remove local listener tracker
}
} | [
"function",
"(",
"other",
",",
"evname",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_listeningTo",
")",
"return",
";",
"if",
"(",
"!",
"other",
")",
"{",
"for",
"(",
"var",
"cid",
"in",
"this",
".",
"_listeningTo",
")",
"{",
"this",
... | Remove event listener from an other object
@param {object} object to listening to
@param {string} name of event
@param {function} callback
@return {this} | [
"Remove",
"event",
"listener",
"from",
"an",
"other",
"object"
] | b76a50b070643d34485941eef9a610e100737b7b | https://github.com/Havelaer/node-orientdb-http/blob/b76a50b070643d34485941eef9a610e100737b7b/lib/Base.js#L278-L288 | train | |
zedgu/surface | lib/surface.js | Surface | function Surface(app, options) {
if (!(this instanceof Surface)) {
return new Surface(app, options);
}
this.conf = setting(options);
this.middleware(app);
context(app, this);
} | javascript | function Surface(app, options) {
if (!(this instanceof Surface)) {
return new Surface(app, options);
}
this.conf = setting(options);
this.middleware(app);
context(app, this);
} | [
"function",
"Surface",
"(",
"app",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Surface",
")",
")",
"{",
"return",
"new",
"Surface",
"(",
"app",
",",
"options",
")",
";",
"}",
"this",
".",
"conf",
"=",
"setting",
"(",
"opti... | Surface Constructor.
@param {Object} app koa().
@param {Object} options Config object.
@api public | [
"Surface",
"Constructor",
"."
] | 3f32b0ef98c781c923b26cef543fdea457da1030 | https://github.com/zedgu/surface/blob/3f32b0ef98c781c923b26cef543fdea457da1030/lib/surface.js#L77-L86 | train |
tjvantoll/nativescript-maps | demo/app/tns_modules/js-libs/reworkcss/reworkcss.js | athost | function athost() {
var pos = position();
var m = match(/^@host */);
if (!m) return;
if (!open()) return error("@host missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@host missing '}'");
return pos({
type: 'host',
rules: style
});
} | javascript | function athost() {
var pos = position();
var m = match(/^@host */);
if (!m) return;
if (!open()) return error("@host missing '{'");
var style = comments().concat(rules());
if (!close()) return error("@host missing '}'");
return pos({
type: 'host',
rules: style
});
} | [
"function",
"athost",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@host *",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"if",
"(",
"!",
"open",
"(",
")",
")",
"return",
"error... | Parse host. | [
"Parse",
"host",
"."
] | 7ba076e576968fbce1364e294fbc5470808ba8d9 | https://github.com/tjvantoll/nativescript-maps/blob/7ba076e576968fbce1364e294fbc5470808ba8d9/demo/app/tns_modules/js-libs/reworkcss/reworkcss.js#L351-L367 | train |
tjvantoll/nativescript-maps | demo/app/tns_modules/js-libs/reworkcss/reworkcss.js | atcustommedia | function atcustommedia() {
var pos = position();
var m = match(/^@custom-media (--[^\s]+) *([^{;]+);/);
if (!m) return;
return pos({
type: 'custom-media',
name: trim(m[1]),
media: trim(m[2])
});
} | javascript | function atcustommedia() {
var pos = position();
var m = match(/^@custom-media (--[^\s]+) *([^{;]+);/);
if (!m) return;
return pos({
type: 'custom-media',
name: trim(m[1]),
media: trim(m[2])
});
} | [
"function",
"atcustommedia",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@custom-media (--[^\\s]+) *([^{;]+);",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"return",
"pos",
"(",
"{",
... | Parse custom-media. | [
"Parse",
"custom",
"-",
"media",
"."
] | 7ba076e576968fbce1364e294fbc5470808ba8d9 | https://github.com/tjvantoll/nativescript-maps/blob/7ba076e576968fbce1364e294fbc5470808ba8d9/demo/app/tns_modules/js-libs/reworkcss/reworkcss.js#L398-L408 | train |
tjvantoll/nativescript-maps | demo/app/tns_modules/js-libs/reworkcss/reworkcss.js | atfontface | function atfontface() {
var pos = position();
var m = match(/^@font-face */);
if (!m) return;
if (!open()) return error("@font-face missing '{'");
var decls = comments();
// declarations
var decl;
while (decl = declaration()) {
decls.push(decl);
decls = decls.concat(comment... | javascript | function atfontface() {
var pos = position();
var m = match(/^@font-face */);
if (!m) return;
if (!open()) return error("@font-face missing '{'");
var decls = comments();
// declarations
var decl;
while (decl = declaration()) {
decls.push(decl);
decls = decls.concat(comment... | [
"function",
"atfontface",
"(",
")",
"{",
"var",
"pos",
"=",
"position",
"(",
")",
";",
"var",
"m",
"=",
"match",
"(",
"/",
"^@font-face *",
"/",
")",
";",
"if",
"(",
"!",
"m",
")",
"return",
";",
"if",
"(",
"!",
"open",
"(",
")",
")",
"return",... | Parse font-face. | [
"Parse",
"font",
"-",
"face",
"."
] | 7ba076e576968fbce1364e294fbc5470808ba8d9 | https://github.com/tjvantoll/nativescript-maps/blob/7ba076e576968fbce1364e294fbc5470808ba8d9/demo/app/tns_modules/js-libs/reworkcss/reworkcss.js#L470-L491 | train |
mysticatea/appcache-manifest | lib/generate.js | generateContent | function generateContent(globOrGlobArray, options) {
// Detect base.
const globs = toArray(globOrGlobArray)
assert(globs.length > 0, "globs should exist")
const base = commonPart(globs)
assert(base != null, "the common parent directory of globs is not found.")
// Create streams.
const glob... | javascript | function generateContent(globOrGlobArray, options) {
// Detect base.
const globs = toArray(globOrGlobArray)
assert(globs.length > 0, "globs should exist")
const base = commonPart(globs)
assert(base != null, "the common parent directory of globs is not found.")
// Create streams.
const glob... | [
"function",
"generateContent",
"(",
"globOrGlobArray",
",",
"options",
")",
"{",
"// Detect base.",
"const",
"globs",
"=",
"toArray",
"(",
"globOrGlobArray",
")",
"assert",
"(",
"globs",
".",
"length",
">",
"0",
",",
"\"globs should exist\"",
")",
"const",
"base... | Create the stream to generate the cache section of appcache manifest.
@param {string|string[]} globOrGlobArray - The glob patterns to spcify the files of the cache section.
@param {object} options - The option object.
@returns {AppcacheTransform} The created stream.
@private | [
"Create",
"the",
"stream",
"to",
"generate",
"the",
"cache",
"section",
"of",
"appcache",
"manifest",
"."
] | c44f4d54096287212149a7cf5031bd3e4f5a1fbe | https://github.com/mysticatea/appcache-manifest/blob/c44f4d54096287212149a7cf5031bd3e4f5a1fbe/lib/generate.js#L158-L173 | train |
mysticatea/appcache-manifest | bin/appcache-manifest.js | generate | function generate(globs, options, callback) {
if (generationQueue.size > 0) {
// There is a process not started.
return
}
if (typeof options.delay === "number") {
generationQueue.push(next => setTimeout(next, options.delay))
}
generationQueue.push(next => {
//eslint-d... | javascript | function generate(globs, options, callback) {
if (generationQueue.size > 0) {
// There is a process not started.
return
}
if (typeof options.delay === "number") {
generationQueue.push(next => setTimeout(next, options.delay))
}
generationQueue.push(next => {
//eslint-d... | [
"function",
"generate",
"(",
"globs",
",",
"options",
",",
"callback",
")",
"{",
"if",
"(",
"generationQueue",
".",
"size",
">",
"0",
")",
"{",
"// There is a process not started.",
"return",
"}",
"if",
"(",
"typeof",
"options",
".",
"delay",
"===",
"\"numbe... | Generate appcache manifest.
@param {string[]} globs - The globs which specifies the target files.
@param {object} options - The option object.
@param {function} callback - The callback function.
@returns {void}
@private | [
"Generate",
"appcache",
"manifest",
"."
] | c44f4d54096287212149a7cf5031bd3e4f5a1fbe | https://github.com/mysticatea/appcache-manifest/blob/c44f4d54096287212149a7cf5031bd3e4f5a1fbe/bin/appcache-manifest.js#L143-L198 | train |
mysticatea/appcache-manifest | bin/appcache-manifest.js | watch | function watch(globs, options) {
options.delay = 1000
chokidar
.watch(globs, { persistent: true, ignoreInitial: true })
.on("add", () => generate(globs, options))
.on("unlink", () => generate(globs, options))
.on("change", () => generate(globs, options))
.on("error", (er... | javascript | function watch(globs, options) {
options.delay = 1000
chokidar
.watch(globs, { persistent: true, ignoreInitial: true })
.on("add", () => generate(globs, options))
.on("unlink", () => generate(globs, options))
.on("change", () => generate(globs, options))
.on("error", (er... | [
"function",
"watch",
"(",
"globs",
",",
"options",
")",
"{",
"options",
".",
"delay",
"=",
"1000",
"chokidar",
".",
"watch",
"(",
"globs",
",",
"{",
"persistent",
":",
"true",
",",
"ignoreInitial",
":",
"true",
"}",
")",
".",
"on",
"(",
"\"add\"",
",... | Generate appcache manifest for each change.
@param {string[]} globs - The globs which specifies the target files.
@param {object} options - The option object.
@returns {void}
@private | [
"Generate",
"appcache",
"manifest",
"for",
"each",
"change",
"."
] | c44f4d54096287212149a7cf5031bd3e4f5a1fbe | https://github.com/mysticatea/appcache-manifest/blob/c44f4d54096287212149a7cf5031bd3e4f5a1fbe/bin/appcache-manifest.js#L208-L227 | train |
ekryski/node-hl7 | lib/server.js | Server | function Server(host, port, options) {
var self = this;
// Needed to convert this constructor into EventEmitter
EventEmitter.call(this);
options = options || {};
this.host = host || '127.0.0.1';
this.port = port || 59895;
this.debug = options.debug || false;
this.json = options.json || true;
var pa... | javascript | function Server(host, port, options) {
var self = this;
// Needed to convert this constructor into EventEmitter
EventEmitter.call(this);
options = options || {};
this.host = host || '127.0.0.1';
this.port = port || 59895;
this.debug = options.debug || false;
this.json = options.json || true;
var pa... | [
"function",
"Server",
"(",
"host",
",",
"port",
",",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Needed to convert this constructor into EventEmitter",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",... | Creates a HL7 Server
@param String host to listen for HL7 data
@param Integer port to listen to HL7 data - default is 59895
@param {Object} options
@api public | [
"Creates",
"a",
"HL7",
"Server"
] | 9ee63f524ac0335892ed281b572d7290e56f7167 | https://github.com/ekryski/node-hl7/blob/9ee63f524ac0335892ed281b572d7290e56f7167/lib/server.js#L30-L216 | train |
Vizzuality/node-varnish | lib/node-varnish/varnish_client.js | _send | function _send(cmd, callback) {
cmd_callback = callback;
if(connected) {
client.write(cmd + '\n');
} else {
connect();
}
} | javascript | function _send(cmd, callback) {
cmd_callback = callback;
if(connected) {
client.write(cmd + '\n');
} else {
connect();
}
} | [
"function",
"_send",
"(",
"cmd",
",",
"callback",
")",
"{",
"cmd_callback",
"=",
"callback",
";",
"if",
"(",
"connected",
")",
"{",
"client",
".",
"write",
"(",
"cmd",
"+",
"'\\n'",
")",
";",
"}",
"else",
"{",
"connect",
"(",
")",
";",
"}",
"}"
] | sends the command to the server | [
"sends",
"the",
"command",
"to",
"the",
"server"
] | c0ce86b8c7016dc3a3900ef3a6bdd795e83c3436 | https://github.com/Vizzuality/node-varnish/blob/c0ce86b8c7016dc3a3900ef3a6bdd795e83c3436/lib/node-varnish/varnish_client.js#L119-L126 | train |
mysticatea/appcache-manifest | lib/common-part.js | globParentToArray | function globParentToArray(glob) {
return path.resolve(globParent(glob))
.replace(BACK_SLASH, "/")
.split("/")
.filter(Boolean)
} | javascript | function globParentToArray(glob) {
return path.resolve(globParent(glob))
.replace(BACK_SLASH, "/")
.split("/")
.filter(Boolean)
} | [
"function",
"globParentToArray",
"(",
"glob",
")",
"{",
"return",
"path",
".",
"resolve",
"(",
"globParent",
"(",
"glob",
")",
")",
".",
"replace",
"(",
"BACK_SLASH",
",",
"\"/\"",
")",
".",
"split",
"(",
"\"/\"",
")",
".",
"filter",
"(",
"Boolean",
")... | Get the parent path of the given glob as an array of path elements.
@param {string} glob - The glob to get.
@returns {string[]} The path elements.
@private | [
"Get",
"the",
"parent",
"path",
"of",
"the",
"given",
"glob",
"as",
"an",
"array",
"of",
"path",
"elements",
"."
] | c44f4d54096287212149a7cf5031bd3e4f5a1fbe | https://github.com/mysticatea/appcache-manifest/blob/c44f4d54096287212149a7cf5031bd3e4f5a1fbe/lib/common-part.js#L31-L36 | train |
mysticatea/appcache-manifest | lib/common-part.js | findLastCommonIndex | function findLastCommonIndex(xs, ys) {
for (let i = Math.min(xs.length, ys.length) - 1; i >= 0; --i) {
if (xs[i] === ys[i]) {
return i
}
}
return -1
} | javascript | function findLastCommonIndex(xs, ys) {
for (let i = Math.min(xs.length, ys.length) - 1; i >= 0; --i) {
if (xs[i] === ys[i]) {
return i
}
}
return -1
} | [
"function",
"findLastCommonIndex",
"(",
"xs",
",",
"ys",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"Math",
".",
"min",
"(",
"xs",
".",
"length",
",",
"ys",
".",
"length",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"--",
"i",
")",
"{",
"if",
"(",
... | Get the index of the last element which is same between the given 2 elements.
@param {string[]} xs - An array to compare.
@param {string[]} ys - Another array to compare.
@returns {number} The index of the last element is same.
@private | [
"Get",
"the",
"index",
"of",
"the",
"last",
"element",
"which",
"is",
"same",
"between",
"the",
"given",
"2",
"elements",
"."
] | c44f4d54096287212149a7cf5031bd3e4f5a1fbe | https://github.com/mysticatea/appcache-manifest/blob/c44f4d54096287212149a7cf5031bd3e4f5a1fbe/lib/common-part.js#L46-L53 | train |
zhangchiqing/bluebird-promisell | index.js | function(val) {
return val === null ? 'Null' :
val === undefined ? 'Undefined' :
Object.prototype.toString.call(val).slice(8, -1);
} | javascript | function(val) {
return val === null ? 'Null' :
val === undefined ? 'Undefined' :
Object.prototype.toString.call(val).slice(8, -1);
} | [
"function",
"(",
"val",
")",
"{",
"return",
"val",
"===",
"null",
"?",
"'Null'",
":",
"val",
"===",
"undefined",
"?",
"'Undefined'",
":",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"val",
")",
".",
"slice",
"(",
"8",
",",
"-",
"... | a -> String | [
"a",
"-",
">",
"String"
] | ade459c0ceb9710cacc0a8c992907e3eb421a4c2 | https://github.com/zhangchiqing/bluebird-promisell/blob/ade459c0ceb9710cacc0a8c992907e3eb421a4c2/index.js#L153-L157 | train | |
zhangchiqing/bluebird-promisell | index.js | function(expectedType, value) {
var actualType = getType(value);
if (expectedType!== actualType) {
throw new TypeError('Expected type to be ' +
expectedType + ', but got ' + actualType);
}
return value;
} | javascript | function(expectedType, value) {
var actualType = getType(value);
if (expectedType!== actualType) {
throw new TypeError('Expected type to be ' +
expectedType + ', but got ' + actualType);
}
return value;
} | [
"function",
"(",
"expectedType",
",",
"value",
")",
"{",
"var",
"actualType",
"=",
"getType",
"(",
"value",
")",
";",
"if",
"(",
"expectedType",
"!==",
"actualType",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Expected type to be '",
"+",
"expectedType",
"... | String -> String -> a -> a | [
"String",
"-",
">",
"String",
"-",
">",
"a",
"-",
">",
"a"
] | ade459c0ceb9710cacc0a8c992907e3eb421a4c2 | https://github.com/zhangchiqing/bluebird-promisell/blob/ade459c0ceb9710cacc0a8c992907e3eb421a4c2/index.js#L160-L167 | train | |
sidorares/node-cli-debugger | lib/interface.js | leftPad | function leftPad(n, prefix) {
var s = n.toString(),
nchars = intChars(n),
nspaces = nchars - s.length - 1;
prefix || (prefix = ' ');
for (var i = 0; i < nspaces; i++) {
prefix += ' ';
}
return prefix + s;
} | javascript | function leftPad(n, prefix) {
var s = n.toString(),
nchars = intChars(n),
nspaces = nchars - s.length - 1;
prefix || (prefix = ' ');
for (var i = 0; i < nspaces; i++) {
prefix += ' ';
}
return prefix + s;
} | [
"function",
"leftPad",
"(",
"n",
",",
"prefix",
")",
"{",
"var",
"s",
"=",
"n",
".",
"toString",
"(",
")",
",",
"nchars",
"=",
"intChars",
"(",
"n",
")",
",",
"nspaces",
"=",
"nchars",
"-",
"s",
".",
"length",
"-",
"1",
";",
"prefix",
"||",
"("... | Adds spaces and prefix to number | [
"Adds",
"spaces",
"and",
"prefix",
"to",
"number"
] | 3887de612751e05564e6b50759371b4e7f04569f | https://github.com/sidorares/node-cli-debugger/blob/3887de612751e05564e6b50759371b4e7f04569f/lib/interface.js#L386-L398 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.