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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(autoset){
autoset = autoset !== void 0 ? autoset : true;
if(autoset && !this.current && this.targets.length){
this.sort();
this.setCurrent(this.targets[0]);
}
return this.current;
} | javascript | function(autoset){
autoset = autoset !== void 0 ? autoset : true;
if(autoset && !this.current && this.targets.length){
this.sort();
this.setCurrent(this.targets[0]);
}
return this.current;
} | [
"function",
"(",
"autoset",
")",
"{",
"autoset",
"=",
"autoset",
"!==",
"void",
"0",
"?",
"autoset",
":",
"true",
";",
"if",
"(",
"autoset",
"&&",
"!",
"this",
".",
"current",
"&&",
"this",
".",
"targets",
".",
"length",
")",
"{",
"this",
".",
"sor... | Gets the currently selected target object.
@method getCurrent
@param {Bool} [autoset=true] - If no target is set to current autoset the first.
@return {Object} | [
"Gets",
"the",
"currently",
"selected",
"target",
"object",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L109-L117 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(){
if(!this.current){
return this.getCurrent();
}
var index = this.targets.indexOf(this.current);
if(index === 0){
index = this.targets.length - 1;
} else {
index--;
}
this.setCu... | javascript | function(){
if(!this.current){
return this.getCurrent();
}
var index = this.targets.indexOf(this.current);
if(index === 0){
index = this.targets.length - 1;
} else {
index--;
}
this.setCu... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"current",
")",
"{",
"return",
"this",
".",
"getCurrent",
"(",
")",
";",
"}",
"var",
"index",
"=",
"this",
".",
"targets",
".",
"indexOf",
"(",
"this",
".",
"current",
")",
";",
"if",
"(",
... | Sets the object before the currently selected object to be the selected object.
@method prev
@return {Object} The new currently selected object. | [
"Sets",
"the",
"object",
"before",
"the",
"currently",
"selected",
"object",
"to",
"be",
"the",
"selected",
"object",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L144-L158 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(obj){
for(var i = this.typeSortPriority.length - 1; i >= 0; i--){
var type = this.typeSortPriority[i];
if(obj instanceof type){
return i;
}
}
} | javascript | function(obj){
for(var i = this.typeSortPriority.length - 1; i >= 0; i--){
var type = this.typeSortPriority[i];
if(obj instanceof type){
return i;
}
}
} | [
"function",
"(",
"obj",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"this",
".",
"typeSortPriority",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"type",
"=",
"this",
".",
"typeSortPriority",
"[",
"i",
"]",
";",
"if... | Gets the sort priority of an object based on its type using 'this.typeSortPriority'.
@method getTypeSortPriority
@param {Object} obj
@return {Number} | [
"Gets",
"the",
"sort",
"priority",
"of",
"an",
"object",
"based",
"on",
"its",
"type",
"using",
"this",
".",
"typeSortPriority",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L166-L173 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(){
var _this = this;
this.targets.sort(function(a, b){
var aTypeSortPriority = _this.getTypeSortPriority(a.value);
var bTypeSortPriority = _this.getTypeSortPriority(b.value);
if(aTypeSortPriority === bTypeSortPriority){
... | javascript | function(){
var _this = this;
this.targets.sort(function(a, b){
var aTypeSortPriority = _this.getTypeSortPriority(a.value);
var bTypeSortPriority = _this.getTypeSortPriority(b.value);
if(aTypeSortPriority === bTypeSortPriority){
... | [
"function",
"(",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"this",
".",
"targets",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"aTypeSortPriority",
"=",
"_this",
".",
"getTypeSortPriority",
"(",
"a",
".",
"value",
")",
";",
... | Sorts `this.targets` by `this.typeSortPriority` then by range.
@method sort
@return {Number} | [
"Sorts",
"this",
".",
"targets",
"by",
"this",
".",
"typeSortPriority",
"then",
"by",
"range",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L179-L196 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/valid-targets.js | function(value){
for(var i = this.targets.length - 1; i >= 0; i--){
var target = this.targets[i];
if(target.value === value){
return target;
}
}
} | javascript | function(value){
for(var i = this.targets.length - 1; i >= 0; i--){
var target = this.targets[i];
if(target.value === value){
return target;
}
}
} | [
"function",
"(",
"value",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"this",
".",
"targets",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"target",
"=",
"this",
".",
"targets",
"[",
"i",
"]",
";",
"if",
"(",
"t... | Finds a target object by its value.
@method getTargetByValue
@param {Object} value
@return {Object} | [
"Finds",
"a",
"target",
"object",
"by",
"its",
"value",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/valid-targets.js#L204-L211 | train | |
djett41/node-feedjett | lib/parser.js | parseTitle | function parseTitle (node, nodeType, feedType) {
return utils.stripHtml(utils.get(node.title));
} | javascript | function parseTitle (node, nodeType, feedType) {
return utils.stripHtml(utils.get(node.title));
} | [
"function",
"parseTitle",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"return",
"utils",
".",
"stripHtml",
"(",
"utils",
".",
"get",
"(",
"node",
".",
"title",
")",
")",
";",
"}"
] | Parses the title of a meta or item node and strips HTML
@param node
@param nodeType
@param feedType
@returns {string} | [
"Parses",
"the",
"title",
"of",
"a",
"meta",
"or",
"item",
"node",
"and",
"strips",
"HTML"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L86-L88 | train |
djett41/node-feedjett | lib/parser.js | parseDescription | function parseDescription (node, nodeType, feedType) {
var propOrder = nodeType === 'item' ?
['description', 'summary', 'itunes:summary', 'content:encoded', 'content'] :
['description', 'subtitle', 'itunes:summary'];
return utils.stripHtml(utils.getFirstFoundPropValue(node, propOrder));
} | javascript | function parseDescription (node, nodeType, feedType) {
var propOrder = nodeType === 'item' ?
['description', 'summary', 'itunes:summary', 'content:encoded', 'content'] :
['description', 'subtitle', 'itunes:summary'];
return utils.stripHtml(utils.getFirstFoundPropValue(node, propOrder));
} | [
"function",
"parseDescription",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"propOrder",
"=",
"nodeType",
"===",
"'item'",
"?",
"[",
"'description'",
",",
"'summary'",
",",
"'itunes:summary'",
",",
"'content:encoded'",
",",
"'content'",
"]",
... | Parses the description of a meta or item node and strips HTML
- description
- highest priority and quantity in RSS feeds for both meta and item nodes.
- rarely found in ATOM feeds, commonly found in RSS feeds
- subtitle
- highest priority and quantity in ATOM feeds for meta nodes
- rarely found in RSS feeds
- summary
... | [
"Parses",
"the",
"description",
"of",
"a",
"meta",
"or",
"item",
"node",
"and",
"strips",
"HTML"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L119-L125 | train |
djett41/node-feedjett | lib/parser.js | parseXmlUrl | function parseXmlUrl (node, nodeType, feedType) {
var getLink = function (linkNode) {
var link;
utils.parse(linkNode, function (linkEl) {
var linkAttr = linkEl['@'];
if (linkAttr.href && linkAttr.rel === 'self') {
link = linkAttr.href;
return;
}
}, this, true);
ret... | javascript | function parseXmlUrl (node, nodeType, feedType) {
var getLink = function (linkNode) {
var link;
utils.parse(linkNode, function (linkEl) {
var linkAttr = linkEl['@'];
if (linkAttr.href && linkAttr.rel === 'self') {
link = linkAttr.href;
return;
}
}, this, true);
ret... | [
"function",
"parseXmlUrl",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"getLink",
"=",
"function",
"(",
"linkNode",
")",
"{",
"var",
"link",
";",
"utils",
".",
"parse",
"(",
"linkNode",
",",
"function",
"(",
"linkEl",
")",
"{",
"var... | Parses the xmlUrl of a meta node.
- link
- highest priority and quantity in RSS and ATOM feeds for both meta and item nodes.
- atom:link
- next highest priority and quantity in RSS feeds for meta nodes.
- rarely found in ATOM feeds or item nodes if ever.
- atom10:link
- next highest priority in RSS feeds for meta node... | [
"Parses",
"the",
"xmlUrl",
"of",
"a",
"meta",
"node",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L205-L222 | train |
djett41/node-feedjett | lib/parser.js | parseOrigLink | function parseOrigLink (node, nodeType, feedType) {
var origLink;
if (origLink = utils.getFirstFoundPropValue(node, ['feedburner:origlink', 'pheedo:origlink'])) {
return origLink;
} else {
utils.parse(node.link, function (linkEl) {
var linkAttr = linkEl['@'];
if (linkAttr.href && linkAttr.re... | javascript | function parseOrigLink (node, nodeType, feedType) {
var origLink;
if (origLink = utils.getFirstFoundPropValue(node, ['feedburner:origlink', 'pheedo:origlink'])) {
return origLink;
} else {
utils.parse(node.link, function (linkEl) {
var linkAttr = linkEl['@'];
if (linkAttr.href && linkAttr.re... | [
"function",
"parseOrigLink",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"origLink",
";",
"if",
"(",
"origLink",
"=",
"utils",
".",
"getFirstFoundPropValue",
"(",
"node",
",",
"[",
"'feedburner:origlink'",
",",
"'pheedo:origlink'",
"]",
")"... | Parses the origLink for item nodes.
@param node
@param nodeType
@param feedType | [
"Parses",
"the",
"origLink",
"for",
"item",
"nodes",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L232-L249 | train |
djett41/node-feedjett | lib/parser.js | parseAuthor | function parseAuthor (node, nodeType, feedType) {
var authorNode = node.author,
author;
//Both meta and item have author property as top priority and share parsing logic.
if (authorNode && (author = utils.get(authorNode))) {
author = addressparser(author)[0];
return author.name || author.address;
... | javascript | function parseAuthor (node, nodeType, feedType) {
var authorNode = node.author,
author;
//Both meta and item have author property as top priority and share parsing logic.
if (authorNode && (author = utils.get(authorNode))) {
author = addressparser(author)[0];
return author.name || author.address;
... | [
"function",
"parseAuthor",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"authorNode",
"=",
"node",
".",
"author",
",",
"author",
";",
"//Both meta and item have author property as top priority and share parsing logic.",
"if",
"(",
"authorNode",
"&&",
... | Parses the author for meta and item nodes
- author
- highest priority in ATOM and RSS feeds for both meta and item nodes
- more commonly found in ATOM feeds than RSS feeds
- managingeditor
- next highest priority for RSS feeds in meta nodes
- more commonly found in RSS feeds and rarely found in ATOM feeds if ever
- ge... | [
"Parses",
"the",
"author",
"for",
"meta",
"and",
"item",
"nodes"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L288-L314 | train |
djett41/node-feedjett | lib/parser.js | parseLanguage | function parseLanguage (node, nodeType, feedType) {
return utils.get(node.language) || utils.getAttr(node, 'xml:lang') || utils.get(node['dc:language']);
} | javascript | function parseLanguage (node, nodeType, feedType) {
return utils.get(node.language) || utils.getAttr(node, 'xml:lang') || utils.get(node['dc:language']);
} | [
"function",
"parseLanguage",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"return",
"utils",
".",
"get",
"(",
"node",
".",
"language",
")",
"||",
"utils",
".",
"getAttr",
"(",
"node",
",",
"'xml:lang'",
")",
"||",
"utils",
".",
"get",
"(",
... | Parses the language for meta nodes
- language
- highest priority for RSS feeds
- commonly found in RSS feeds and rarely in ATOM feeds if ever
- xml:lang
- highest priority for ATOM feeds
- more commonly found in ATOM feeds and rarely found in RSS feeds if ever
- dc:language
- next highest priority for RSS feeds
- more... | [
"Parses",
"the",
"language",
"for",
"meta",
"nodes"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L335-L337 | train |
djett41/node-feedjett | lib/parser.js | parseUpdateInfo | function parseUpdateInfo (node, nodeType, feedType) {
var updateInfo = {}, temp;
if (temp = utils.get(node['sy:updatefrequency'])) {
updateInfo.frequency = temp;
}
if (temp = utils.get(node['sy:updateperiod'])) {
updateInfo.period = temp;
}
if (temp = utils.get(node['sy:updatebase'])) {
updateI... | javascript | function parseUpdateInfo (node, nodeType, feedType) {
var updateInfo = {}, temp;
if (temp = utils.get(node['sy:updatefrequency'])) {
updateInfo.frequency = temp;
}
if (temp = utils.get(node['sy:updateperiod'])) {
updateInfo.period = temp;
}
if (temp = utils.get(node['sy:updatebase'])) {
updateI... | [
"function",
"parseUpdateInfo",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"updateInfo",
"=",
"{",
"}",
",",
"temp",
";",
"if",
"(",
"temp",
"=",
"utils",
".",
"get",
"(",
"node",
"[",
"'sy:updatefrequency'",
"]",
")",
")",
"{",
"... | Parses the common meta properties used to determine when to update or get a new feed
@param node
@param nodeType
@param feedType
@returns {{}} | [
"Parses",
"the",
"common",
"meta",
"properties",
"used",
"to",
"determine",
"when",
"to",
"update",
"or",
"get",
"a",
"new",
"feed"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L391-L408 | train |
djett41/node-feedjett | lib/parser.js | parseImage | function parseImage (node, nodeType, feedType) {
var image, mediaGroup, mediaContent;
if (node.image && (image = utils.get(utils.get(node.image, 'url') || node.image))) {
return image;
} else if (nodeType === 'meta') {
return utils.getAttr(node['itunes:image'], 'href') || utils.getAttr(node['media:thumbn... | javascript | function parseImage (node, nodeType, feedType) {
var image, mediaGroup, mediaContent;
if (node.image && (image = utils.get(utils.get(node.image, 'url') || node.image))) {
return image;
} else if (nodeType === 'meta') {
return utils.getAttr(node['itunes:image'], 'href') || utils.getAttr(node['media:thumbn... | [
"function",
"parseImage",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"image",
",",
"mediaGroup",
",",
"mediaContent",
";",
"if",
"(",
"node",
".",
"image",
"&&",
"(",
"image",
"=",
"utils",
".",
"get",
"(",
"utils",
".",
"get",
"... | Parses the image of a meta or item node.
- image
- highest priority for RSS feeds in both meta nd item nodes
- most frequent in meta nodes, less frequent in item nodes
- itunes:image
- second most frequent in RSS feeds for meta nodes
- less frequent and lesser priority than media:thumbnail in RSS feeds for item nodes
... | [
"Parses",
"the",
"image",
"of",
"a",
"meta",
"or",
"item",
"node",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L472-L500 | train |
djett41/node-feedjett | lib/parser.js | parseCloud | function parseCloud (node, nodeType, feedType) {
var cloud,
temp = utils.getAttr(node.cloud) || {};
if (Object.keys(temp).length) {
cloud = temp;
cloud.type = 'rsscloud';
} else {
utils.parse(node.link, function (link) {
var attr = utils.getAttr(link);
if (attr && attr.href && attr.... | javascript | function parseCloud (node, nodeType, feedType) {
var cloud,
temp = utils.getAttr(node.cloud) || {};
if (Object.keys(temp).length) {
cloud = temp;
cloud.type = 'rsscloud';
} else {
utils.parse(node.link, function (link) {
var attr = utils.getAttr(link);
if (attr && attr.href && attr.... | [
"function",
"parseCloud",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"cloud",
",",
"temp",
"=",
"utils",
".",
"getAttr",
"(",
"node",
".",
"cloud",
")",
"||",
"{",
"}",
";",
"if",
"(",
"Object",
".",
"keys",
"(",
"temp",
")",
... | Parses the cloud of a meta node.
- cloud
- highest priority for RSS feeds
- rarely found in ATOM feeds if ever
- link (rel=hub)
- mostly found in ATOM feeds and rarely in RSS
@param node
@param nodeType
@param feedType | [
"Parses",
"the",
"cloud",
"of",
"a",
"meta",
"node",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L516-L534 | train |
djett41/node-feedjett | lib/parser.js | parseCategories | function parseCategories (node, nodeType, feedType) {
var categoryMap = {};
var setCategory = function (category, attrProp) {
if (!category) {
return;
} else if (attrProp) {
category = utils.getAttr(category, attrProp);
}
if (!categoryMap[category]) {
categoryMap[category] = true... | javascript | function parseCategories (node, nodeType, feedType) {
var categoryMap = {};
var setCategory = function (category, attrProp) {
if (!category) {
return;
} else if (attrProp) {
category = utils.getAttr(category, attrProp);
}
if (!categoryMap[category]) {
categoryMap[category] = true... | [
"function",
"parseCategories",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"categoryMap",
"=",
"{",
"}",
";",
"var",
"setCategory",
"=",
"function",
"(",
"category",
",",
"attrProp",
")",
"{",
"if",
"(",
"!",
"category",
")",
"{",
"... | Parses and aggregates an Array of categories for an item or meta node. The following node properties are parsed in
order of most frequently available. Categories for a specific node are uniquely identified and cached by value,
then mapped to an array of categories
category, dc:subject, link, itunes:category, media:c... | [
"Parses",
"and",
"aggregates",
"an",
"Array",
"of",
"categories",
"for",
"an",
"item",
"or",
"meta",
"node",
".",
"The",
"following",
"node",
"properties",
"are",
"parsed",
"in",
"order",
"of",
"most",
"frequently",
"available",
".",
"Categories",
"for",
"a"... | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L549-L597 | train |
djett41/node-feedjett | lib/parser.js | parseComments | function parseComments (node, nodeType, feedType) {
var comments = utils.get(node.comments);
if (!comments && feedType === 'atom') {
utils.parse(node.link, function (link) {
var linkAttr = link['@'];
if (linkAttr && linkAttr.rel === 'replies' && linkAttr.href) {
comments = linkAttr.href;
... | javascript | function parseComments (node, nodeType, feedType) {
var comments = utils.get(node.comments);
if (!comments && feedType === 'atom') {
utils.parse(node.link, function (link) {
var linkAttr = link['@'];
if (linkAttr && linkAttr.rel === 'replies' && linkAttr.href) {
comments = linkAttr.href;
... | [
"function",
"parseComments",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"comments",
"=",
"utils",
".",
"get",
"(",
"node",
".",
"comments",
")",
";",
"if",
"(",
"!",
"comments",
"&&",
"feedType",
"===",
"'atom'",
")",
"{",
"utils",... | Parses comments for item nodes
- comments
- highest priority for RSS and ATOM feeds
- link (rel=replies)
- fallback for comments sometimes found in ATOM feeds
@param node
@param nodeType
@param feedType
@returns {*} | [
"Parses",
"comments",
"for",
"item",
"nodes"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L613-L631 | train |
djett41/node-feedjett | lib/parser.js | parseEnclosures | function parseEnclosures (node, nodeType, feedType) {
var enclosuresMap = {};
['media:content', 'enclosure', 'link', 'enc:enclosure'].forEach(function (key) {
if (!node[key]) {
return;
}
utils.parse(node[key], function (enc) {
var enclosure,
encAttr = enc['@'];
if (!encAtt... | javascript | function parseEnclosures (node, nodeType, feedType) {
var enclosuresMap = {};
['media:content', 'enclosure', 'link', 'enc:enclosure'].forEach(function (key) {
if (!node[key]) {
return;
}
utils.parse(node[key], function (enc) {
var enclosure,
encAttr = enc['@'];
if (!encAtt... | [
"function",
"parseEnclosures",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"enclosuresMap",
"=",
"{",
"}",
";",
"[",
"'media:content'",
",",
"'enclosure'",
",",
"'link'",
",",
"'enc:enclosure'",
"]",
".",
"forEach",
"(",
"function",
"(",
... | Parses and aggregates an Array of enclosures for an item node. The following node properties are parsed in
order of most frequently available. enclosures for a specific node are uniquely identified and cached by url,
then mapped to an array of enclosures
media:content, enclosure, link, enc:enclosure
@param node
@pa... | [
"Parses",
"and",
"aggregates",
"an",
"Array",
"of",
"enclosures",
"for",
"an",
"item",
"node",
".",
"The",
"following",
"node",
"properties",
"are",
"parsed",
"in",
"order",
"of",
"most",
"frequently",
"available",
".",
"enclosures",
"for",
"a",
"specific",
... | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L683-L727 | train |
djett41/node-feedjett | lib/parser.js | parseSource | function parseSource (node, nodeType, feedType) {
var source = {},
sourceNode = node.source,
temp;
if (!sourceNode) {
return;
}
if (temp = (feedType === 'atom' && utils.get(sourceNode.title)) || utils.get(sourceNode)) {
source.title = temp;
}
if (temp = (feedType === 'atom' && utils.ge... | javascript | function parseSource (node, nodeType, feedType) {
var source = {},
sourceNode = node.source,
temp;
if (!sourceNode) {
return;
}
if (temp = (feedType === 'atom' && utils.get(sourceNode.title)) || utils.get(sourceNode)) {
source.title = temp;
}
if (temp = (feedType === 'atom' && utils.ge... | [
"function",
"parseSource",
"(",
"node",
",",
"nodeType",
",",
"feedType",
")",
"{",
"var",
"source",
"=",
"{",
"}",
",",
"sourceNode",
"=",
"node",
".",
"source",
",",
"temp",
";",
"if",
"(",
"!",
"sourceNode",
")",
"{",
"return",
";",
"}",
"if",
"... | Parse the source of an item node
@param node
@param nodeType
@param feedType | [
"Parse",
"the",
"source",
"of",
"an",
"item",
"node"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/parser.js#L756-L773 | train |
djett41/node-feedjett | lib/utils.js | get | function get(obj, subkey) {
if (!obj) { return; }
if (Array.isArray(obj)) {
obj = obj[0];
}
return obj[subkey || '#'];
} | javascript | function get(obj, subkey) {
if (!obj) { return; }
if (Array.isArray(obj)) {
obj = obj[0];
}
return obj[subkey || '#'];
} | [
"function",
"get",
"(",
"obj",
",",
"subkey",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"obj",
"=",
"obj",
"[",
"0",
"]",
";",
"}",
"return",
"obj",
"[",
"s... | Utility function to test for and extract a subkey.
var obj = { '#': 'foo', 'bar': 'baz' };
get(obj);
// => 'foo'
get(obj, 'bar');
// => 'baz'
@param {Object} obj
@param {String} [subkey="#"] By default, use the '#' key, but you may pass any key you like
@return {*} Returns the value of the selected key or 'null' if... | [
"Utility",
"function",
"to",
"test",
"for",
"and",
"extract",
"a",
"subkey",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L38-L45 | train |
djett41/node-feedjett | lib/utils.js | getAttr | function getAttr(obj, attr) {
if (!obj) { return; }
if (Array.isArray(obj)) {
obj = obj[0];
}
return (attr && obj['@']) ? obj['@'][attr] : obj['@'];
} | javascript | function getAttr(obj, attr) {
if (!obj) { return; }
if (Array.isArray(obj)) {
obj = obj[0];
}
return (attr && obj['@']) ? obj['@'][attr] : obj['@'];
} | [
"function",
"getAttr",
"(",
"obj",
",",
"attr",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"obj",
"=",
"obj",
"[",
"0",
"]",
";",
"}",
"return",
"(",
"attr",
... | Fetches a specific attribute or the whole attribute for an object
@param obj
@param attr
@returns {*} | [
"Fetches",
"a",
"specific",
"attribute",
"or",
"the",
"whole",
"attribute",
"for",
"an",
"object"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L56-L64 | train |
djett41/node-feedjett | lib/utils.js | parse | function parse (el, parseFn, context, canBreak) {
if (!el) { return; }
if (!Array.isArray(el)) {
parseFn.call(context, el);
} else if (canBreak) {
el.some(parseFn, context);
} else {
el.forEach(parseFn, context);
}
} | javascript | function parse (el, parseFn, context, canBreak) {
if (!el) { return; }
if (!Array.isArray(el)) {
parseFn.call(context, el);
} else if (canBreak) {
el.some(parseFn, context);
} else {
el.forEach(parseFn, context);
}
} | [
"function",
"parse",
"(",
"el",
",",
"parseFn",
",",
"context",
",",
"canBreak",
")",
"{",
"if",
"(",
"!",
"el",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"el",
")",
")",
"{",
"parseFn",
".",
"call",
"(",
"cont... | Invokes a callback with a specified context.
If the el is an array, the callback will be called for each item in the array
@param el
@param parseFn
@param context | [
"Invokes",
"a",
"callback",
"with",
"a",
"specified",
"context",
".",
"If",
"the",
"el",
"is",
"an",
"array",
"the",
"callback",
"will",
"be",
"called",
"for",
"each",
"item",
"in",
"the",
"array"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L124-L134 | train |
djett41/node-feedjett | lib/utils.js | strArrayToObj | function strArrayToObj (array) {
return array && array.reduce(function(o, v) {
o[v] = true;
return o;
}, {});
} | javascript | function strArrayToObj (array) {
return array && array.reduce(function(o, v) {
o[v] = true;
return o;
}, {});
} | [
"function",
"strArrayToObj",
"(",
"array",
")",
"{",
"return",
"array",
"&&",
"array",
".",
"reduce",
"(",
"function",
"(",
"o",
",",
"v",
")",
"{",
"o",
"[",
"v",
"]",
"=",
"true",
";",
"return",
"o",
";",
"}",
",",
"{",
"}",
")",
";",
"}"
] | Converts a String array to object. Used for whitelisting and blacklisting feed properties
@param array
@returns {*} | [
"Converts",
"a",
"String",
"array",
"to",
"object",
".",
"Used",
"for",
"whitelisting",
"and",
"blacklisting",
"feed",
"properties"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L144-L149 | train |
djett41/node-feedjett | lib/utils.js | createOpenTag | function createOpenTag (tagName, attrs) {
var attrString = Object.keys(attrs).map(function (key) {
return ' ' + key + '="' + attrs[key] + '"';
}).join('');
return '<' + tagName + attrString + '>';
} | javascript | function createOpenTag (tagName, attrs) {
var attrString = Object.keys(attrs).map(function (key) {
return ' ' + key + '="' + attrs[key] + '"';
}).join('');
return '<' + tagName + attrString + '>';
} | [
"function",
"createOpenTag",
"(",
"tagName",
",",
"attrs",
")",
"{",
"var",
"attrString",
"=",
"Object",
".",
"keys",
"(",
"attrs",
")",
".",
"map",
"(",
"function",
"(",
"key",
")",
"{",
"return",
"' '",
"+",
"key",
"+",
"'=\"'",
"+",
"attrs",
"[",
... | Creates an opening XML tag based on tagName and attributes
@param tagName
@param attrs
@returns {string} | [
"Creates",
"an",
"opening",
"XML",
"tag",
"based",
"on",
"tagName",
"and",
"attributes"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L194-L200 | train |
djett41/node-feedjett | lib/utils.js | getStandardTimeOffset | function getStandardTimeOffset(date) {
var jan = new Date(date.getFullYear(), 0, 1);
var jul = new Date(date.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
} | javascript | function getStandardTimeOffset(date) {
var jan = new Date(date.getFullYear(), 0, 1);
var jul = new Date(date.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
} | [
"function",
"getStandardTimeOffset",
"(",
"date",
")",
"{",
"var",
"jan",
"=",
"new",
"Date",
"(",
"date",
".",
"getFullYear",
"(",
")",
",",
"0",
",",
"1",
")",
";",
"var",
"jul",
"=",
"new",
"Date",
"(",
"date",
".",
"getFullYear",
"(",
")",
",",... | Returns the standard time timezone offset regardless of whether the current time is on standard or daylight saving time.
@param node
@param nodeType
@param feedType | [
"Returns",
"the",
"standard",
"time",
"timezone",
"offset",
"regardless",
"of",
"whether",
"the",
"current",
"time",
"is",
"on",
"standard",
"or",
"daylight",
"saving",
"time",
"."
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L222-L226 | train |
djett41/node-feedjett | lib/utils.js | fixInvalidDate | function fixInvalidDate(dateString) {
if (!dateString) {
return;
}
//Convert invalid dates' timezones to GMT using timezoneMap
dateString = dateString.replace(/BST?/i, function (match) {
return timezoneMap[match];
});
//Some dates come in as ET, CT etc.. and some don't have the correct offset.
/... | javascript | function fixInvalidDate(dateString) {
if (!dateString) {
return;
}
//Convert invalid dates' timezones to GMT using timezoneMap
dateString = dateString.replace(/BST?/i, function (match) {
return timezoneMap[match];
});
//Some dates come in as ET, CT etc.. and some don't have the correct offset.
/... | [
"function",
"fixInvalidDate",
"(",
"dateString",
")",
"{",
"if",
"(",
"!",
"dateString",
")",
"{",
"return",
";",
"}",
"//Convert invalid dates' timezones to GMT using timezoneMap",
"dateString",
"=",
"dateString",
".",
"replace",
"(",
"/",
"BST?",
"/",
"i",
",",
... | Attempts to fix invalid dates coming in from different feeds
@param dateString
@returns {Date} | [
"Attempts",
"to",
"fix",
"invalid",
"dates",
"coming",
"in",
"from",
"different",
"feeds"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L246-L264 | train |
djett41/node-feedjett | lib/utils.js | getDate | function getDate (dateString) {
var date = new Date(dateString);
if (Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime())) {
return date;
}
//try to fix invalid date
date = fixInvalidDate(dateString);
//if date still isn't valid there's not more we can do..
if (!isNaN(... | javascript | function getDate (dateString) {
var date = new Date(dateString);
if (Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime())) {
return date;
}
//try to fix invalid date
date = fixInvalidDate(dateString);
//if date still isn't valid there's not more we can do..
if (!isNaN(... | [
"function",
"getDate",
"(",
"dateString",
")",
"{",
"var",
"date",
"=",
"new",
"Date",
"(",
"dateString",
")",
";",
"if",
"(",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"date",
")",
"===",
"'[object Date]'",
"&&",
"!",
"isNaN",
"("... | Parses a date string to a date
@param dateString | [
"Parses",
"a",
"date",
"string",
"to",
"a",
"date"
] | b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/utils.js#L272-L286 | train |
sergeyt/fetch-stream | src/parser.js | makeConcat | function makeConcat(chunkType) {
switch (chunkType) {
case BUFFER:
return (a, b) => Buffer.concat([a, b]);
default:
return (a, b) => {
// console.log('[%d, %d]', a.length, b.length);
const t = new Uint8Array(a.length + b.length);
t.set(a);
t.set(b, a.length);
// console.log('%d: %s', t.length, new... | javascript | function makeConcat(chunkType) {
switch (chunkType) {
case BUFFER:
return (a, b) => Buffer.concat([a, b]);
default:
return (a, b) => {
// console.log('[%d, %d]', a.length, b.length);
const t = new Uint8Array(a.length + b.length);
t.set(a);
t.set(b, a.length);
// console.log('%d: %s', t.length, new... | [
"function",
"makeConcat",
"(",
"chunkType",
")",
"{",
"switch",
"(",
"chunkType",
")",
"{",
"case",
"BUFFER",
":",
"return",
"(",
"a",
",",
"b",
")",
"=>",
"Buffer",
".",
"concat",
"(",
"[",
"a",
",",
"b",
"]",
")",
";",
"default",
":",
"return",
... | Makes function to concat two byte chunks.
@param {Boolean} [chunkType] Specifies type of input chunks.
@return {Function} The function to concat two byte chunks. | [
"Makes",
"function",
"to",
"concat",
"two",
"byte",
"chunks",
"."
] | eab91c059ce3b1d172fd44890769c761bb4b7aa3 | https://github.com/sergeyt/fetch-stream/blob/eab91c059ce3b1d172fd44890769c761bb4b7aa3/src/parser.js#L47-L61 | train |
jlengstorf/responsive-lazyload.js | source/scripts/responsive-lazyload.js | isElementVisible | function isElementVisible(el) {
/*
* Checks if element (or an ancestor) is hidden via style properties.
* See https://stackoverflow.com/a/21696585/463471
*/
const isCurrentlyVisible = el.offsetParent !== null;
// Check if any part of the element is vertically within the viewport.
const position = el.g... | javascript | function isElementVisible(el) {
/*
* Checks if element (or an ancestor) is hidden via style properties.
* See https://stackoverflow.com/a/21696585/463471
*/
const isCurrentlyVisible = el.offsetParent !== null;
// Check if any part of the element is vertically within the viewport.
const position = el.g... | [
"function",
"isElementVisible",
"(",
"el",
")",
"{",
"/*\n * Checks if element (or an ancestor) is hidden via style properties.\n * See https://stackoverflow.com/a/21696585/463471\n */",
"const",
"isCurrentlyVisible",
"=",
"el",
".",
"offsetParent",
"!==",
"null",
";",
"// Chec... | Check if an element is visible at all in the viewport.
It would be cool to use an IntersectionObserver here, but browser support
isn’t there yet: http://caniuse.com/#feat=intersectionobserver
@param {Element} el the element to check
@return {Boolean} `true` if the element is visible at all; `false` if not | [
"Check",
"if",
"an",
"element",
"is",
"visible",
"at",
"all",
"in",
"the",
"viewport",
"."
] | d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/source/scripts/responsive-lazyload.js#L10-L27 | train |
Lanfei/websocket-lib | lib/frame.js | Receiver | function Receiver() {
stream.Duplex.call(this, {
readableObjectMode: true
});
this._buffer = null;
this._frame = new Frame();
this._state = WAITING_FOR_HEADER;
} | javascript | function Receiver() {
stream.Duplex.call(this, {
readableObjectMode: true
});
this._buffer = null;
this._frame = new Frame();
this._state = WAITING_FOR_HEADER;
} | [
"function",
"Receiver",
"(",
")",
"{",
"stream",
".",
"Duplex",
".",
"call",
"(",
"this",
",",
"{",
"readableObjectMode",
":",
"true",
"}",
")",
";",
"this",
".",
"_buffer",
"=",
"null",
";",
"this",
".",
"_frame",
"=",
"new",
"Frame",
"(",
")",
";... | WebSocket Frame Receiver
@constructor
@extends stream.Duplex | [
"WebSocket",
"Frame",
"Receiver"
] | d39f704490fb91b1e2897712b280c0e5ac79e123 | https://github.com/Lanfei/websocket-lib/blob/d39f704490fb91b1e2897712b280c0e5ac79e123/lib/frame.js#L174-L182 | train |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mouse.js | function(e){
if(e.type === 'mousemove' && this.onHover){
this.onHover(e.clientX, e.clientY);
}
else if(e.type === 'mouseenter' && this.onHover){
this.onHover(e.clientX, e.clientY);
}
else if(e.type === 'mouseleave' && this.onHov... | javascript | function(e){
if(e.type === 'mousemove' && this.onHover){
this.onHover(e.clientX, e.clientY);
}
else if(e.type === 'mouseenter' && this.onHover){
this.onHover(e.clientX, e.clientY);
}
else if(e.type === 'mouseleave' && this.onHov... | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"type",
"===",
"'mousemove'",
"&&",
"this",
".",
"onHover",
")",
"{",
"this",
".",
"onHover",
"(",
"e",
".",
"clientX",
",",
"e",
".",
"clientY",
")",
";",
"}",
"else",
"if",
"(",
"e",
".",
... | Hander for mouse events
@method handleEvent
@param {Event} e - mouse event | [
"Hander",
"for",
"mouse",
"events"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mouse.js#L48-L61 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mouse.js | function(e) {
if(this.onHover){
var coords = this.game.renderer.mouseToTileCoords(e.clientX, e.clientY);
this.onHover(coords);
}
} | javascript | function(e) {
if(this.onHover){
var coords = this.game.renderer.mouseToTileCoords(e.clientX, e.clientY);
this.onHover(coords);
}
} | [
"function",
"(",
"e",
")",
"{",
"if",
"(",
"this",
".",
"onHover",
")",
"{",
"var",
"coords",
"=",
"this",
".",
"game",
".",
"renderer",
".",
"mouseToTileCoords",
"(",
"e",
".",
"clientX",
",",
"e",
".",
"clientY",
")",
";",
"this",
".",
"onHover",... | Hander for mouse move events
@method mouseMove
@param {Event} e - mouse event | [
"Hander",
"for",
"mouse",
"move",
"events"
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mouse.js#L68-L73 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mouse.js | function(element){
if(this._boundElement){
this.stopListening();
}
element.addEventListener('mousemove', this);
element.addEventListener('mouseenter', this);
element.addEventListener('mouseleave', this);
element.addEventListener('c... | javascript | function(element){
if(this._boundElement){
this.stopListening();
}
element.addEventListener('mousemove', this);
element.addEventListener('mouseenter', this);
element.addEventListener('mouseleave', this);
element.addEventListener('c... | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"this",
".",
"_boundElement",
")",
"{",
"this",
".",
"stopListening",
"(",
")",
";",
"}",
"element",
".",
"addEventListener",
"(",
"'mousemove'",
",",
"this",
")",
";",
"element",
".",
"addEventListener",
... | Binds event listener for mouse events.
@method startListening
@param {HTMLElement} element - The dom element being rendered to. | [
"Binds",
"event",
"listener",
"for",
"mouse",
"events",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mouse.js#L80-L91 | train | |
THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/mouse.js | function(){
if(!this._boundElement){
return false;
}
var el = this._boundElement;
el.removeEventListener('mousemove', this);
el.removeEventListener('mouseenter', this);
el.removeEventListener('mouseleave', this);
el.remo... | javascript | function(){
if(!this._boundElement){
return false;
}
var el = this._boundElement;
el.removeEventListener('mousemove', this);
el.removeEventListener('mouseenter', this);
el.removeEventListener('mouseleave', this);
el.remo... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_boundElement",
")",
"{",
"return",
"false",
";",
"}",
"var",
"el",
"=",
"this",
".",
"_boundElement",
";",
"el",
".",
"removeEventListener",
"(",
"'mousemove'",
",",
"this",
")",
";",
"el",
".... | Unbinds event listener for mouse events.
@method stopListening | [
"Unbinds",
"event",
"listener",
"for",
"mouse",
"events",
"."
] | ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/mouse.js#L97-L106 | train | |
bjorg/jDoc | src/jdoc.js | function(array, json) {
var i;
if (typeof json === 'object' && typeof json.length === 'number') {
for (i = 0; i < json.length; ++i) {
array.push(json[i]);
}
} else {
array.push(json);
}
} | javascript | function(array, json) {
var i;
if (typeof json === 'object' && typeof json.length === 'number') {
for (i = 0; i < json.length; ++i) {
array.push(json[i]);
}
} else {
array.push(json);
}
} | [
"function",
"(",
"array",
",",
"json",
")",
"{",
"var",
"i",
";",
"if",
"(",
"typeof",
"json",
"===",
"'object'",
"&&",
"typeof",
"json",
".",
"length",
"===",
"'number'",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"json",
".",
"length",... | private jDoc functions | [
"private",
"jDoc",
"functions"
] | 14ace8ae07320e180a1445f25881d31b0c477540 | https://github.com/bjorg/jDoc/blob/14ace8ae07320e180a1445f25881d31b0c477540/src/jdoc.js#L87-L96 | train | |
jonjomckay/jjgraph | javascript/examples/grapheditor/www/js/Editor.js | function(sender, evt)
{
var cand = graph.getSelectionCellsForChanges(evt.getProperty('edit').changes);
var model = graph.getModel();
var cells = [];
for (var i = 0; i < cand.length; i++)
{
if ((model.isVertex(cand[i]) || model.isEdge(cand[i])) && graph.view.getState(cand[i]) != null)
{
cells.pus... | javascript | function(sender, evt)
{
var cand = graph.getSelectionCellsForChanges(evt.getProperty('edit').changes);
var model = graph.getModel();
var cells = [];
for (var i = 0; i < cand.length; i++)
{
if ((model.isVertex(cand[i]) || model.isEdge(cand[i])) && graph.view.getState(cand[i]) != null)
{
cells.pus... | [
"function",
"(",
"sender",
",",
"evt",
")",
"{",
"var",
"cand",
"=",
"graph",
".",
"getSelectionCellsForChanges",
"(",
"evt",
".",
"getProperty",
"(",
"'edit'",
")",
".",
"changes",
")",
";",
"var",
"model",
"=",
"graph",
".",
"getModel",
"(",
")",
";"... | Keeps the selection in sync with the history | [
"Keeps",
"the",
"selection",
"in",
"sync",
"with",
"the",
"history"
] | f041596ea8cb33e7a47e8c029008f13b31a92469 | https://github.com/jonjomckay/jjgraph/blob/f041596ea8cb33e7a47e8c029008f13b31a92469/javascript/examples/grapheditor/www/js/Editor.js#L596-L611 | train | |
sethvincent/read-directory | transform.js | end | function end (next) {
filenames(dir, obj).forEach(function (filename) {
sm.emit('file', filename)
})
next()
} | javascript | function end (next) {
filenames(dir, obj).forEach(function (filename) {
sm.emit('file', filename)
})
next()
} | [
"function",
"end",
"(",
"next",
")",
"{",
"filenames",
"(",
"dir",
",",
"obj",
")",
".",
"forEach",
"(",
"function",
"(",
"filename",
")",
"{",
"sm",
".",
"emit",
"(",
"'file'",
",",
"filename",
")",
"}",
")",
"next",
"(",
")",
"}"
] | Make sure all files are watched | [
"Make",
"sure",
"all",
"files",
"are",
"watched"
] | e154975071f1dd68ecd4ccb4b329aa00dc1b056e | https://github.com/sethvincent/read-directory/blob/e154975071f1dd68ecd4ccb4b329aa00dc1b056e/transform.js#L33-L38 | train |
nickzuber/needle | src/BitArray/bitArray.js | function(n){
if(typeof n === 'number'){
return n;
}
if(typeof n !== 'string'){
n = JSON.stringify(n)
}
var res = 0;
n.split("").map(function(bit){
res += bit.charCodeAt(0);
});
return res;
} | javascript | function(n){
if(typeof n === 'number'){
return n;
}
if(typeof n !== 'string'){
n = JSON.stringify(n)
}
var res = 0;
n.split("").map(function(bit){
res += bit.charCodeAt(0);
});
return res;
} | [
"function",
"(",
"n",
")",
"{",
"if",
"(",
"typeof",
"n",
"===",
"'number'",
")",
"{",
"return",
"n",
";",
"}",
"if",
"(",
"typeof",
"n",
"!==",
"'string'",
")",
"{",
"n",
"=",
"JSON",
".",
"stringify",
"(",
"n",
")",
"}",
"var",
"res",
"=",
... | Transforms input into a number.
@param {*} input to become a number
@return {number} number version of input | [
"Transforms",
"input",
"into",
"a",
"number",
"."
] | 9565b3c193b93d67ffed39d430eba395a7bb5531 | https://github.com/nickzuber/needle/blob/9565b3c193b93d67ffed39d430eba395a7bb5531/src/BitArray/bitArray.js#L26-L38 | train | |
nickzuber/needle | src/BitArray/bitArray.js | function(size){
this.data = [];
if(typeof size === 'undefined'){
return; // Empty instance of a bit array
}
if(typeof size !== 'number'){
size = shred(size);
}
for(var i=0; i<Math.ceil(size/INTEGER_SIZE); ++i){
this.data.push(0);
}
} | javascript | function(size){
this.data = [];
if(typeof size === 'undefined'){
return; // Empty instance of a bit array
}
if(typeof size !== 'number'){
size = shred(size);
}
for(var i=0; i<Math.ceil(size/INTEGER_SIZE); ++i){
this.data.push(0);
}
} | [
"function",
"(",
"size",
")",
"{",
"this",
".",
"data",
"=",
"[",
"]",
";",
"if",
"(",
"typeof",
"size",
"===",
"'undefined'",
")",
"{",
"return",
";",
"// Empty instance of a bit array",
"}",
"if",
"(",
"typeof",
"size",
"!==",
"'number'",
")",
"{",
"... | Instantiates a bit array with given size.
@param {number} [size = 0] the size of the bit array
@return {void} | [
"Instantiates",
"a",
"bit",
"array",
"with",
"given",
"size",
"."
] | 9565b3c193b93d67ffed39d430eba395a7bb5531 | https://github.com/nickzuber/needle/blob/9565b3c193b93d67ffed39d430eba395a7bb5531/src/BitArray/bitArray.js#L50-L61 | train | |
juttle/juttle-elastic-adapter | lib/query.js | bridge_fetch | function bridge_fetch(size) {
var bridge_time = new JuttleMoment(last_seen_timestamp);
var time_filter = {term: {}};
time_filter.term[timeField] = bridge_time.valueOf();
var body = make_body(filter, null, null, direction, time_filter, size, timeField);
body.from = bridge_offset... | javascript | function bridge_fetch(size) {
var bridge_time = new JuttleMoment(last_seen_timestamp);
var time_filter = {term: {}};
time_filter.term[timeField] = bridge_time.valueOf();
var body = make_body(filter, null, null, direction, time_filter, size, timeField);
body.from = bridge_offset... | [
"function",
"bridge_fetch",
"(",
"size",
")",
"{",
"var",
"bridge_time",
"=",
"new",
"JuttleMoment",
"(",
"last_seen_timestamp",
")",
";",
"var",
"time_filter",
"=",
"{",
"term",
":",
"{",
"}",
"}",
";",
"time_filter",
".",
"term",
"[",
"timeField",
"]",
... | if more than fetchSize events have the same timestamp, we do a "bridge fetch" which pages through all the points with that timestamp | [
"if",
"more",
"than",
"fetchSize",
"events",
"have",
"the",
"same",
"timestamp",
"we",
"do",
"a",
"bridge",
"fetch",
"which",
"pages",
"through",
"all",
"the",
"points",
"with",
"that",
"timestamp"
] | 7b3b1c46943381230bc7dde33874a738a0a50cbe | https://github.com/juttle/juttle-elastic-adapter/blob/7b3b1c46943381230bc7dde33874a738a0a50cbe/lib/query.js#L109-L137 | train |
juttle/juttle-elastic-adapter | lib/query.js | drop_last_time_stamp_and_maybe_bridge_fetch | function drop_last_time_stamp_and_maybe_bridge_fetch(processed, size) {
if (processed.eof) { return processed; }
var last = _.last(processed.points);
last_seen_timestamp = last && last.time;
var non_simultaneous_points = processed.points.filter(function(pt) {
return pt.time ... | javascript | function drop_last_time_stamp_and_maybe_bridge_fetch(processed, size) {
if (processed.eof) { return processed; }
var last = _.last(processed.points);
last_seen_timestamp = last && last.time;
var non_simultaneous_points = processed.points.filter(function(pt) {
return pt.time ... | [
"function",
"drop_last_time_stamp_and_maybe_bridge_fetch",
"(",
"processed",
",",
"size",
")",
"{",
"if",
"(",
"processed",
".",
"eof",
")",
"{",
"return",
"processed",
";",
"}",
"var",
"last",
"=",
"_",
".",
"last",
"(",
"processed",
".",
"points",
")",
"... | takes the output of points_and_eof_from_es_result and removes the points with the last timestamp, triggering a bridge fetch if all the points are simultaneous. This makes sure the next query, which starts at the last timestamp, won't return any duplicates | [
"takes",
"the",
"output",
"of",
"points_and_eof_from_es_result",
"and",
"removes",
"the",
"points",
"with",
"the",
"last",
"timestamp",
"triggering",
"a",
"bridge",
"fetch",
"if",
"all",
"the",
"points",
"are",
"simultaneous",
".",
"This",
"makes",
"sure",
"the"... | 7b3b1c46943381230bc7dde33874a738a0a50cbe | https://github.com/juttle/juttle-elastic-adapter/blob/7b3b1c46943381230bc7dde33874a738a0a50cbe/lib/query.js#L143-L162 | train |
sergeyt/fetch-stream | lib/parser.js | makeDecoder | function makeDecoder(chunkType) {
if (chunkType === BUFFER) {
return function (buf) {
return buf.toString('utf8');
};
}
if (isnode) {
return function (a) {
return new Buffer(a).toString('utf8');
};
}
var decoder = null;
return function (buf) {
if (!decoder) {
decoder = new TextDecoder();
}
... | javascript | function makeDecoder(chunkType) {
if (chunkType === BUFFER) {
return function (buf) {
return buf.toString('utf8');
};
}
if (isnode) {
return function (a) {
return new Buffer(a).toString('utf8');
};
}
var decoder = null;
return function (buf) {
if (!decoder) {
decoder = new TextDecoder();
}
... | [
"function",
"makeDecoder",
"(",
"chunkType",
")",
"{",
"if",
"(",
"chunkType",
"===",
"BUFFER",
")",
"{",
"return",
"function",
"(",
"buf",
")",
"{",
"return",
"buf",
".",
"toString",
"(",
"'utf8'",
")",
";",
"}",
";",
"}",
"if",
"(",
"isnode",
")",
... | Makes UTF8 decoding function.
@param {Boolean} [chunkType] Specifies type of input chunks.
@return {Function} The function to decode byte chunks. | [
"Makes",
"UTF8",
"decoding",
"function",
"."
] | eab91c059ce3b1d172fd44890769c761bb4b7aa3 | https://github.com/sergeyt/fetch-stream/blob/eab91c059ce3b1d172fd44890769c761bb4b7aa3/lib/parser.js#L32-L50 | train |
LittleHelicase/frequencyjs | lib/processing.js | function(signal1, signal2, options){
options = options || {};
options = _.defaults(options, defaultOptions);
// ensure signal2 is not longer than signal2
if(signal1.length < signal2.length){
var tmp = signal1;
signal1 = signal2;
signal2 = tmp;
}
if(options.method == "... | javascript | function(signal1, signal2, options){
options = options || {};
options = _.defaults(options, defaultOptions);
// ensure signal2 is not longer than signal2
if(signal1.length < signal2.length){
var tmp = signal1;
signal1 = signal2;
signal2 = tmp;
}
if(options.method == "... | [
"function",
"(",
"signal1",
",",
"signal2",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
"=",
"_",
".",
"defaults",
"(",
"options",
",",
"defaultOptions",
")",
";",
"// ensure signal2 is not longer than signal2",
"if",
... | the convolution function assumes two discrete signals
that have the same spacing | [
"the",
"convolution",
"function",
"assumes",
"two",
"discrete",
"signals",
"that",
"have",
"the",
"same",
"spacing"
] | a3cf163ddfe77888ddefde77417f2ea192c05cc8 | https://github.com/LittleHelicase/frequencyjs/blob/a3cf163ddfe77888ddefde77417f2ea192c05cc8/lib/processing.js#L24-L40 | train | |
LittleHelicase/frequencyjs | lib/processing.js | function(signal1, signal2, options){
options = options || {};
options.epsilon = options.epsilon || 1E-08;
var sig1 = Signal(signal1);
var sig2 = Signal(signal2);
if(signal1.length != signal2.length) return false;
var diffSQ = _.reduce(_.range(signal1.length), function(d,idx){
var diff = (s... | javascript | function(signal1, signal2, options){
options = options || {};
options.epsilon = options.epsilon || 1E-08;
var sig1 = Signal(signal1);
var sig2 = Signal(signal2);
if(signal1.length != signal2.length) return false;
var diffSQ = _.reduce(_.range(signal1.length), function(d,idx){
var diff = (s... | [
"function",
"(",
"signal1",
",",
"signal2",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"epsilon",
"=",
"options",
".",
"epsilon",
"||",
"1E-08",
";",
"var",
"sig1",
"=",
"Signal",
"(",
"signal1",
")",
";... | determines if two signals can be considered equal. | [
"determines",
"if",
"two",
"signals",
"can",
"be",
"considered",
"equal",
"."
] | a3cf163ddfe77888ddefde77417f2ea192c05cc8 | https://github.com/LittleHelicase/frequencyjs/blob/a3cf163ddfe77888ddefde77417f2ea192c05cc8/lib/processing.js#L43-L54 | train | |
hectorcorrea/mongoConnect | index.js | function(callback) {
log('Connecting...');
MongoClient.connect(dbUrl, dbOptions, function(err, dbConn) {
if(err) {
log('Cannot connect: ' + err);
callback(err);
return;
}
log('Connected!');
isConnected = true;
db = dbConn;
// http://stackoverflow.com/a/18715857... | javascript | function(callback) {
log('Connecting...');
MongoClient.connect(dbUrl, dbOptions, function(err, dbConn) {
if(err) {
log('Cannot connect: ' + err);
callback(err);
return;
}
log('Connected!');
isConnected = true;
db = dbConn;
// http://stackoverflow.com/a/18715857... | [
"function",
"(",
"callback",
")",
"{",
"log",
"(",
"'Connecting...'",
")",
";",
"MongoClient",
".",
"connect",
"(",
"dbUrl",
",",
"dbOptions",
",",
"function",
"(",
"err",
",",
"dbConn",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
"(",
"'Cannot connec... | by default don't log | [
"by",
"default",
"don",
"t",
"log"
] | e96310f2910d27d3f813d4d0249d47a8456167ac | https://github.com/hectorcorrea/mongoConnect/blob/e96310f2910d27d3f813d4d0249d47a8456167ac/index.js#L23-L49 | train | |
jimbojw/node-red-contrib-json | util.js | function(node, msg) {
if (node.complete === "complete") {
return msg;
}
try {
return (node.prop||"payload").split(".").reduce(function (obj, i) {
return obj[i];
}, msg);
} catch (err) {
return; // undefined
}
} | javascript | function(node, msg) {
if (node.complete === "complete") {
return msg;
}
try {
return (node.prop||"payload").split(".").reduce(function (obj, i) {
return obj[i];
}, msg);
} catch (err) {
return; // undefined
}
} | [
"function",
"(",
"node",
",",
"msg",
")",
"{",
"if",
"(",
"node",
".",
"complete",
"===",
"\"complete\"",
")",
"{",
"return",
"msg",
";",
"}",
"try",
"{",
"return",
"(",
"node",
".",
"prop",
"||",
"\"payload\"",
")",
".",
"split",
"(",
"\".\"",
")"... | given a node and a message, extract the incoming object | [
"given",
"a",
"node",
"and",
"a",
"message",
"extract",
"the",
"incoming",
"object"
] | 2097e296d4024802d24344d83305886fb1f322ed | https://github.com/jimbojw/node-red-contrib-json/blob/2097e296d4024802d24344d83305886fb1f322ed/util.js#L21-L32 | train | |
cognitom/riot-mixin-pack | dist/riot-mixin-pack.amd.js | hook | function hook(p, key) {
var h = function h(e) {
// update only when the argument is an Event object
if (e && e instanceof Event) {
// suppress updating on the inherit tag
e.preventUpdate = true;
// call original method
p[key](e);
// update automatically
p.... | javascript | function hook(p, key) {
var h = function h(e) {
// update only when the argument is an Event object
if (e && e instanceof Event) {
// suppress updating on the inherit tag
e.preventUpdate = true;
// call original method
p[key](e);
// update automatically
p.... | [
"function",
"hook",
"(",
"p",
",",
"key",
")",
"{",
"var",
"h",
"=",
"function",
"h",
"(",
"e",
")",
"{",
"// update only when the argument is an Event object",
"if",
"(",
"e",
"&&",
"e",
"instanceof",
"Event",
")",
"{",
"// suppress updating on the inherit tag"... | Call original method and update automatically | [
"Call",
"original",
"method",
"and",
"update",
"automatically"
] | 903da842cccbccb853dc0c4f952145af35416c17 | https://github.com/cognitom/riot-mixin-pack/blob/903da842cccbccb853dc0c4f952145af35416c17/dist/riot-mixin-pack.amd.js#L56-L72 | train |
cognitom/riot-mixin-pack | dist/riot-mixin-pack.amd.js | init | function init() {
var _this = this;
/** Store the keys originally belonging to the tag */
this.one('update', function () {
_this._ownPropKeys = getAllPropertyNames(_this);
_this._ownOptsKeys = getAllPropertyNames(_this.opts);
});
/** Inherit the properties from parents on ... | javascript | function init() {
var _this = this;
/** Store the keys originally belonging to the tag */
this.one('update', function () {
_this._ownPropKeys = getAllPropertyNames(_this);
_this._ownOptsKeys = getAllPropertyNames(_this.opts);
});
/** Inherit the properties from parents on ... | [
"function",
"init",
"(",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"/** Store the keys originally belonging to the tag */",
"this",
".",
"one",
"(",
"'update'",
",",
"function",
"(",
")",
"{",
"_this",
".",
"_ownPropKeys",
"=",
"getAllPropertyNames",
"(",
"_th... | Inject properties from parents | [
"Inject",
"properties",
"from",
"parents"
] | 903da842cccbccb853dc0c4f952145af35416c17 | https://github.com/cognitom/riot-mixin-pack/blob/903da842cccbccb853dc0c4f952145af35416c17/dist/riot-mixin-pack.amd.js#L78-L105 | train |
cognitom/riot-mixin-pack | dist/riot-mixin-pack.amd.js | querySelector | function querySelector(sel, flag) {
var node = this.root.querySelector(normalize(sel));
return !flag ? node : node._tag || undefined;
} | javascript | function querySelector(sel, flag) {
var node = this.root.querySelector(normalize(sel));
return !flag ? node : node._tag || undefined;
} | [
"function",
"querySelector",
"(",
"sel",
",",
"flag",
")",
"{",
"var",
"node",
"=",
"this",
".",
"root",
".",
"querySelector",
"(",
"normalize",
"(",
"sel",
")",
")",
";",
"return",
"!",
"flag",
"?",
"node",
":",
"node",
".",
"_tag",
"||",
"undefined... | Gets Node or Tag by CSS selector
@param { string } sel - CSS selector
@param { boolean } flag - true for Tag | [
"Gets",
"Node",
"or",
"Tag",
"by",
"CSS",
"selector"
] | 903da842cccbccb853dc0c4f952145af35416c17 | https://github.com/cognitom/riot-mixin-pack/blob/903da842cccbccb853dc0c4f952145af35416c17/dist/riot-mixin-pack.amd.js#L125-L128 | train |
cognitom/riot-mixin-pack | dist/riot-mixin-pack.amd.js | querySelectorAll | function querySelectorAll(sel, flag) {
var nodes = this.root.querySelectorAll(normalize(sel));
return !flag ? nodes : Array.prototype.map.call(nodes, function (node) {
return node._tag || undefined;
});
} | javascript | function querySelectorAll(sel, flag) {
var nodes = this.root.querySelectorAll(normalize(sel));
return !flag ? nodes : Array.prototype.map.call(nodes, function (node) {
return node._tag || undefined;
});
} | [
"function",
"querySelectorAll",
"(",
"sel",
",",
"flag",
")",
"{",
"var",
"nodes",
"=",
"this",
".",
"root",
".",
"querySelectorAll",
"(",
"normalize",
"(",
"sel",
")",
")",
";",
"return",
"!",
"flag",
"?",
"nodes",
":",
"Array",
".",
"prototype",
".",... | Gets Nodes or Tags by CSS selector
@param { string } sel - CSS selector
@param { boolean } flag - true for Tag | [
"Gets",
"Nodes",
"or",
"Tags",
"by",
"CSS",
"selector"
] | 903da842cccbccb853dc0c4f952145af35416c17 | https://github.com/cognitom/riot-mixin-pack/blob/903da842cccbccb853dc0c4f952145af35416c17/dist/riot-mixin-pack.amd.js#L135-L140 | train |
jldec/pub-pkg-editor | client/editor-ui.js | fragmentClick | function fragmentClick(e) {
var el = e.target;
var href;
while (el && el.nodeName !== 'HTML' && !el.getAttribute('data-render-html')) { el = el.parentNode };
if (el && (href = el.getAttribute('data-render-html'))) {
bindEditor(generator.fragment$[href]);
e.preventDefault(); // will also stop... | javascript | function fragmentClick(e) {
var el = e.target;
var href;
while (el && el.nodeName !== 'HTML' && !el.getAttribute('data-render-html')) { el = el.parentNode };
if (el && (href = el.getAttribute('data-render-html'))) {
bindEditor(generator.fragment$[href]);
e.preventDefault(); // will also stop... | [
"function",
"fragmentClick",
"(",
"e",
")",
"{",
"var",
"el",
"=",
"e",
".",
"target",
";",
"var",
"href",
";",
"while",
"(",
"el",
"&&",
"el",
".",
"nodeName",
"!==",
"'HTML'",
"&&",
"!",
"el",
".",
"getAttribute",
"(",
"'data-render-html'",
")",
")... | fragment click handler | [
"fragment",
"click",
"handler"
] | db148d04eeaf49e3278240fcb96bf4d9055f584b | https://github.com/jldec/pub-pkg-editor/blob/db148d04eeaf49e3278240fcb96bf4d9055f584b/client/editor-ui.js#L149-L157 | train |
jldec/pub-pkg-editor | client/editor-ui.js | bindEditor | function bindEditor(fragment) {
saveBreakHold();
if (fragment) {
editor.$name.text(fragment._href);
if (fragment._holdUpdates) {
editText(fragment._holdText);
}
else {
editText(fragment._hdr + fragment._txt);
}
editor.binding = fragment._href;
}
else {... | javascript | function bindEditor(fragment) {
saveBreakHold();
if (fragment) {
editor.$name.text(fragment._href);
if (fragment._holdUpdates) {
editText(fragment._holdText);
}
else {
editText(fragment._hdr + fragment._txt);
}
editor.binding = fragment._href;
}
else {... | [
"function",
"bindEditor",
"(",
"fragment",
")",
"{",
"saveBreakHold",
"(",
")",
";",
"if",
"(",
"fragment",
")",
"{",
"editor",
".",
"$name",
".",
"text",
"(",
"fragment",
".",
"_href",
")",
";",
"if",
"(",
"fragment",
".",
"_holdUpdates",
")",
"{",
... | change editingHref to a different fragment or page | [
"change",
"editingHref",
"to",
"a",
"different",
"fragment",
"or",
"page"
] | db148d04eeaf49e3278240fcb96bf4d9055f584b | https://github.com/jldec/pub-pkg-editor/blob/db148d04eeaf49e3278240fcb96bf4d9055f584b/client/editor-ui.js#L173-L190 | train |
jldec/pub-pkg-editor | client/editor-ui.js | editorUpdate | function editorUpdate() {
if (editor.binding) {
if ('hold' === generator.clientUpdateFragmentText(editor.binding, editor.$edit.val())) {
editor.holding = true;
}
}
} | javascript | function editorUpdate() {
if (editor.binding) {
if ('hold' === generator.clientUpdateFragmentText(editor.binding, editor.$edit.val())) {
editor.holding = true;
}
}
} | [
"function",
"editorUpdate",
"(",
")",
"{",
"if",
"(",
"editor",
".",
"binding",
")",
"{",
"if",
"(",
"'hold'",
"===",
"generator",
".",
"clientUpdateFragmentText",
"(",
"editor",
".",
"binding",
",",
"editor",
".",
"$edit",
".",
"val",
"(",
")",
")",
"... | register updates from editor using editor.binding | [
"register",
"updates",
"from",
"editor",
"using",
"editor",
".",
"binding"
] | db148d04eeaf49e3278240fcb96bf4d9055f584b | https://github.com/jldec/pub-pkg-editor/blob/db148d04eeaf49e3278240fcb96bf4d9055f584b/client/editor-ui.js#L203-L209 | train |
jldec/pub-pkg-editor | client/editor-ui.js | saveBreakHold | function saveBreakHold() {
if (editor.binding && editor.holding) {
generator.clientUpdateFragmentText(editor.binding, editor.$edit.val(), true);
editor.holding = false;
}
} | javascript | function saveBreakHold() {
if (editor.binding && editor.holding) {
generator.clientUpdateFragmentText(editor.binding, editor.$edit.val(), true);
editor.holding = false;
}
} | [
"function",
"saveBreakHold",
"(",
")",
"{",
"if",
"(",
"editor",
".",
"binding",
"&&",
"editor",
".",
"holding",
")",
"{",
"generator",
".",
"clientUpdateFragmentText",
"(",
"editor",
".",
"binding",
",",
"editor",
".",
"$edit",
".",
"val",
"(",
")",
","... | save with breakHold - may result in modified href ==> loss of binding context? | [
"save",
"with",
"breakHold",
"-",
"may",
"result",
"in",
"modified",
"href",
"==",
">",
"loss",
"of",
"binding",
"context?"
] | db148d04eeaf49e3278240fcb96bf4d9055f584b | https://github.com/jldec/pub-pkg-editor/blob/db148d04eeaf49e3278240fcb96bf4d9055f584b/client/editor-ui.js#L212-L217 | train |
denar90/marionette-cli | lib/commands.js | function(type) {
//define if put type is present in config
if (config.moduleTypes.indexOf(type) > -1) {
config.moduleType = type;
fs.writeFile(path.resolve(__dirname, 'config.json'), JSON.stringify(config, null, 4), 'utf8', function (err) {
if (err) {
retu... | javascript | function(type) {
//define if put type is present in config
if (config.moduleTypes.indexOf(type) > -1) {
config.moduleType = type;
fs.writeFile(path.resolve(__dirname, 'config.json'), JSON.stringify(config, null, 4), 'utf8', function (err) {
if (err) {
retu... | [
"function",
"(",
"type",
")",
"{",
"//define if put type is present in config",
"if",
"(",
"config",
".",
"moduleTypes",
".",
"indexOf",
"(",
"type",
")",
">",
"-",
"1",
")",
"{",
"config",
".",
"moduleType",
"=",
"type",
";",
"fs",
".",
"writeFile",
"(",
... | Sets module type
@param {string} type | [
"Sets",
"module",
"type"
] | fde5934ba7369b0c3356864512efee8dc8242fff | https://github.com/denar90/marionette-cli/blob/fde5934ba7369b0c3356864512efee8dc8242fff/lib/commands.js#L13-L25 | train | |
denar90/marionette-cli | lib/commands.js | function(folder) {
var type = config.moduleType;
var appPath;
if (folder) {
if (path.isAbsolute(folder)) {
appPath = path.join(folder);
} else {
appPath = path.join(process.cwd(), folder);
}
} else {
appPath = path.join(process.cwd());
}
var appSrc = config.apps[type];
helpers.gitClone... | javascript | function(folder) {
var type = config.moduleType;
var appPath;
if (folder) {
if (path.isAbsolute(folder)) {
appPath = path.join(folder);
} else {
appPath = path.join(process.cwd(), folder);
}
} else {
appPath = path.join(process.cwd());
}
var appSrc = config.apps[type];
helpers.gitClone... | [
"function",
"(",
"folder",
")",
"{",
"var",
"type",
"=",
"config",
".",
"moduleType",
";",
"var",
"appPath",
";",
"if",
"(",
"folder",
")",
"{",
"if",
"(",
"path",
".",
"isAbsolute",
"(",
"folder",
")",
")",
"{",
"appPath",
"=",
"path",
".",
"join"... | Generates new app
@param {string} folder | [
"Generates",
"new",
"app"
] | fde5934ba7369b0c3356864512efee8dc8242fff | https://github.com/denar90/marionette-cli/blob/fde5934ba7369b0c3356864512efee8dc8242fff/lib/commands.js#L31-L45 | train | |
gsmcwhirter/node-zoneinfo | index.js | function (){
var offset = parseInt(self._utcoffset());
var minus = false;
if (offset < 0)
{
minus = true;
offset = -offset;
}
var minutes = offset % 60;
var hours = (offset - minutes) / 60;
o... | javascript | function (){
var offset = parseInt(self._utcoffset());
var minus = false;
if (offset < 0)
{
minus = true;
offset = -offset;
}
var minutes = offset % 60;
var hours = (offset - minutes) / 60;
o... | [
"function",
"(",
")",
"{",
"var",
"offset",
"=",
"parseInt",
"(",
"self",
".",
"_utcoffset",
"(",
")",
")",
";",
"var",
"minus",
"=",
"false",
";",
"if",
"(",
"offset",
"<",
"0",
")",
"{",
"minus",
"=",
"true",
";",
"offset",
"=",
"-",
"offset",
... | O UTC offset | [
"O",
"UTC",
"offset"
] | 2c350afa97ef6854d42f78f954ba3ab402808028 | https://github.com/gsmcwhirter/node-zoneinfo/blob/2c350afa97ef6854d42f78f954ba3ab402808028/index.js#L425-L441 | train | |
AndiDittrich/Node.fs-magic | lib/isFileOfType.js | isFileOfType | async function isFileOfType(filename, condition){
try{
// get stats
const stats = await _fs.stat(filename);
// is directory ?
return condition(stats);
}catch(e){
// file not found error ?
if (e.code === 'ENOENT'){
return false;
}else{
... | javascript | async function isFileOfType(filename, condition){
try{
// get stats
const stats = await _fs.stat(filename);
// is directory ?
return condition(stats);
}catch(e){
// file not found error ?
if (e.code === 'ENOENT'){
return false;
}else{
... | [
"async",
"function",
"isFileOfType",
"(",
"filename",
",",
"condition",
")",
"{",
"try",
"{",
"// get stats",
"const",
"stats",
"=",
"await",
"_fs",
".",
"stat",
"(",
"filename",
")",
";",
"// is directory ?",
"return",
"condition",
"(",
"stats",
")",
";",
... | check if node is of specific type | [
"check",
"if",
"node",
"is",
"of",
"specific",
"type"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/isFileOfType.js#L4-L19 | train |
AndiDittrich/Node.fs-magic | lib/bulkCopy.js | bulkCopy | async function bulkCopy(srcset, createDestinationDirs=true, defaultFilemode=0o750, defaultDirmode=0o777){
// create destination directories in advance ?
if (createDestinationDirs === true){
// get unique paths from filelist
const dstDirs = Array.from(new Set(srcset.map((set) => _path.dirname(set... | javascript | async function bulkCopy(srcset, createDestinationDirs=true, defaultFilemode=0o750, defaultDirmode=0o777){
// create destination directories in advance ?
if (createDestinationDirs === true){
// get unique paths from filelist
const dstDirs = Array.from(new Set(srcset.map((set) => _path.dirname(set... | [
"async",
"function",
"bulkCopy",
"(",
"srcset",
",",
"createDestinationDirs",
"=",
"true",
",",
"defaultFilemode",
"=",
"0o750",
",",
"defaultDirmode",
"=",
"0o777",
")",
"{",
"// create destination directories in advance ?",
"if",
"(",
"createDestinationDirs",
"===",
... | copy a set of files simultanous | [
"copy",
"a",
"set",
"of",
"files",
"simultanous"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/bulkCopy.js#L7-L24 | train |
alekseykulikov/storage-emitter | src/index.js | isPrivateBrowsingMode | function isPrivateBrowsingMode () {
try {
localStorage.setItem(TEST_KEY, '1')
localStorage.removeItem(TEST_KEY)
return false
} catch (error) {
return true
}
} | javascript | function isPrivateBrowsingMode () {
try {
localStorage.setItem(TEST_KEY, '1')
localStorage.removeItem(TEST_KEY)
return false
} catch (error) {
return true
}
} | [
"function",
"isPrivateBrowsingMode",
"(",
")",
"{",
"try",
"{",
"localStorage",
".",
"setItem",
"(",
"TEST_KEY",
",",
"'1'",
")",
"localStorage",
".",
"removeItem",
"(",
"TEST_KEY",
")",
"return",
"false",
"}",
"catch",
"(",
"error",
")",
"{",
"return",
"t... | Check browser is in private browsing mode or not
@return {Boolean} | [
"Check",
"browser",
"is",
"in",
"private",
"browsing",
"mode",
"or",
"not"
] | 49c00eb546a25787dfcfd9485e02273868b14d52 | https://github.com/alekseykulikov/storage-emitter/blob/49c00eb546a25787dfcfd9485e02273868b14d52/src/index.js#L68-L76 | train |
SerkanSipahi/app-decorators | src/helpers/extract-dom-properties.js | extractDomProperties | function extractDomProperties(domNode, regex, removeDomAttributes = false) {
if(regex && classof(regex) !== 'RegExp'){
throw Error('Second argument is passed but it must be a Regular-Expression');
}
let domViewAttributes = {};
let toBeRemovedAttributes = [];
for(let key in domNode.attributes) {
if(!domNode... | javascript | function extractDomProperties(domNode, regex, removeDomAttributes = false) {
if(regex && classof(regex) !== 'RegExp'){
throw Error('Second argument is passed but it must be a Regular-Expression');
}
let domViewAttributes = {};
let toBeRemovedAttributes = [];
for(let key in domNode.attributes) {
if(!domNode... | [
"function",
"extractDomProperties",
"(",
"domNode",
",",
"regex",
",",
"removeDomAttributes",
"=",
"false",
")",
"{",
"if",
"(",
"regex",
"&&",
"classof",
"(",
"regex",
")",
"!==",
"'RegExp'",
")",
"{",
"throw",
"Error",
"(",
"'Second argument is passed but it m... | Extract domnode attributes
@param {HTMLElement} domNode
@param {Regex} expression
@param {Boolean} removeDomAttributes
@return {Object} | [
"Extract",
"domnode",
"attributes"
] | 15f046b1bbe56af0d45b4a1b45a6a4c5689e4763 | https://github.com/SerkanSipahi/app-decorators/blob/15f046b1bbe56af0d45b4a1b45a6a4c5689e4763/src/helpers/extract-dom-properties.js#L12-L50 | train |
Zefau/nello.io | lib/nello.js | Nello | function Nello(token)
{
if (!(this instanceof Nello))
return new Nello(token);
_events.call(this);
this.token = token;
if (!this.token)
throw new Error('Please check the arguments!');
} | javascript | function Nello(token)
{
if (!(this instanceof Nello))
return new Nello(token);
_events.call(this);
this.token = token;
if (!this.token)
throw new Error('Please check the arguments!');
} | [
"function",
"Nello",
"(",
"token",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Nello",
")",
")",
"return",
"new",
"Nello",
"(",
"token",
")",
";",
"_events",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"token",
"=",
"token",
";",
"... | The constructor for a connection to a nello.
@class Nello
@param {String} token Token for authentication
@returns {Nello}
@constructor | [
"The",
"constructor",
"for",
"a",
"connection",
"to",
"a",
"nello",
"."
] | 5a2b2cc9b47ffe700c203d3a38435d94e532d8ec | https://github.com/Zefau/nello.io/blob/5a2b2cc9b47ffe700c203d3a38435d94e532d8ec/lib/nello.js#L18-L28 | train |
pichfl/onoff-rotary | index.js | RotaryEncoder | function RotaryEncoder(pinA, pinB) {
this.gpioA = new Gpio(pinA, 'in', 'both');
this.gpioB = new Gpio(pinB, 'in', 'both');
this.a = 2;
this.b = 2;
this.gpioA.watch((err, value) => {
if (err) {
this.emit('error', err);
return;
}
this.a = value;
});
this.gpioB.watch((err, value) => {
if (err) {
... | javascript | function RotaryEncoder(pinA, pinB) {
this.gpioA = new Gpio(pinA, 'in', 'both');
this.gpioB = new Gpio(pinB, 'in', 'both');
this.a = 2;
this.b = 2;
this.gpioA.watch((err, value) => {
if (err) {
this.emit('error', err);
return;
}
this.a = value;
});
this.gpioB.watch((err, value) => {
if (err) {
... | [
"function",
"RotaryEncoder",
"(",
"pinA",
",",
"pinB",
")",
"{",
"this",
".",
"gpioA",
"=",
"new",
"Gpio",
"(",
"pinA",
",",
"'in'",
",",
"'both'",
")",
";",
"this",
".",
"gpioB",
"=",
"new",
"Gpio",
"(",
"pinB",
",",
"'in'",
",",
"'both'",
")",
... | Creates a new Rotary Encoder using two GPIO pins
Expects the pins to be configured as pull-up
@param pinA GPIO # of the first pin
@param pinB GPIO # of the second pin
@returns EventEmitter | [
"Creates",
"a",
"new",
"Rotary",
"Encoder",
"using",
"two",
"GPIO",
"pins",
"Expects",
"the",
"pins",
"to",
"be",
"configured",
"as",
"pull",
"-",
"up"
] | 339712696432b80274fb76aec557fced4eb56080 | https://github.com/pichfl/onoff-rotary/blob/339712696432b80274fb76aec557fced4eb56080/index.js#L13-L41 | train |
cognitom/felt | lib/handler.js | serve | function serve(res, file, maxAge) {
log.debug(`Serving: ${ file }`)
res.status(200)
.set('Cache-Control', `max-age=${ maxAge }`)
.sendFile(file, err => {
if (err) {
log.error(err)
res.status(err.status).end()
return
}
})
} | javascript | function serve(res, file, maxAge) {
log.debug(`Serving: ${ file }`)
res.status(200)
.set('Cache-Control', `max-age=${ maxAge }`)
.sendFile(file, err => {
if (err) {
log.error(err)
res.status(err.status).end()
return
}
})
} | [
"function",
"serve",
"(",
"res",
",",
"file",
",",
"maxAge",
")",
"{",
"log",
".",
"debug",
"(",
"`",
"${",
"file",
"}",
"`",
")",
"res",
".",
"status",
"(",
"200",
")",
".",
"set",
"(",
"'Cache-Control'",
",",
"`",
"${",
"maxAge",
"}",
"`",
")... | serves a cache file | [
"serves",
"a",
"cache",
"file"
] | e97218aef9876ebdb2e6047138afe64ed37a4c83 | https://github.com/cognitom/felt/blob/e97218aef9876ebdb2e6047138afe64ed37a4c83/lib/handler.js#L15-L26 | train |
cognitom/felt | lib/handler.js | find | function find(pathname, patterns) {
for (const entry of patterns)
if (minimatch(pathname, entry.pattern))
return entry.handler
return null
} | javascript | function find(pathname, patterns) {
for (const entry of patterns)
if (minimatch(pathname, entry.pattern))
return entry.handler
return null
} | [
"function",
"find",
"(",
"pathname",
",",
"patterns",
")",
"{",
"for",
"(",
"const",
"entry",
"of",
"patterns",
")",
"if",
"(",
"minimatch",
"(",
"pathname",
",",
"entry",
".",
"pattern",
")",
")",
"return",
"entry",
".",
"handler",
"return",
"null",
"... | finds a handler matched with pathname | [
"finds",
"a",
"handler",
"matched",
"with",
"pathname"
] | e97218aef9876ebdb2e6047138afe64ed37a4c83 | https://github.com/cognitom/felt/blob/e97218aef9876ebdb2e6047138afe64ed37a4c83/lib/handler.js#L31-L36 | train |
AndiDittrich/Node.fs-magic | lib/FileInputStream.js | FileInputStream | function FileInputStream(src){
// wrap into Promise
return new Promise(function(resolve, reject){
// open read stream
const istream = _fs.createReadStream(src);
istream.on('error', reject);
istream.on('open', function(){
resolve(istream);
});
});
} | javascript | function FileInputStream(src){
// wrap into Promise
return new Promise(function(resolve, reject){
// open read stream
const istream = _fs.createReadStream(src);
istream.on('error', reject);
istream.on('open', function(){
resolve(istream);
});
});
} | [
"function",
"FileInputStream",
"(",
"src",
")",
"{",
"// wrap into Promise",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// open read stream",
"const",
"istream",
"=",
"_fs",
".",
"createReadStream",
"(",
"src",
")",
... | open read stream | [
"open",
"read",
"stream"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/FileInputStream.js#L4-L15 | train |
Zefau/nello.io | lib/auth.js | Auth | function Auth(clientId, clientSecret)
{
if (!(this instanceof Auth))
return new Auth(clientId, clientSecret);
this.clientId = clientId;
this.clientSecret = clientSecret;
if (!this.clientId || !this.clientSecret)
throw new Error('No Client ID / Client Secret provided!');
} | javascript | function Auth(clientId, clientSecret)
{
if (!(this instanceof Auth))
return new Auth(clientId, clientSecret);
this.clientId = clientId;
this.clientSecret = clientSecret;
if (!this.clientId || !this.clientSecret)
throw new Error('No Client ID / Client Secret provided!');
} | [
"function",
"Auth",
"(",
"clientId",
",",
"clientSecret",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Auth",
")",
")",
"return",
"new",
"Auth",
"(",
"clientId",
",",
"clientSecret",
")",
";",
"this",
".",
"clientId",
"=",
"clientId",
";",
"th... | The constructor for the authentication to a nello.
@class Auth
@param {String} clientId Client ID used for authentication
@param {String} clientSecret Client Secret used for authentication
@returns {Auth}
@constructor
@see https://nelloauth.docs.apiary.io/#reference/0/token/create-a-new-token-client-crede... | [
"The",
"constructor",
"for",
"the",
"authentication",
"to",
"a",
"nello",
"."
] | 5a2b2cc9b47ffe700c203d3a38435d94e532d8ec | https://github.com/Zefau/nello.io/blob/5a2b2cc9b47ffe700c203d3a38435d94e532d8ec/lib/auth.js#L17-L27 | train |
AndiDittrich/Node.fs-magic | lib/isSymlink.js | isSymlink | async function isSymlink(filename){
try{
// get stats
const stats = await _fs.lstat(filename);
// is symlink ?
return stats.isSymbolicLink();
}catch(e){
// file not found error ?
if (e.code === 'ENOENT'){
return false;
}else{
throw... | javascript | async function isSymlink(filename){
try{
// get stats
const stats = await _fs.lstat(filename);
// is symlink ?
return stats.isSymbolicLink();
}catch(e){
// file not found error ?
if (e.code === 'ENOENT'){
return false;
}else{
throw... | [
"async",
"function",
"isSymlink",
"(",
"filename",
")",
"{",
"try",
"{",
"// get stats",
"const",
"stats",
"=",
"await",
"_fs",
".",
"lstat",
"(",
"filename",
")",
";",
"// is symlink ?",
"return",
"stats",
".",
"isSymbolicLink",
"(",
")",
";",
"}",
"catch... | check if node is a symlink | [
"check",
"if",
"node",
"is",
"a",
"symlink"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/isSymlink.js#L4-L19 | train |
denar90/marionette-cli | lib/helpers.js | function(file, targetPath) {
rigger(
file,
{ output: targetPath},
function(error, content) {
if (error) {
console.log(error);
return;
}
fs.writeFile(targetPath, content, 'utf8');
}
);
} | javascript | function(file, targetPath) {
rigger(
file,
{ output: targetPath},
function(error, content) {
if (error) {
console.log(error);
return;
}
fs.writeFile(targetPath, content, 'utf8');
}
);
} | [
"function",
"(",
"file",
",",
"targetPath",
")",
"{",
"rigger",
"(",
"file",
",",
"{",
"output",
":",
"targetPath",
"}",
",",
"function",
"(",
"error",
",",
"content",
")",
"{",
"if",
"(",
"error",
")",
"{",
"console",
".",
"log",
"(",
"error",
")"... | Creates new file including sources from original one
@param {string} file File
@param {string} targetPath New file name | [
"Creates",
"new",
"file",
"including",
"sources",
"from",
"original",
"one"
] | fde5934ba7369b0c3356864512efee8dc8242fff | https://github.com/denar90/marionette-cli/blob/fde5934ba7369b0c3356864512efee8dc8242fff/lib/helpers.js#L11-L23 | train | |
glennjones/text-autolinker | lib/handlers.js | renderJSON | function renderJSON( request, reply, err, result ){
if(err){
if(err.code === 404){
reply(new hapi.error.notFound(err.message));
}else{
reply(new hapi.error.badRequest(err.message));
}
}else{
reply(result).type('application/json; charset=utf-8');
}
} | javascript | function renderJSON( request, reply, err, result ){
if(err){
if(err.code === 404){
reply(new hapi.error.notFound(err.message));
}else{
reply(new hapi.error.badRequest(err.message));
}
}else{
reply(result).type('application/json; charset=utf-8');
}
} | [
"function",
"renderJSON",
"(",
"request",
",",
"reply",
",",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"code",
"===",
"404",
")",
"{",
"reply",
"(",
"new",
"hapi",
".",
"error",
".",
"notFound",
"(",
"err"... | render json out to http stream | [
"render",
"json",
"out",
"to",
"http",
"stream"
] | 1c873d4779d399bf7f2cb2ba72bccf647af659f0 | https://github.com/glennjones/text-autolinker/blob/1c873d4779d399bf7f2cb2ba72bccf647af659f0/lib/handlers.js#L52-L62 | train |
gluwer/azure-queue-node | index.js | _initDefaultConnection | function _initDefaultConnection() {
if ('CLOUD_STORAGE_ACCOUNT' in process.env) {
var accountSettings = utils.parseAccountString(process.env.CLOUD_STORAGE_ACCOUNT);
if (accountSettings !== null) {
_defaultClientSetting = _.defaults(_defaultClientSetting, accountSettings);
}
}
} | javascript | function _initDefaultConnection() {
if ('CLOUD_STORAGE_ACCOUNT' in process.env) {
var accountSettings = utils.parseAccountString(process.env.CLOUD_STORAGE_ACCOUNT);
if (accountSettings !== null) {
_defaultClientSetting = _.defaults(_defaultClientSetting, accountSettings);
}
}
} | [
"function",
"_initDefaultConnection",
"(",
")",
"{",
"if",
"(",
"'CLOUD_STORAGE_ACCOUNT'",
"in",
"process",
".",
"env",
")",
"{",
"var",
"accountSettings",
"=",
"utils",
".",
"parseAccountString",
"(",
"process",
".",
"env",
".",
"CLOUD_STORAGE_ACCOUNT",
")",
";... | initializes default client using default settings and environment variable CLOUD_STORAGE_ACCOUNT | [
"initializes",
"default",
"client",
"using",
"default",
"settings",
"and",
"environment",
"variable",
"CLOUD_STORAGE_ACCOUNT"
] | d3c3c8415fd65c8ad30779aba3c8c9a74cf0f206 | https://github.com/gluwer/azure-queue-node/blob/d3c3c8415fd65c8ad30779aba3c8c9a74cf0f206/index.js#L17-L24 | train |
ablage/perceptualdiff | lib/lpyramid.js | function (a, b) {
var Kernel = [0.05, 0.25, 0.4, 0.25, 0.05];
var width = this.getWidth();
var weight = this.getWeight();
//#pragma omp parallel for
for (var y = 0; y < weight; y++) {
for (var x = 0; x < width; x++) {
var index = y * width + x;
a[index] = 0;
for (var i = -2; i <= 2; i++) {
... | javascript | function (a, b) {
var Kernel = [0.05, 0.25, 0.4, 0.25, 0.05];
var width = this.getWidth();
var weight = this.getWeight();
//#pragma omp parallel for
for (var y = 0; y < weight; y++) {
for (var x = 0; x < width; x++) {
var index = y * width + x;
a[index] = 0;
for (var i = -2; i <= 2; i++) {
... | [
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"Kernel",
"=",
"[",
"0.05",
",",
"0.25",
",",
"0.4",
",",
"0.25",
",",
"0.05",
"]",
";",
"var",
"width",
"=",
"this",
".",
"getWidth",
"(",
")",
";",
"var",
"weight",
"=",
"this",
".",
"getWeight... | Convolves image b with the filter kernel and stores it in a. | [
"Convolves",
"image",
"b",
"with",
"the",
"filter",
"kernel",
"and",
"stores",
"it",
"in",
"a",
"."
] | d91b1a7d2811fa78a6b4fe633b86ca6525a11314 | https://github.com/ablage/perceptualdiff/blob/d91b1a7d2811fa78a6b4fe633b86ca6525a11314/lib/lpyramid.js#L51-L80 | train | |
segmentio/canonical | lib/index.js | canonical | function canonical() {
var tags = document.getElementsByTagName('link');
// eslint-disable-next-line no-cond-assign
for (var i = 0, tag; tag = tags[i]; i++) {
if (tag.getAttribute('rel') === 'canonical') {
return tag.getAttribute('href');
}
}
} | javascript | function canonical() {
var tags = document.getElementsByTagName('link');
// eslint-disable-next-line no-cond-assign
for (var i = 0, tag; tag = tags[i]; i++) {
if (tag.getAttribute('rel') === 'canonical') {
return tag.getAttribute('href');
}
}
} | [
"function",
"canonical",
"(",
")",
"{",
"var",
"tags",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'link'",
")",
";",
"// eslint-disable-next-line no-cond-assign",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"tag",
";",
"tag",
"=",
"tags",
"[",
"i",
"]"... | Get the current page's canonical URL.
@return {string|undefined} | [
"Get",
"the",
"current",
"page",
"s",
"canonical",
"URL",
"."
] | a5c3817a7bb60f04540883830b4e2db01c747a52 | https://github.com/segmentio/canonical/blob/a5c3817a7bb60f04540883830b4e2db01c747a52/lib/index.js#L8-L16 | train |
doowb/computed-property | index.js | hasChanged | function hasChanged(depValues, current, dependencies) {
var len = dependencies.length;
var i = 0;
var result = false;
while (len--) {
var dep = dependencies[i++];
var value = get(current, dep);
if (get(depValues, dep) !== value) {
result = true;
set(depValues, dep, value);
}
}
re... | javascript | function hasChanged(depValues, current, dependencies) {
var len = dependencies.length;
var i = 0;
var result = false;
while (len--) {
var dep = dependencies[i++];
var value = get(current, dep);
if (get(depValues, dep) !== value) {
result = true;
set(depValues, dep, value);
}
}
re... | [
"function",
"hasChanged",
"(",
"depValues",
",",
"current",
",",
"dependencies",
")",
"{",
"var",
"len",
"=",
"dependencies",
".",
"length",
";",
"var",
"i",
"=",
"0",
";",
"var",
"result",
"=",
"false",
";",
"while",
"(",
"len",
"--",
")",
"{",
"var... | Determine if dependencies have changed.
@param {Object} `depValues` Stored dependency values
@param {Object} `current` Current object to check the dependencies.
@param {Array} `dependencies` Dependencies to check.
@return {Boolean} Did any dependencies change?
@api private | [
"Determine",
"if",
"dependencies",
"have",
"changed",
"."
] | 011af1fa09456b3de356d0e6880fb5ad606239a7 | https://github.com/doowb/computed-property/blob/011af1fa09456b3de356d0e6880fb5ad606239a7/index.js#L24-L37 | train |
doowb/computed-property | index.js | initWatch | function initWatch(obj, depValues, dependencies) {
var len = dependencies.length;
if (len === 0) {
return false;
}
var i = 0;
while (len--) {
var dep = dependencies[i++];
var value = clone(get(obj, dep));
set(depValues, dep, value);
}
return true;
} | javascript | function initWatch(obj, depValues, dependencies) {
var len = dependencies.length;
if (len === 0) {
return false;
}
var i = 0;
while (len--) {
var dep = dependencies[i++];
var value = clone(get(obj, dep));
set(depValues, dep, value);
}
return true;
} | [
"function",
"initWatch",
"(",
"obj",
",",
"depValues",
",",
"dependencies",
")",
"{",
"var",
"len",
"=",
"dependencies",
".",
"length",
";",
"if",
"(",
"len",
"===",
"0",
")",
"{",
"return",
"false",
";",
"}",
"var",
"i",
"=",
"0",
";",
"while",
"(... | Setup the storage object for watching dependencies.
@param {Object} `obj` Object property is being added to.
@param {Object} `depValues` Object used for storage.
@param {Array} `dependencies` Dependencies to watch
@return {Boolean} Return if watching or not.
@api private | [
"Setup",
"the",
"storage",
"object",
"for",
"watching",
"dependencies",
"."
] | 011af1fa09456b3de356d0e6880fb5ad606239a7 | https://github.com/doowb/computed-property/blob/011af1fa09456b3de356d0e6880fb5ad606239a7/index.js#L49-L61 | train |
hendrichbenjamin/mongoose-timestamp-plugin | lib/timestamp.js | timestamp | function timestamp(schema, options) {
options = options || {};
// Set defaults
options = Object.assign({
createdName: 'createdAt',
updatedName: 'updatedAt',
disableCreated: false,
disableUpdated: false
}, options);
// Add fields if not disabled
if (!options.disableCreated) {
addSchemaField(schema, opti... | javascript | function timestamp(schema, options) {
options = options || {};
// Set defaults
options = Object.assign({
createdName: 'createdAt',
updatedName: 'updatedAt',
disableCreated: false,
disableUpdated: false
}, options);
// Add fields if not disabled
if (!options.disableCreated) {
addSchemaField(schema, opti... | [
"function",
"timestamp",
"(",
"schema",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// Set defaults",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"createdName",
":",
"'createdAt'",
",",
"updatedName",
":",
"'updatedAt'",... | Mongoose plugin function which adds fields to track creation and modification dates
@param {Schema} schema the mongoose schema
@param {object} [options] the options object
@this mongoose.Schema
@access public
@returns {undefined} | [
"Mongoose",
"plugin",
"function",
"which",
"adds",
"fields",
"to",
"track",
"creation",
"and",
"modification",
"dates"
] | 8a0a21b01287d88988717e1452e83012c2201756 | https://github.com/hendrichbenjamin/mongoose-timestamp-plugin/blob/8a0a21b01287d88988717e1452e83012c2201756/lib/timestamp.js#L30-L70 | train |
hendrichbenjamin/mongoose-timestamp-plugin | lib/timestamp.js | preSave | function preSave(next) {
const _ref = this.get(options.createdName);
if (!options.disableUpdated) {
this[options.updatedName] = new Date();
}
if (!options.disableCreated && (_ref === undefined || _ref === null)) {
this[options.createdName] = new Date();
}
next();
} | javascript | function preSave(next) {
const _ref = this.get(options.createdName);
if (!options.disableUpdated) {
this[options.updatedName] = new Date();
}
if (!options.disableCreated && (_ref === undefined || _ref === null)) {
this[options.createdName] = new Date();
}
next();
} | [
"function",
"preSave",
"(",
"next",
")",
"{",
"const",
"_ref",
"=",
"this",
".",
"get",
"(",
"options",
".",
"createdName",
")",
";",
"if",
"(",
"!",
"options",
".",
"disableUpdated",
")",
"{",
"this",
"[",
"options",
".",
"updatedName",
"]",
"=",
"n... | Callback for the schema pre save
@this mongoose.Schema
@param {Function} next The next pre save callback in chain
@returns {undefined} | [
"Callback",
"for",
"the",
"schema",
"pre",
"save"
] | 8a0a21b01287d88988717e1452e83012c2201756 | https://github.com/hendrichbenjamin/mongoose-timestamp-plugin/blob/8a0a21b01287d88988717e1452e83012c2201756/lib/timestamp.js#L58-L69 | train |
ballantyne/node-paperclip | class.js | function(key, path, next) {
this.fileSystem.get(key, function(err, data) {
fs.writeFile(path, data, function(err) {
if (err) {
console.log(err);
}
next(err, data);
});
});
} | javascript | function(key, path, next) {
this.fileSystem.get(key, function(err, data) {
fs.writeFile(path, data, function(err) {
if (err) {
console.log(err);
}
next(err, data);
});
});
} | [
"function",
"(",
"key",
",",
"path",
",",
"next",
")",
"{",
"this",
".",
"fileSystem",
".",
"get",
"(",
"key",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"fs",
".",
"writeFile",
"(",
"path",
",",
"data",
",",
"function",
"(",
"err",
")",... | currently not used. was planning on using this function to download files from s3 to reprocess them if the sizes change, but I haven't rewritten that code yet. | [
"currently",
"not",
"used",
".",
"was",
"planning",
"on",
"using",
"this",
"function",
"to",
"download",
"files",
"from",
"s3",
"to",
"reprocess",
"them",
"if",
"the",
"sizes",
"change",
"but",
"I",
"haven",
"t",
"rewritten",
"that",
"code",
"yet",
"."
] | 632020a5f5a3724385aee92d089ef3b55f6e639d | https://github.com/ballantyne/node-paperclip/blob/632020a5f5a3724385aee92d089ef3b55f6e639d/class.js#L139-L148 | train | |
ballantyne/node-paperclip | class.js | function(next) {
var self = this;
var obj = {};
obj.path = path.join(os.tmpdir, randomstring.generate());
obj.original_name = self.document[self.has_attached_file].original_url.split('/').pop();
this.downloadUrl(self.document[self.has_attached_file].origi... | javascript | function(next) {
var self = this;
var obj = {};
obj.path = path.join(os.tmpdir, randomstring.generate());
obj.original_name = self.document[self.has_attached_file].original_url.split('/').pop();
this.downloadUrl(self.document[self.has_attached_file].origi... | [
"function",
"(",
"next",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"obj",
"=",
"{",
"}",
";",
"obj",
".",
"path",
"=",
"path",
".",
"join",
"(",
"os",
".",
"tmpdir",
",",
"randomstring",
".",
"generate",
"(",
")",
")",
";",
"obj",
".",
... | this is currently not used. It is to download a url that is saved to a model and download that file and prepare the parameters to save. I am not sure where the best place to put this code, I was thinking of adding it to the middleware. | [
"this",
"is",
"currently",
"not",
"used",
".",
"It",
"is",
"to",
"download",
"a",
"url",
"that",
"is",
"saved",
"to",
"a",
"model",
"and",
"download",
"that",
"file",
"and",
"prepare",
"the",
"parameters",
"to",
"save",
".",
"I",
"am",
"not",
"sure",
... | 632020a5f5a3724385aee92d089ef3b55f6e639d | https://github.com/ballantyne/node-paperclip/blob/632020a5f5a3724385aee92d089ef3b55f6e639d/class.js#L250-L265 | train | |
DoublePrecisionSoftware/jsontl | src/jsontl.js | function (data, trans, key) {
if (typeof data[key] !== "object") {
throw new SyntaxError('Cannot extend a scalar value. Transform: ' + util.getTransDescription(trans) + ' Data: ' + JSON.stringify(data));
}
for (var prop in trans) {
if (typeof data[prop] === "object") {
return extend(data[key], ... | javascript | function (data, trans, key) {
if (typeof data[key] !== "object") {
throw new SyntaxError('Cannot extend a scalar value. Transform: ' + util.getTransDescription(trans) + ' Data: ' + JSON.stringify(data));
}
for (var prop in trans) {
if (typeof data[prop] === "object") {
return extend(data[key], ... | [
"function",
"(",
"data",
",",
"trans",
",",
"key",
")",
"{",
"if",
"(",
"typeof",
"data",
"[",
"key",
"]",
"!==",
"\"object\"",
")",
"{",
"throw",
"new",
"SyntaxError",
"(",
"'Cannot extend a scalar value. Transform: '",
"+",
"util",
".",
"getTransDescription... | add the specified data to the object provided | [
"add",
"the",
"specified",
"data",
"to",
"the",
"object",
"provided"
] | 13f6c2e52e6cc177aeda39f19b442835798556ad | https://github.com/DoublePrecisionSoftware/jsontl/blob/13f6c2e52e6cc177aeda39f19b442835798556ad/src/jsontl.js#L117-L129 | train | |
DoublePrecisionSoftware/jsontl | src/jsontl.js | function (data, transform) {
if (typeof transform.jsontl !== "undefined") {
if (typeof transform.jsontl.transform !== "undefined") {
return locators.in(data, transform.jsontl.transform);
}
}
throw new Error("Tranform definition invalid");
} | javascript | function (data, transform) {
if (typeof transform.jsontl !== "undefined") {
if (typeof transform.jsontl.transform !== "undefined") {
return locators.in(data, transform.jsontl.transform);
}
}
throw new Error("Tranform definition invalid");
} | [
"function",
"(",
"data",
",",
"transform",
")",
"{",
"if",
"(",
"typeof",
"transform",
".",
"jsontl",
"!==",
"\"undefined\"",
")",
"{",
"if",
"(",
"typeof",
"transform",
".",
"jsontl",
".",
"transform",
"!==",
"\"undefined\"",
")",
"{",
"return",
"locators... | Perform the provided transform on the data
@param {Object} data Data to transform
@param {Object} trans Transform definition
@returns {Object} The transformed data | [
"Perform",
"the",
"provided",
"transform",
"on",
"the",
"data"
] | 13f6c2e52e6cc177aeda39f19b442835798556ad | https://github.com/DoublePrecisionSoftware/jsontl/blob/13f6c2e52e6cc177aeda39f19b442835798556ad/src/jsontl.js#L197-L204 | train | |
AndiDittrich/Node.fs-magic | lib/gunzip.js | gunzip | async function gunzip(input, dst){
// is input a filename or stream ?
if (typeof input === 'string'){
input = await _fileInputStream(input);
}
// decompress
const gzipStream = input.pipe(_zlib.createGunzip());
// write content to file
return _fileOutputStream(gzipStream, dst);
} | javascript | async function gunzip(input, dst){
// is input a filename or stream ?
if (typeof input === 'string'){
input = await _fileInputStream(input);
}
// decompress
const gzipStream = input.pipe(_zlib.createGunzip());
// write content to file
return _fileOutputStream(gzipStream, dst);
} | [
"async",
"function",
"gunzip",
"(",
"input",
",",
"dst",
")",
"{",
"// is input a filename or stream ?",
"if",
"(",
"typeof",
"input",
"===",
"'string'",
")",
"{",
"input",
"=",
"await",
"_fileInputStream",
"(",
"input",
")",
";",
"}",
"// decompress",
"const"... | decompress a file | [
"decompress",
"a",
"file"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/gunzip.js#L6-L17 | train |
canguruhh/metaversejs | src/output.js | targetComplete | function targetComplete(target) {
let complete = true;
Object.values(target).forEach((value) => {
if (value > 0)
complete = false;
});
return complete;
} | javascript | function targetComplete(target) {
let complete = true;
Object.values(target).forEach((value) => {
if (value > 0)
complete = false;
});
return complete;
} | [
"function",
"targetComplete",
"(",
"target",
")",
"{",
"let",
"complete",
"=",
"true",
";",
"Object",
".",
"values",
"(",
"target",
")",
".",
"forEach",
"(",
"(",
"value",
")",
"=>",
"{",
"if",
"(",
"value",
">",
"0",
")",
"complete",
"=",
"false",
... | Helper function to check a target object if there are no more positive values.
@param {Object} targets
@returns {Boolean} | [
"Helper",
"function",
"to",
"check",
"a",
"target",
"object",
"if",
"there",
"are",
"no",
"more",
"positive",
"values",
"."
] | d79471978d9e4bed277d3c12918a0f0c2a14a498 | https://github.com/canguruhh/metaversejs/blob/d79471978d9e4bed277d3c12918a0f0c2a14a498/src/output.js#L371-L378 | train |
SerkanSipahi/app-decorators | src/helpers/guid.js | guid | function guid() {
function _s4() {
return Math.floor(
(1 + Math.random()) * 0x10000
).toString(16).substring(1);
}
return _s4() + _s4() + '-' + _s4() + '-' + _s4() + '-' + _s4() + '-' + _s4() + _s4() + _s4();
} | javascript | function guid() {
function _s4() {
return Math.floor(
(1 + Math.random()) * 0x10000
).toString(16).substring(1);
}
return _s4() + _s4() + '-' + _s4() + '-' + _s4() + '-' + _s4() + '-' + _s4() + _s4() + _s4();
} | [
"function",
"guid",
"(",
")",
"{",
"function",
"_s4",
"(",
")",
"{",
"return",
"Math",
".",
"floor",
"(",
"(",
"1",
"+",
"Math",
".",
"random",
"(",
")",
")",
"*",
"0x10000",
")",
".",
"toString",
"(",
"16",
")",
".",
"substring",
"(",
"1",
")"... | Generate unique id
@source http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript#105074
@returns {string} | [
"Generate",
"unique",
"id"
] | 15f046b1bbe56af0d45b4a1b45a6a4c5689e4763 | https://github.com/SerkanSipahi/app-decorators/blob/15f046b1bbe56af0d45b4a1b45a6a4c5689e4763/src/helpers/guid.js#L6-L13 | train |
tkqubo/conditional-decorator | dist/utils.js | getDecoratorTypeFromArguments | function getDecoratorTypeFromArguments(args) {
'use strict';
if (args.length === 0 || args.length > 3) {
return DecoratorType.None;
}
var kind = typeof (args.length === 1 ? args[0] : args[2]);
switch (kind) {
case 'function':
return DecoratorType.Class;
case 'numb... | javascript | function getDecoratorTypeFromArguments(args) {
'use strict';
if (args.length === 0 || args.length > 3) {
return DecoratorType.None;
}
var kind = typeof (args.length === 1 ? args[0] : args[2]);
switch (kind) {
case 'function':
return DecoratorType.Class;
case 'numb... | [
"function",
"getDecoratorTypeFromArguments",
"(",
"args",
")",
"{",
"'use strict'",
";",
"if",
"(",
"args",
".",
"length",
"===",
"0",
"||",
"args",
".",
"length",
">",
"3",
")",
"{",
"return",
"DecoratorType",
".",
"None",
";",
"}",
"var",
"kind",
"=",
... | Guesses which kind of decorator from its functional arguments
@param args
@returns {DecoratorType} | [
"Guesses",
"which",
"kind",
"of",
"decorator",
"from",
"its",
"functional",
"arguments"
] | 9e19163d3c7bc5b0c9695a736ff8802c700b1ffc | https://github.com/tkqubo/conditional-decorator/blob/9e19163d3c7bc5b0c9695a736ff8802c700b1ffc/dist/utils.js#L18-L36 | train |
mlewand/win-clipboard | lib/html.js | function( tagName, inputString ) {
let ret = inputString;
if ( ret.indexOf( '<' + tagName ) === -1 ) {
ret = `<${tagName}>${ret}`;
}
if ( ret.indexOf( '</' + tagName + '>' ) === -1 ) {
ret = `${ret}</${tagName}>`;
}
return ret;
} | javascript | function( tagName, inputString ) {
let ret = inputString;
if ( ret.indexOf( '<' + tagName ) === -1 ) {
ret = `<${tagName}>${ret}`;
}
if ( ret.indexOf( '</' + tagName + '>' ) === -1 ) {
ret = `${ret}</${tagName}>`;
}
return ret;
} | [
"function",
"(",
"tagName",
",",
"inputString",
")",
"{",
"let",
"ret",
"=",
"inputString",
";",
"if",
"(",
"ret",
".",
"indexOf",
"(",
"'<'",
"+",
"tagName",
")",
"===",
"-",
"1",
")",
"{",
"ret",
"=",
"`",
"${",
"tagName",
"}",
"${",
"ret",
"}"... | Ensures that `string` is wrapped with an `tagName` element.
@param {string} tagName
@param {string} inputString
@returns {string} A copy of `inputString` that is guaranteed to be wrapped with `tagName` element. | [
"Ensures",
"that",
"string",
"is",
"wrapped",
"with",
"an",
"tagName",
"element",
"."
] | 07fedc3f2a346ced39163dae75042884bde010e4 | https://github.com/mlewand/win-clipboard/blob/07fedc3f2a346ced39163dae75042884bde010e4/lib/html.js#L125-L137 | train | |
little-brother/outlier2 | stat-func.js | variance | function variance(values) {
let avg = mean(values);
return mean(values.map((e) => Math.pow(e - avg, 2)));
} | javascript | function variance(values) {
let avg = mean(values);
return mean(values.map((e) => Math.pow(e - avg, 2)));
} | [
"function",
"variance",
"(",
"values",
")",
"{",
"let",
"avg",
"=",
"mean",
"(",
"values",
")",
";",
"return",
"mean",
"(",
"values",
".",
"map",
"(",
"(",
"e",
")",
"=>",
"Math",
".",
"pow",
"(",
"e",
"-",
"avg",
",",
"2",
")",
")",
")",
";"... | Variance = average squared deviation from mean | [
"Variance",
"=",
"average",
"squared",
"deviation",
"from",
"mean"
] | c6037b27b236e7d24aab81a1f925376f4ed8c03c | https://github.com/little-brother/outlier2/blob/c6037b27b236e7d24aab81a1f925376f4ed8c03c/stat-func.js#L21-L24 | train |
ablage/perceptualdiff | index.js | function (path, image) {
if (image instanceof Buffer) {
return Promise.denodeify(PNGImage.loadImage)(image);
} else if ((typeof path === 'string') && !image) {
return Promise.denodeify(PNGImage.readImage)(path);
} else {
return image;
}
} | javascript | function (path, image) {
if (image instanceof Buffer) {
return Promise.denodeify(PNGImage.loadImage)(image);
} else if ((typeof path === 'string') && !image) {
return Promise.denodeify(PNGImage.readImage)(path);
} else {
return image;
}
} | [
"function",
"(",
"path",
",",
"image",
")",
"{",
"if",
"(",
"image",
"instanceof",
"Buffer",
")",
"{",
"return",
"Promise",
".",
"denodeify",
"(",
"PNGImage",
".",
"loadImage",
")",
"(",
"image",
")",
";",
"}",
"else",
"if",
"(",
"(",
"typeof",
"path... | Loads the image or uses the already available image
@method _loadImage
@param {string} path
@param {PNGImage} image
@return {PNGImage|Promise}
@private | [
"Loads",
"the",
"image",
"or",
"uses",
"the",
"already",
"available",
"image"
] | d91b1a7d2811fa78a6b4fe633b86ca6525a11314 | https://github.com/ablage/perceptualdiff/blob/d91b1a7d2811fa78a6b4fe633b86ca6525a11314/index.js#L151-L162 | train | |
tdzienniak/entropy | example/breakout/src/Breakout.js | fadeOutScreen | function fadeOutScreen(screen) {
var screenElement = document.querySelector(screen);
return Velocity(screenElement, {
opacity: 0,
}, {
display: "none",
duration: 500
});
} | javascript | function fadeOutScreen(screen) {
var screenElement = document.querySelector(screen);
return Velocity(screenElement, {
opacity: 0,
}, {
display: "none",
duration: 500
});
} | [
"function",
"fadeOutScreen",
"(",
"screen",
")",
"{",
"var",
"screenElement",
"=",
"document",
".",
"querySelector",
"(",
"screen",
")",
";",
"return",
"Velocity",
"(",
"screenElement",
",",
"{",
"opacity",
":",
"0",
",",
"}",
",",
"{",
"display",
":",
"... | Some helper CSS animation functions | [
"Some",
"helper",
"CSS",
"animation",
"functions"
] | c9c6460806c9dd3318caa690a0eaf463fecc2fd3 | https://github.com/tdzienniak/entropy/blob/c9c6460806c9dd3318caa690a0eaf463fecc2fd3/example/breakout/src/Breakout.js#L51-L60 | train |
nicjansma/usertiming-compression.js | dist/usertiming-decompression.js | eat | function eat(expected) {
if (s[i] !== expected) {
throw new Error("bad JSURL syntax: expected " + expected + ", got " + (s && s[i]));
}
i++;
} | javascript | function eat(expected) {
if (s[i] !== expected) {
throw new Error("bad JSURL syntax: expected " + expected + ", got " + (s && s[i]));
}
i++;
} | [
"function",
"eat",
"(",
"expected",
")",
"{",
"if",
"(",
"s",
"[",
"i",
"]",
"!==",
"expected",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"bad JSURL syntax: expected \"",
"+",
"expected",
"+",
"\", got \"",
"+",
"(",
"s",
"&&",
"s",
"[",
"i",
"]",
")... | Eats the specified character, and throws an exception if another character
was found
@param {string} expected Expected string | [
"Eats",
"the",
"specified",
"character",
"and",
"throws",
"an",
"exception",
"if",
"another",
"character",
"was",
"found"
] | 381c5d2ed832d128dd2291e130ade0fa7851630e | https://github.com/nicjansma/usertiming-compression.js/blob/381c5d2ed832d128dd2291e130ade0fa7851630e/dist/usertiming-decompression.js#L395-L401 | train |
nicjansma/usertiming-compression.js | dist/usertiming-decompression.js | decode | function decode() {
var beg = i;
var ch;
var r = "";
// iterate until we reach the end of the string or "~" or ")"
while (i < len && (ch = s[i]) !== "~" && ch !== ")") {
switch (ch) {
case "*":
if (b... | javascript | function decode() {
var beg = i;
var ch;
var r = "";
// iterate until we reach the end of the string or "~" or ")"
while (i < len && (ch = s[i]) !== "~" && ch !== ")") {
switch (ch) {
case "*":
if (b... | [
"function",
"decode",
"(",
")",
"{",
"var",
"beg",
"=",
"i",
";",
"var",
"ch",
";",
"var",
"r",
"=",
"\"\"",
";",
"// iterate until we reach the end of the string or \"~\" or \")\"",
"while",
"(",
"i",
"<",
"len",
"&&",
"(",
"ch",
"=",
"s",
"[",
"i",
"]"... | Decodes the next value
@returns {string} Next value | [
"Decodes",
"the",
"next",
"value"
] | 381c5d2ed832d128dd2291e130ade0fa7851630e | https://github.com/nicjansma/usertiming-compression.js/blob/381c5d2ed832d128dd2291e130ade0fa7851630e/dist/usertiming-decompression.js#L408-L447 | train |
bang88/antd-local-icon-font | index.js | function (_a) {
var _b = _a === void 0 ? {} : _a, baseDir = _b.baseDir, _c = _b.fontsPathToSave, fontsPathToSave = _c === void 0 ? process.cwd() + "/build/static/fonts/" : _c, _d = _b.iconUrl, iconUrl = _d === void 0 ? "https://at.alicdn.com/t/" : _d, _e = _b.fontReg, fontReg = _e === void 0 ? /@font-face{font-fami... | javascript | function (_a) {
var _b = _a === void 0 ? {} : _a, baseDir = _b.baseDir, _c = _b.fontsPathToSave, fontsPathToSave = _c === void 0 ? process.cwd() + "/build/static/fonts/" : _c, _d = _b.iconUrl, iconUrl = _d === void 0 ? "https://at.alicdn.com/t/" : _d, _e = _b.fontReg, fontReg = _e === void 0 ? /@font-face{font-fami... | [
"function",
"(",
"_a",
")",
"{",
"var",
"_b",
"=",
"_a",
"===",
"void",
"0",
"?",
"{",
"}",
":",
"_a",
",",
"baseDir",
"=",
"_b",
".",
"baseDir",
",",
"_c",
"=",
"_b",
".",
"fontsPathToSave",
",",
"fontsPathToSave",
"=",
"_c",
"===",
"void",
"0",... | finding files and replace it | [
"finding",
"files",
"and",
"replace",
"it"
] | d9aed9c581efe32d941b8a2bfcca6492cc6a6e58 | https://github.com/bang88/antd-local-icon-font/blob/d9aed9c581efe32d941b8a2bfcca6492cc6a6e58/index.js#L58-L98 | train | |
AndiDittrich/Node.fs-magic | lib/untar.js | untar | async function untar(istream, dst){
// is destination a directory ?
if (!await _isDirectory(dst)){
throw Error('Destination is not a valid directory: ' + dst);
}
// get instance
const extract = _tar.extract();
// list of extracted files
const items = [];
// wrap into Promi... | javascript | async function untar(istream, dst){
// is destination a directory ?
if (!await _isDirectory(dst)){
throw Error('Destination is not a valid directory: ' + dst);
}
// get instance
const extract = _tar.extract();
// list of extracted files
const items = [];
// wrap into Promi... | [
"async",
"function",
"untar",
"(",
"istream",
",",
"dst",
")",
"{",
"// is destination a directory ?",
"if",
"(",
"!",
"await",
"_isDirectory",
"(",
"dst",
")",
")",
"{",
"throw",
"Error",
"(",
"'Destination is not a valid directory: '",
"+",
"dst",
")",
";",
... | decompress an archive | [
"decompress",
"an",
"archive"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/untar.js#L8-L53 | train |
mickleroy/gulp-clientlibify | index.js | zipDirectory | function zipDirectory(directories, dest, callback) {
var archive = archiver.create('zip', {gzip: false});
// Where to write the file
var destStream = fs.createWriteStream(dest);
archive.on('error', function(err) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archi... | javascript | function zipDirectory(directories, dest, callback) {
var archive = archiver.create('zip', {gzip: false});
// Where to write the file
var destStream = fs.createWriteStream(dest);
archive.on('error', function(err) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archi... | [
"function",
"zipDirectory",
"(",
"directories",
",",
"dest",
",",
"callback",
")",
"{",
"var",
"archive",
"=",
"archiver",
".",
"create",
"(",
"'zip'",
",",
"{",
"gzip",
":",
"false",
"}",
")",
";",
"// Where to write the file",
"var",
"destStream",
"=",
"... | Zips a set of directories and its contents using node-archiver.
@param directories
@param dest
@param zipCallback | [
"Zips",
"a",
"set",
"of",
"directories",
"and",
"its",
"contents",
"using",
"node",
"-",
"archiver",
"."
] | 49869cc06ef37fe67b3490bd1be175814d2646aa | https://github.com/mickleroy/gulp-clientlibify/blob/49869cc06ef37fe67b3490bd1be175814d2646aa/index.js#L246-L282 | train |
nicjansma/usertiming-compression.js | src/usertiming-compression.js | encode | function encode(s) {
if (!/[^\w-.]/.test(s)) {
// if the string is only made up of alpha-numeric, underscore,
// dash or period, we can use it directly.
return s;
}
// we need to escape other characters
s = s.replac... | javascript | function encode(s) {
if (!/[^\w-.]/.test(s)) {
// if the string is only made up of alpha-numeric, underscore,
// dash or period, we can use it directly.
return s;
}
// we need to escape other characters
s = s.replac... | [
"function",
"encode",
"(",
"s",
")",
"{",
"if",
"(",
"!",
"/",
"[^\\w-.]",
"/",
".",
"test",
"(",
"s",
")",
")",
"{",
"// if the string is only made up of alpha-numeric, underscore,\r",
"// dash or period, we can use it directly.\r",
"return",
"s",
";",
"}",
"// we ... | Encodes the specified string
@param {string} s String
@returns {string} Encoded string | [
"Encodes",
"the",
"specified",
"string"
] | 381c5d2ed832d128dd2291e130ade0fa7851630e | https://github.com/nicjansma/usertiming-compression.js/blob/381c5d2ed832d128dd2291e130ade0fa7851630e/src/usertiming-compression.js#L571-L597 | train |
LittleHelicase/frequencyjs | dsp.js | setupTypedArray | function setupTypedArray(name, fallback) {
// check if TypedArray exists
// typeof on Minefield and Chrome return function, typeof on Webkit returns object.
if (typeof this[name] !== "function" && typeof this[name] !== "object") {
// nope.. check if WebGLArray exists
if (typeof this[fallback] === "functio... | javascript | function setupTypedArray(name, fallback) {
// check if TypedArray exists
// typeof on Minefield and Chrome return function, typeof on Webkit returns object.
if (typeof this[name] !== "function" && typeof this[name] !== "object") {
// nope.. check if WebGLArray exists
if (typeof this[fallback] === "functio... | [
"function",
"setupTypedArray",
"(",
"name",
",",
"fallback",
")",
"{",
"// check if TypedArray exists",
"// typeof on Minefield and Chrome return function, typeof on Webkit returns object.",
"if",
"(",
"typeof",
"this",
"[",
"name",
"]",
"!==",
"\"function\"",
"&&",
"typeof",... | Setup arrays for platforms which do not support byte arrays | [
"Setup",
"arrays",
"for",
"platforms",
"which",
"do",
"not",
"support",
"byte",
"arrays"
] | a3cf163ddfe77888ddefde77417f2ea192c05cc8 | https://github.com/LittleHelicase/frequencyjs/blob/a3cf163ddfe77888ddefde77417f2ea192c05cc8/dsp.js#L57-L75 | train |
LittleHelicase/frequencyjs | dsp.js | DFT | function DFT(bufferSize, sampleRate) {
FourierTransform.call(this, bufferSize, sampleRate);
var N = bufferSize/2 * bufferSize;
var TWO_PI = 2 * Math.PI;
this.sinTable = new Float32Array(N);
this.cosTable = new Float32Array(N);
for (var i = 0; i < N; i++) {
this.sinTable[i] = Math.sin(i * TWO_PI / buf... | javascript | function DFT(bufferSize, sampleRate) {
FourierTransform.call(this, bufferSize, sampleRate);
var N = bufferSize/2 * bufferSize;
var TWO_PI = 2 * Math.PI;
this.sinTable = new Float32Array(N);
this.cosTable = new Float32Array(N);
for (var i = 0; i < N; i++) {
this.sinTable[i] = Math.sin(i * TWO_PI / buf... | [
"function",
"DFT",
"(",
"bufferSize",
",",
"sampleRate",
")",
"{",
"FourierTransform",
".",
"call",
"(",
"this",
",",
"bufferSize",
",",
"sampleRate",
")",
";",
"var",
"N",
"=",
"bufferSize",
"/",
"2",
"*",
"bufferSize",
";",
"var",
"TWO_PI",
"=",
"2",
... | DFT is a class for calculating the Discrete Fourier Transform of a signal.
@param {Number} bufferSize The size of the sample buffer to be computed
@param {Number} sampleRate The sampleRate of the buffer (eg. 44100)
@constructor | [
"DFT",
"is",
"a",
"class",
"for",
"calculating",
"the",
"Discrete",
"Fourier",
"Transform",
"of",
"a",
"signal",
"."
] | a3cf163ddfe77888ddefde77417f2ea192c05cc8 | https://github.com/LittleHelicase/frequencyjs/blob/a3cf163ddfe77888ddefde77417f2ea192c05cc8/dsp.js#L298-L311 | train |
LittleHelicase/frequencyjs | dsp.js | Oscillator | function Oscillator(type, frequency, amplitude, bufferSize, sampleRate) {
this.frequency = frequency;
this.amplitude = amplitude;
this.bufferSize = bufferSize;
this.sampleRate = sampleRate;
//this.pulseWidth = pulseWidth;
this.frameCount = 0;
this.waveTableLength = 2048;
this.cyclesPerSample = freq... | javascript | function Oscillator(type, frequency, amplitude, bufferSize, sampleRate) {
this.frequency = frequency;
this.amplitude = amplitude;
this.bufferSize = bufferSize;
this.sampleRate = sampleRate;
//this.pulseWidth = pulseWidth;
this.frameCount = 0;
this.waveTableLength = 2048;
this.cyclesPerSample = freq... | [
"function",
"Oscillator",
"(",
"type",
",",
"frequency",
",",
"amplitude",
",",
"bufferSize",
",",
"sampleRate",
")",
"{",
"this",
".",
"frequency",
"=",
"frequency",
";",
"this",
".",
"amplitude",
"=",
"amplitude",
";",
"this",
".",
"bufferSize",
"=",
"bu... | Oscillator class for generating and modifying signals
@param {Number} type A waveform constant (eg. DSP.SINE)
@param {Number} frequency Initial frequency of the signal
@param {Number} amplitude Initial amplitude of the signal
@param {Number} bufferSize Size of the sample buffer to generate
@param {Number} samp... | [
"Oscillator",
"class",
"for",
"generating",
"and",
"modifying",
"signals"
] | a3cf163ddfe77888ddefde77417f2ea192c05cc8 | https://github.com/LittleHelicase/frequencyjs/blob/a3cf163ddfe77888ddefde77417f2ea192c05cc8/dsp.js#L960-L1013 | train |
frapa/bs4-selectbox | src/bs4-selectbox.directive.js | checkLater | function checkLater() {
setTimeout(function () {
ctrl.options(ctrl.searchTerms, function (options) {
ctrl._options = options;
if (options.length === 0) checkLater();
$scope.$apply();
});
}, 1000);
} | javascript | function checkLater() {
setTimeout(function () {
ctrl.options(ctrl.searchTerms, function (options) {
ctrl._options = options;
if (options.length === 0) checkLater();
$scope.$apply();
});
}, 1000);
} | [
"function",
"checkLater",
"(",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"ctrl",
".",
"options",
"(",
"ctrl",
".",
"searchTerms",
",",
"function",
"(",
"options",
")",
"{",
"ctrl",
".",
"_options",
"=",
"options",
";",
"if",
"(",
"options... | Sometimes options cannot return before some other stuff has been initialized Loop and check periodically until there is some data. | [
"Sometimes",
"options",
"cannot",
"return",
"before",
"some",
"other",
"stuff",
"has",
"been",
"initialized",
"Loop",
"and",
"check",
"periodically",
"until",
"there",
"is",
"some",
"data",
"."
] | 9216dcd702d23def5a9bbf944ec4a73f1ddf4051 | https://github.com/frapa/bs4-selectbox/blob/9216dcd702d23def5a9bbf944ec4a73f1ddf4051/src/bs4-selectbox.directive.js#L204-L212 | train |
AndiDittrich/Node.fs-magic | lib/checksum.js | checksum | function checksum(src, algorithm='sha256', outputFormat='hex'){
return new Promise(async function(resolve, reject){
// hash engine
const hash = _crypto.createHash(algorithm);
// events
hash.on('readable', function(){
// get hashsum
const sum = hash.read();
... | javascript | function checksum(src, algorithm='sha256', outputFormat='hex'){
return new Promise(async function(resolve, reject){
// hash engine
const hash = _crypto.createHash(algorithm);
// events
hash.on('readable', function(){
// get hashsum
const sum = hash.read();
... | [
"function",
"checksum",
"(",
"src",
",",
"algorithm",
"=",
"'sha256'",
",",
"outputFormat",
"=",
"'hex'",
")",
"{",
"return",
"new",
"Promise",
"(",
"async",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"// hash engine",
"const",
"hash",
"=",
"_cry... | generic checksum hashing | [
"generic",
"checksum",
"hashing"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/checksum.js#L5-L48 | train |
AndiDittrich/Node.fs-magic | lib/mkdirp.js | mkdirp | async function mkdirp(dir, mode=0o777, recursive=false){
// stats command executable ? dir/file exists
const stats = await _statx(dir);
// dir already exists ?
if (stats){
// check if its a directory
if (!stats.isDirectory()){
throw new Error('Requested directory <' + d... | javascript | async function mkdirp(dir, mode=0o777, recursive=false){
// stats command executable ? dir/file exists
const stats = await _statx(dir);
// dir already exists ?
if (stats){
// check if its a directory
if (!stats.isDirectory()){
throw new Error('Requested directory <' + d... | [
"async",
"function",
"mkdirp",
"(",
"dir",
",",
"mode",
"=",
"0o777",
",",
"recursive",
"=",
"false",
")",
"{",
"// stats command executable ? dir/file exists",
"const",
"stats",
"=",
"await",
"_statx",
"(",
"dir",
")",
";",
"// dir already exists ?",
"if",
"(",... | helper function to create directory only if they don't exists | [
"helper",
"function",
"to",
"create",
"directory",
"only",
"if",
"they",
"don",
"t",
"exists"
] | 5e685a550fd956b5b422a0f21c359952e9be114b | https://github.com/AndiDittrich/Node.fs-magic/blob/5e685a550fd956b5b422a0f21c359952e9be114b/lib/mkdirp.js#L6-L72 | 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.