repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
glennjones/microformat-shiv | microformat-shiv.js | function(rootNode, filters) {
if(modules.utils.isString(filters)){
filters = [filters];
}
var newRootNode = modules.domUtils.createNode('div'),
items = this.findRootNodes(rootNode, true),
i = 0,
x = 0,
y = 0;
// add v1 names
y = filters.length;
while (y--) {
if(this.getMapping(filters[y])){
var v1Name = this.getMapping(filters[y]).root;
filters.push(v1Name);
}
}
if(items){
i = items.length;
while(x < i) {
// append matching nodes into newRootNode
y = filters.length;
while (y--) {
if(modules.domUtils.hasAttributeValue(items[x], 'class', filters[y])){
var clone = modules.domUtils.clone(items[x]);
modules.domUtils.appendChild(newRootNode, clone);
break;
}
}
x++;
}
}
return newRootNode;
} | javascript | function(rootNode, filters) {
if(modules.utils.isString(filters)){
filters = [filters];
}
var newRootNode = modules.domUtils.createNode('div'),
items = this.findRootNodes(rootNode, true),
i = 0,
x = 0,
y = 0;
// add v1 names
y = filters.length;
while (y--) {
if(this.getMapping(filters[y])){
var v1Name = this.getMapping(filters[y]).root;
filters.push(v1Name);
}
}
if(items){
i = items.length;
while(x < i) {
// append matching nodes into newRootNode
y = filters.length;
while (y--) {
if(modules.domUtils.hasAttributeValue(items[x], 'class', filters[y])){
var clone = modules.domUtils.clone(items[x]);
modules.domUtils.appendChild(newRootNode, clone);
break;
}
}
x++;
}
}
return newRootNode;
} | [
"function",
"(",
"rootNode",
",",
"filters",
")",
"{",
"if",
"(",
"modules",
".",
"utils",
".",
"isString",
"(",
"filters",
")",
")",
"{",
"filters",
"=",
"[",
"filters",
"]",
";",
"}",
"var",
"newRootNode",
"=",
"modules",
".",
"domUtils",
".",
"createNode",
"(",
"'div'",
")",
",",
"items",
"=",
"this",
".",
"findRootNodes",
"(",
"rootNode",
",",
"true",
")",
",",
"i",
"=",
"0",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
";",
"y",
"=",
"filters",
".",
"length",
";",
"while",
"(",
"y",
"--",
")",
"{",
"if",
"(",
"this",
".",
"getMapping",
"(",
"filters",
"[",
"y",
"]",
")",
")",
"{",
"var",
"v1Name",
"=",
"this",
".",
"getMapping",
"(",
"filters",
"[",
"y",
"]",
")",
".",
"root",
";",
"filters",
".",
"push",
"(",
"v1Name",
")",
";",
"}",
"}",
"if",
"(",
"items",
")",
"{",
"i",
"=",
"items",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
"y",
"=",
"filters",
".",
"length",
";",
"while",
"(",
"y",
"--",
")",
"{",
"if",
"(",
"modules",
".",
"domUtils",
".",
"hasAttributeValue",
"(",
"items",
"[",
"x",
"]",
",",
"'class'",
",",
"filters",
"[",
"y",
"]",
")",
")",
"{",
"var",
"clone",
"=",
"modules",
".",
"domUtils",
".",
"clone",
"(",
"items",
"[",
"x",
"]",
")",
";",
"modules",
".",
"domUtils",
".",
"appendChild",
"(",
"newRootNode",
",",
"clone",
")",
";",
"break",
";",
"}",
"}",
"x",
"++",
";",
"}",
"}",
"return",
"newRootNode",
";",
"}"
] | find microformats of a given type and return node structures | [
"find",
"microformats",
"of",
"a",
"given",
"type",
"and",
"return",
"node",
"structures"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L403-L439 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(name, count, out){
if(out[name]){
out[name] = out[name] + count;
}else{
out[name] = count;
}
} | javascript | function(name, count, out){
if(out[name]){
out[name] = out[name] + count;
}else{
out[name] = count;
}
} | [
"function",
"(",
"name",
",",
"count",
",",
"out",
")",
"{",
"if",
"(",
"out",
"[",
"name",
"]",
")",
"{",
"out",
"[",
"name",
"]",
"=",
"out",
"[",
"name",
"]",
"+",
"count",
";",
"}",
"else",
"{",
"out",
"[",
"name",
"]",
"=",
"count",
";",
"}",
"}"
] | appends data to output object for count
@param {string} name
@param {Int} count
@param {Object} | [
"appends",
"data",
"to",
"output",
"object",
"for",
"count"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L449-L455 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(uf, filters) {
var i;
if(modules.utils.isArray(filters) && filters.length > 0) {
i = filters.length;
while(i--) {
if(uf.type[0] === filters[i]) {
return true;
}
}
return false;
} else {
return true;
}
} | javascript | function(uf, filters) {
var i;
if(modules.utils.isArray(filters) && filters.length > 0) {
i = filters.length;
while(i--) {
if(uf.type[0] === filters[i]) {
return true;
}
}
return false;
} else {
return true;
}
} | [
"function",
"(",
"uf",
",",
"filters",
")",
"{",
"var",
"i",
";",
"if",
"(",
"modules",
".",
"utils",
".",
"isArray",
"(",
"filters",
")",
"&&",
"filters",
".",
"length",
">",
"0",
")",
"{",
"i",
"=",
"filters",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"uf",
".",
"type",
"[",
"0",
"]",
"===",
"filters",
"[",
"i",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | is the microformats type in the filter list
@param {Object} uf
@param {Array} filters
@return {Boolean} | [
"is",
"the",
"microformats",
"type",
"in",
"the",
"filter",
"list"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L465-L479 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(rootNode, includeRoot) {
var arr = null,
out = [],
classList = [],
items,
x,
i,
y,
key;
// build an array of v1 root names
for(key in modules.maps) {
if (modules.maps.hasOwnProperty(key)) {
classList.push(modules.maps[key].root);
}
}
// get all elements that have a class attribute
includeRoot = (includeRoot) ? includeRoot : false;
if(includeRoot && rootNode.parentNode) {
arr = modules.domUtils.getNodesByAttribute(rootNode.parentNode, 'class');
} else {
arr = modules.domUtils.getNodesByAttribute(rootNode, 'class');
}
// loop elements that have a class attribute
x = 0;
i = arr.length;
while(x < i) {
items = modules.domUtils.getAttributeList(arr[x], 'class');
// loop classes on an element
y = items.length;
while(y--) {
// match v1 root names
if(classList.indexOf(items[y]) > -1) {
out.push(arr[x]);
break;
}
// match v2 root name prefix
if(modules.utils.startWith(items[y], 'h-')) {
out.push(arr[x]);
break;
}
}
x++;
}
return out;
} | javascript | function(rootNode, includeRoot) {
var arr = null,
out = [],
classList = [],
items,
x,
i,
y,
key;
// build an array of v1 root names
for(key in modules.maps) {
if (modules.maps.hasOwnProperty(key)) {
classList.push(modules.maps[key].root);
}
}
// get all elements that have a class attribute
includeRoot = (includeRoot) ? includeRoot : false;
if(includeRoot && rootNode.parentNode) {
arr = modules.domUtils.getNodesByAttribute(rootNode.parentNode, 'class');
} else {
arr = modules.domUtils.getNodesByAttribute(rootNode, 'class');
}
// loop elements that have a class attribute
x = 0;
i = arr.length;
while(x < i) {
items = modules.domUtils.getAttributeList(arr[x], 'class');
// loop classes on an element
y = items.length;
while(y--) {
// match v1 root names
if(classList.indexOf(items[y]) > -1) {
out.push(arr[x]);
break;
}
// match v2 root name prefix
if(modules.utils.startWith(items[y], 'h-')) {
out.push(arr[x]);
break;
}
}
x++;
}
return out;
} | [
"function",
"(",
"rootNode",
",",
"includeRoot",
")",
"{",
"var",
"arr",
"=",
"null",
",",
"out",
"=",
"[",
"]",
",",
"classList",
"=",
"[",
"]",
",",
"items",
",",
"x",
",",
"i",
",",
"y",
",",
"key",
";",
"for",
"(",
"key",
"in",
"modules",
".",
"maps",
")",
"{",
"if",
"(",
"modules",
".",
"maps",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"classList",
".",
"push",
"(",
"modules",
".",
"maps",
"[",
"key",
"]",
".",
"root",
")",
";",
"}",
"}",
"includeRoot",
"=",
"(",
"includeRoot",
")",
"?",
"includeRoot",
":",
"false",
";",
"if",
"(",
"includeRoot",
"&&",
"rootNode",
".",
"parentNode",
")",
"{",
"arr",
"=",
"modules",
".",
"domUtils",
".",
"getNodesByAttribute",
"(",
"rootNode",
".",
"parentNode",
",",
"'class'",
")",
";",
"}",
"else",
"{",
"arr",
"=",
"modules",
".",
"domUtils",
".",
"getNodesByAttribute",
"(",
"rootNode",
",",
"'class'",
")",
";",
"}",
"x",
"=",
"0",
";",
"i",
"=",
"arr",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
"items",
"=",
"modules",
".",
"domUtils",
".",
"getAttributeList",
"(",
"arr",
"[",
"x",
"]",
",",
"'class'",
")",
";",
"y",
"=",
"items",
".",
"length",
";",
"while",
"(",
"y",
"--",
")",
"{",
"if",
"(",
"classList",
".",
"indexOf",
"(",
"items",
"[",
"y",
"]",
")",
">",
"-",
"1",
")",
"{",
"out",
".",
"push",
"(",
"arr",
"[",
"x",
"]",
")",
";",
"break",
";",
"}",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"items",
"[",
"y",
"]",
",",
"'h-'",
")",
")",
"{",
"out",
".",
"push",
"(",
"arr",
"[",
"x",
"]",
")",
";",
"break",
";",
"}",
"}",
"x",
"++",
";",
"}",
"return",
"out",
";",
"}"
] | finds all microformat roots in a rootNode
@param {DOM Node} rootNode
@param {Boolean} includeRoot
@return {Array} | [
"finds",
"all",
"microformat",
"roots",
"in",
"a",
"rootNode"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L489-L541 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node){
var context = this,
children = [],
child,
classes,
items = [],
out = [];
classes = this.getUfClassNames(node);
// if it is a root microformat node
if(classes && classes.root.length > 0){
items = this.walkTree(node);
if(items.length > 0){
out = out.concat(items);
}
}else{
// check if there are children and one of the children has a root microformat
children = modules.domUtils.getChildren( node );
if(children && children.length > 0 && this.findRootNodes(node, true).length > -1){
for (var i = 0; i < children.length; i++) {
child = children[i];
items = context.walkRoot(child);
if(items.length > 0){
out = out.concat(items);
}
}
}
}
return out;
} | javascript | function(node){
var context = this,
children = [],
child,
classes,
items = [],
out = [];
classes = this.getUfClassNames(node);
// if it is a root microformat node
if(classes && classes.root.length > 0){
items = this.walkTree(node);
if(items.length > 0){
out = out.concat(items);
}
}else{
// check if there are children and one of the children has a root microformat
children = modules.domUtils.getChildren( node );
if(children && children.length > 0 && this.findRootNodes(node, true).length > -1){
for (var i = 0; i < children.length; i++) {
child = children[i];
items = context.walkRoot(child);
if(items.length > 0){
out = out.concat(items);
}
}
}
}
return out;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"context",
"=",
"this",
",",
"children",
"=",
"[",
"]",
",",
"child",
",",
"classes",
",",
"items",
"=",
"[",
"]",
",",
"out",
"=",
"[",
"]",
";",
"classes",
"=",
"this",
".",
"getUfClassNames",
"(",
"node",
")",
";",
"if",
"(",
"classes",
"&&",
"classes",
".",
"root",
".",
"length",
">",
"0",
")",
"{",
"items",
"=",
"this",
".",
"walkTree",
"(",
"node",
")",
";",
"if",
"(",
"items",
".",
"length",
">",
"0",
")",
"{",
"out",
"=",
"out",
".",
"concat",
"(",
"items",
")",
";",
"}",
"}",
"else",
"{",
"children",
"=",
"modules",
".",
"domUtils",
".",
"getChildren",
"(",
"node",
")",
";",
"if",
"(",
"children",
"&&",
"children",
".",
"length",
">",
"0",
"&&",
"this",
".",
"findRootNodes",
"(",
"node",
",",
"true",
")",
".",
"length",
">",
"-",
"1",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"child",
"=",
"children",
"[",
"i",
"]",
";",
"items",
"=",
"context",
".",
"walkRoot",
"(",
"child",
")",
";",
"if",
"(",
"items",
".",
"length",
">",
"0",
")",
"{",
"out",
"=",
"out",
".",
"concat",
"(",
"items",
")",
";",
"}",
"}",
"}",
"}",
"return",
"out",
";",
"}"
] | starts the tree walk to find microformats
@param {DOM Node} node
@return {Array} | [
"starts",
"the",
"tree",
"walk",
"to",
"find",
"microformats"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L550-L580 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node) {
var classes,
out = [],
obj,
itemRootID;
// loop roots found on one element
classes = this.getUfClassNames(node);
if(classes && classes.root.length && classes.root.length > 0){
this.rootID++;
itemRootID = this.rootID;
obj = this.createUfObject(classes.root, classes.typeVersion);
this.walkChildren(node, obj, classes.root, itemRootID, classes);
if(this.impliedRules){
this.impliedRules(node, obj, classes);
}
if(this.options.lang === true){
var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang');
if(lang){
obj.lang = lang;
}
}
out.push( this.cleanUfObject(obj) );
}
return out;
} | javascript | function(node) {
var classes,
out = [],
obj,
itemRootID;
// loop roots found on one element
classes = this.getUfClassNames(node);
if(classes && classes.root.length && classes.root.length > 0){
this.rootID++;
itemRootID = this.rootID;
obj = this.createUfObject(classes.root, classes.typeVersion);
this.walkChildren(node, obj, classes.root, itemRootID, classes);
if(this.impliedRules){
this.impliedRules(node, obj, classes);
}
if(this.options.lang === true){
var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang');
if(lang){
obj.lang = lang;
}
}
out.push( this.cleanUfObject(obj) );
}
return out;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"classes",
",",
"out",
"=",
"[",
"]",
",",
"obj",
",",
"itemRootID",
";",
"classes",
"=",
"this",
".",
"getUfClassNames",
"(",
"node",
")",
";",
"if",
"(",
"classes",
"&&",
"classes",
".",
"root",
".",
"length",
"&&",
"classes",
".",
"root",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"rootID",
"++",
";",
"itemRootID",
"=",
"this",
".",
"rootID",
";",
"obj",
"=",
"this",
".",
"createUfObject",
"(",
"classes",
".",
"root",
",",
"classes",
".",
"typeVersion",
")",
";",
"this",
".",
"walkChildren",
"(",
"node",
",",
"obj",
",",
"classes",
".",
"root",
",",
"itemRootID",
",",
"classes",
")",
";",
"if",
"(",
"this",
".",
"impliedRules",
")",
"{",
"this",
".",
"impliedRules",
"(",
"node",
",",
"obj",
",",
"classes",
")",
";",
"}",
"if",
"(",
"this",
".",
"options",
".",
"lang",
"===",
"true",
")",
"{",
"var",
"lang",
"=",
"modules",
".",
"domUtils",
".",
"getFirstAncestorAttribute",
"(",
"node",
",",
"'lang'",
")",
";",
"if",
"(",
"lang",
")",
"{",
"obj",
".",
"lang",
"=",
"lang",
";",
"}",
"}",
"out",
".",
"push",
"(",
"this",
".",
"cleanUfObject",
"(",
"obj",
")",
")",
";",
"}",
"return",
"out",
";",
"}"
] | starts the tree walking for a single microformat
@param {DOM Node} node
@return {Array} | [
"starts",
"the",
"tree",
"walking",
"for",
"a",
"single",
"microformat"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L589-L619 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, className, uf) {
var value = '';
if(modules.utils.startWith(className, 'p-')) {
value = this.getPValue(node, true);
}
if(modules.utils.startWith(className, 'e-')) {
value = this.getEValue(node);
}
if(modules.utils.startWith(className, 'u-')) {
value = this.getUValue(node, true);
}
if(modules.utils.startWith(className, 'dt-')) {
value = this.getDTValue(node, className, uf, true);
}
return value;
} | javascript | function(node, className, uf) {
var value = '';
if(modules.utils.startWith(className, 'p-')) {
value = this.getPValue(node, true);
}
if(modules.utils.startWith(className, 'e-')) {
value = this.getEValue(node);
}
if(modules.utils.startWith(className, 'u-')) {
value = this.getUValue(node, true);
}
if(modules.utils.startWith(className, 'dt-')) {
value = this.getDTValue(node, className, uf, true);
}
return value;
} | [
"function",
"(",
"node",
",",
"className",
",",
"uf",
")",
"{",
"var",
"value",
"=",
"''",
";",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"className",
",",
"'p-'",
")",
")",
"{",
"value",
"=",
"this",
".",
"getPValue",
"(",
"node",
",",
"true",
")",
";",
"}",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"className",
",",
"'e-'",
")",
")",
"{",
"value",
"=",
"this",
".",
"getEValue",
"(",
"node",
")",
";",
"}",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"className",
",",
"'u-'",
")",
")",
"{",
"value",
"=",
"this",
".",
"getUValue",
"(",
"node",
",",
"true",
")",
";",
"}",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"className",
",",
"'dt-'",
")",
")",
"{",
"value",
"=",
"this",
".",
"getDTValue",
"(",
"node",
",",
"className",
",",
"uf",
",",
"true",
")",
";",
"}",
"return",
"value",
";",
"}"
] | gets the value of a property from a node
@param {DOM Node} node
@param {String} className
@param {Object} uf
@return {String || Object} | [
"gets",
"the",
"value",
"of",
"a",
"property",
"from",
"a",
"node"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L796-L815 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, valueParse) {
var out = '';
if(valueParse) {
out = this.getValueClass(node, 'p');
}
if(!out && valueParse) {
out = this.getValueTitle(node);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value');
}
if(node.name === 'br' || node.name === 'hr') {
out = '';
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['img', 'area'], 'alt');
}
if(!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
return(out) ? out : '';
} | javascript | function(node, valueParse) {
var out = '';
if(valueParse) {
out = this.getValueClass(node, 'p');
}
if(!out && valueParse) {
out = this.getValueTitle(node);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value');
}
if(node.name === 'br' || node.name === 'hr') {
out = '';
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['img', 'area'], 'alt');
}
if(!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
return(out) ? out : '';
} | [
"function",
"(",
"node",
",",
"valueParse",
")",
"{",
"var",
"out",
"=",
"''",
";",
"if",
"(",
"valueParse",
")",
"{",
"out",
"=",
"this",
".",
"getValueClass",
"(",
"node",
",",
"'p'",
")",
";",
"}",
"if",
"(",
"!",
"out",
"&&",
"valueParse",
")",
"{",
"out",
"=",
"this",
".",
"getValueTitle",
"(",
"node",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'abbr'",
"]",
",",
"'title'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'data'",
",",
"'input'",
"]",
",",
"'value'",
")",
";",
"}",
"if",
"(",
"node",
".",
"name",
"===",
"'br'",
"||",
"node",
".",
"name",
"===",
"'hr'",
")",
"{",
"out",
"=",
"''",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'img'",
",",
"'area'",
"]",
",",
"'alt'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"text",
".",
"parse",
"(",
"this",
".",
"document",
",",
"node",
",",
"this",
".",
"options",
".",
"textFormat",
")",
";",
"}",
"return",
"(",
"out",
")",
"?",
"out",
":",
"''",
";",
"}"
] | gets the value of a node which contains a 'p-' property
@param {DOM Node} node
@param {Boolean} valueParse
@return {String} | [
"gets",
"the",
"value",
"of",
"a",
"node",
"which",
"contains",
"a",
"p",
"-",
"property"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L825-L856 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node) {
var out = {value: '', html: ''};
this.expandURLs(node, 'src', this.options.baseUrl);
this.expandURLs(node, 'href', this.options.baseUrl);
out.value = modules.text.parse(this.document, node, this.options.textFormat);
out.html = modules.html.parse(node);
if(this.options.lang === true){
var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang');
if(lang){
out.lang = lang;
}
}
return out;
} | javascript | function(node) {
var out = {value: '', html: ''};
this.expandURLs(node, 'src', this.options.baseUrl);
this.expandURLs(node, 'href', this.options.baseUrl);
out.value = modules.text.parse(this.document, node, this.options.textFormat);
out.html = modules.html.parse(node);
if(this.options.lang === true){
var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang');
if(lang){
out.lang = lang;
}
}
return out;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"out",
"=",
"{",
"value",
":",
"''",
",",
"html",
":",
"''",
"}",
";",
"this",
".",
"expandURLs",
"(",
"node",
",",
"'src'",
",",
"this",
".",
"options",
".",
"baseUrl",
")",
";",
"this",
".",
"expandURLs",
"(",
"node",
",",
"'href'",
",",
"this",
".",
"options",
".",
"baseUrl",
")",
";",
"out",
".",
"value",
"=",
"modules",
".",
"text",
".",
"parse",
"(",
"this",
".",
"document",
",",
"node",
",",
"this",
".",
"options",
".",
"textFormat",
")",
";",
"out",
".",
"html",
"=",
"modules",
".",
"html",
".",
"parse",
"(",
"node",
")",
";",
"if",
"(",
"this",
".",
"options",
".",
"lang",
"===",
"true",
")",
"{",
"var",
"lang",
"=",
"modules",
".",
"domUtils",
".",
"getFirstAncestorAttribute",
"(",
"node",
",",
"'lang'",
")",
";",
"if",
"(",
"lang",
")",
"{",
"out",
".",
"lang",
"=",
"lang",
";",
"}",
"}",
"return",
"out",
";",
"}"
] | gets the value of a node which contains the 'e-' property
@param {DOM Node} node
@return {Object} | [
"gets",
"the",
"value",
"of",
"a",
"node",
"which",
"contains",
"the",
"e",
"-",
"property"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L865-L883 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, valueParse) {
var out = '';
if(valueParse) {
out = this.getValueClass(node, 'u');
}
if(!out && valueParse) {
out = this.getValueTitle(node);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['a', 'area'], 'href');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['img','audio','video','source'], 'src');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['video'], 'poster');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data');
}
// if we have no protocol separator, turn relative url to absolute url
if(out && out !== '' && out.indexOf('://') === -1) {
out = modules.url.resolve(out, this.options.baseUrl);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value');
}
if(!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
return(out) ? out : '';
} | javascript | function(node, valueParse) {
var out = '';
if(valueParse) {
out = this.getValueClass(node, 'u');
}
if(!out && valueParse) {
out = this.getValueTitle(node);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['a', 'area'], 'href');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['img','audio','video','source'], 'src');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['video'], 'poster');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['object'], 'data');
}
// if we have no protocol separator, turn relative url to absolute url
if(out && out !== '' && out.indexOf('://') === -1) {
out = modules.url.resolve(out, this.options.baseUrl);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data','input'], 'value');
}
if(!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
return(out) ? out : '';
} | [
"function",
"(",
"node",
",",
"valueParse",
")",
"{",
"var",
"out",
"=",
"''",
";",
"if",
"(",
"valueParse",
")",
"{",
"out",
"=",
"this",
".",
"getValueClass",
"(",
"node",
",",
"'u'",
")",
";",
"}",
"if",
"(",
"!",
"out",
"&&",
"valueParse",
")",
"{",
"out",
"=",
"this",
".",
"getValueTitle",
"(",
"node",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'a'",
",",
"'area'",
"]",
",",
"'href'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'img'",
",",
"'audio'",
",",
"'video'",
",",
"'source'",
"]",
",",
"'src'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'video'",
"]",
",",
"'poster'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'object'",
"]",
",",
"'data'",
")",
";",
"}",
"if",
"(",
"out",
"&&",
"out",
"!==",
"''",
"&&",
"out",
".",
"indexOf",
"(",
"'://'",
")",
"===",
"-",
"1",
")",
"{",
"out",
"=",
"modules",
".",
"url",
".",
"resolve",
"(",
"out",
",",
"this",
".",
"options",
".",
"baseUrl",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'abbr'",
"]",
",",
"'title'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'data'",
",",
"'input'",
"]",
",",
"'value'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"text",
".",
"parse",
"(",
"this",
".",
"document",
",",
"node",
",",
"this",
".",
"options",
".",
"textFormat",
")",
";",
"}",
"return",
"(",
"out",
")",
"?",
"out",
":",
"''",
";",
"}"
] | gets the value of a node which contains the 'u-' property
@param {DOM Node} node
@param {Boolean} valueParse
@return {String} | [
"gets",
"the",
"value",
"of",
"a",
"node",
"which",
"contains",
"the",
"u",
"-",
"property"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L893-L937 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, className, uf, valueParse) {
var out = '',
fromValue = false;
if(valueParse) {
out = this.getValueClass(node, 'dt');
if(out){
fromValue = true;
}
}
if(!out && valueParse) {
out = this.getValueTitle(node);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['time', 'ins', 'del'], 'datetime');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data', 'input'], 'value');
}
if(!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
if(out) {
var format = (fromValue)? 'microformat2' : this.options.dateFormat;
if(modules.dates.isDuration(out)) {
// just duration
return out;
} else if(modules.dates.isTime(out)) {
// just time or time+timezone
if(uf) {
uf.times.push([className, modules.dates.parseAmPmTime(out, format)]);
}
return modules.dates.parseAmPmTime(out, format);
} else {
// returns a date - microformat profile
if(uf) {
uf.dates.push([className, new modules.ISODate(out).toString( format )]);
}
return new modules.ISODate(out).toString( format );
}
} else {
return '';
}
} | javascript | function(node, className, uf, valueParse) {
var out = '',
fromValue = false;
if(valueParse) {
out = this.getValueClass(node, 'dt');
if(out){
fromValue = true;
}
}
if(!out && valueParse) {
out = this.getValueTitle(node);
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['time', 'ins', 'del'], 'datetime');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['abbr'], 'title');
}
if(!out) {
out = modules.domUtils.getAttrValFromTagList(node, ['data', 'input'], 'value');
}
if(!out) {
out = modules.text.parse(this.document, node, this.options.textFormat);
}
if(out) {
var format = (fromValue)? 'microformat2' : this.options.dateFormat;
if(modules.dates.isDuration(out)) {
// just duration
return out;
} else if(modules.dates.isTime(out)) {
// just time or time+timezone
if(uf) {
uf.times.push([className, modules.dates.parseAmPmTime(out, format)]);
}
return modules.dates.parseAmPmTime(out, format);
} else {
// returns a date - microformat profile
if(uf) {
uf.dates.push([className, new modules.ISODate(out).toString( format )]);
}
return new modules.ISODate(out).toString( format );
}
} else {
return '';
}
} | [
"function",
"(",
"node",
",",
"className",
",",
"uf",
",",
"valueParse",
")",
"{",
"var",
"out",
"=",
"''",
",",
"fromValue",
"=",
"false",
";",
"if",
"(",
"valueParse",
")",
"{",
"out",
"=",
"this",
".",
"getValueClass",
"(",
"node",
",",
"'dt'",
")",
";",
"if",
"(",
"out",
")",
"{",
"fromValue",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"out",
"&&",
"valueParse",
")",
"{",
"out",
"=",
"this",
".",
"getValueTitle",
"(",
"node",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'time'",
",",
"'ins'",
",",
"'del'",
"]",
",",
"'datetime'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'abbr'",
"]",
",",
"'title'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"domUtils",
".",
"getAttrValFromTagList",
"(",
"node",
",",
"[",
"'data'",
",",
"'input'",
"]",
",",
"'value'",
")",
";",
"}",
"if",
"(",
"!",
"out",
")",
"{",
"out",
"=",
"modules",
".",
"text",
".",
"parse",
"(",
"this",
".",
"document",
",",
"node",
",",
"this",
".",
"options",
".",
"textFormat",
")",
";",
"}",
"if",
"(",
"out",
")",
"{",
"var",
"format",
"=",
"(",
"fromValue",
")",
"?",
"'microformat2'",
":",
"this",
".",
"options",
".",
"dateFormat",
";",
"if",
"(",
"modules",
".",
"dates",
".",
"isDuration",
"(",
"out",
")",
")",
"{",
"return",
"out",
";",
"}",
"else",
"if",
"(",
"modules",
".",
"dates",
".",
"isTime",
"(",
"out",
")",
")",
"{",
"if",
"(",
"uf",
")",
"{",
"uf",
".",
"times",
".",
"push",
"(",
"[",
"className",
",",
"modules",
".",
"dates",
".",
"parseAmPmTime",
"(",
"out",
",",
"format",
")",
"]",
")",
";",
"}",
"return",
"modules",
".",
"dates",
".",
"parseAmPmTime",
"(",
"out",
",",
"format",
")",
";",
"}",
"else",
"{",
"if",
"(",
"uf",
")",
"{",
"uf",
".",
"dates",
".",
"push",
"(",
"[",
"className",
",",
"new",
"modules",
".",
"ISODate",
"(",
"out",
")",
".",
"toString",
"(",
"format",
")",
"]",
")",
";",
"}",
"return",
"new",
"modules",
".",
"ISODate",
"(",
"out",
")",
".",
"toString",
"(",
"format",
")",
";",
"}",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | gets the value of a node which contains the 'dt-' property
@param {DOM Node} node
@param {String} className
@param {Object} uf
@param {Boolean} valueParse
@return {String} | [
"gets",
"the",
"value",
"of",
"a",
"node",
"which",
"contains",
"the",
"dt",
"-",
"property"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L949-L1001 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, id, propertyName) {
if(this.hasRootID(node, id, propertyName) === false){
var rootids = [];
if(modules.domUtils.hasAttribute(node,'rootids')){
rootids = modules.domUtils.getAttributeList(node,'rootids');
}
rootids.push('id' + id + '-' + propertyName);
modules.domUtils.setAttribute(node, 'rootids', rootids.join(' '));
}
} | javascript | function(node, id, propertyName) {
if(this.hasRootID(node, id, propertyName) === false){
var rootids = [];
if(modules.domUtils.hasAttribute(node,'rootids')){
rootids = modules.domUtils.getAttributeList(node,'rootids');
}
rootids.push('id' + id + '-' + propertyName);
modules.domUtils.setAttribute(node, 'rootids', rootids.join(' '));
}
} | [
"function",
"(",
"node",
",",
"id",
",",
"propertyName",
")",
"{",
"if",
"(",
"this",
".",
"hasRootID",
"(",
"node",
",",
"id",
",",
"propertyName",
")",
"===",
"false",
")",
"{",
"var",
"rootids",
"=",
"[",
"]",
";",
"if",
"(",
"modules",
".",
"domUtils",
".",
"hasAttribute",
"(",
"node",
",",
"'rootids'",
")",
")",
"{",
"rootids",
"=",
"modules",
".",
"domUtils",
".",
"getAttributeList",
"(",
"node",
",",
"'rootids'",
")",
";",
"}",
"rootids",
".",
"push",
"(",
"'id'",
"+",
"id",
"+",
"'-'",
"+",
"propertyName",
")",
";",
"modules",
".",
"domUtils",
".",
"setAttribute",
"(",
"node",
",",
"'rootids'",
",",
"rootids",
".",
"join",
"(",
"' '",
")",
")",
";",
"}",
"}"
] | appends a new rootid to a given node
@param {DOM Node} node
@param {String} id
@param {String} propertyName | [
"appends",
"a",
"new",
"rootid",
"to",
"a",
"given",
"node"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1011-L1020 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, id, propertyName) {
var rootids = [];
if(!modules.domUtils.hasAttribute(node,'rootids')){
return false;
} else {
rootids = modules.domUtils.getAttributeList(node, 'rootids');
return (rootids.indexOf('id' + id + '-' + propertyName) > -1);
}
} | javascript | function(node, id, propertyName) {
var rootids = [];
if(!modules.domUtils.hasAttribute(node,'rootids')){
return false;
} else {
rootids = modules.domUtils.getAttributeList(node, 'rootids');
return (rootids.indexOf('id' + id + '-' + propertyName) > -1);
}
} | [
"function",
"(",
"node",
",",
"id",
",",
"propertyName",
")",
"{",
"var",
"rootids",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"modules",
".",
"domUtils",
".",
"hasAttribute",
"(",
"node",
",",
"'rootids'",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"rootids",
"=",
"modules",
".",
"domUtils",
".",
"getAttributeList",
"(",
"node",
",",
"'rootids'",
")",
";",
"return",
"(",
"rootids",
".",
"indexOf",
"(",
"'id'",
"+",
"id",
"+",
"'-'",
"+",
"propertyName",
")",
">",
"-",
"1",
")",
";",
"}",
"}"
] | does a given node already have a rootid
@param {DOM Node} node
@param {String} id
@param {String} propertyName
@return {Boolean} | [
"does",
"a",
"given",
"node",
"already",
"have",
"a",
"rootid"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1031-L1039 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, propertyType) {
var context = this,
children = [],
out = [],
child,
x,
i;
children = modules.domUtils.getChildren( node );
x = 0;
i = children.length;
while(x < i) {
child = children[x];
var value = null;
if(modules.domUtils.hasAttributeValue(child, 'class', 'value')) {
switch(propertyType) {
case 'p':
value = context.getPValue(child, false);
break;
case 'u':
value = context.getUValue(child, false);
break;
case 'dt':
value = context.getDTValue(child, '', null, false);
break;
}
if(value) {
out.push(modules.utils.trim(value));
}
}
x++;
}
if(out.length > 0) {
if(propertyType === 'p') {
return modules.text.parseText( this.document, out.join(''), this.options.textFormat);
}
if(propertyType === 'u') {
return out.join('');
}
if(propertyType === 'dt') {
var format = 'microformat2';
return modules.dates.concatFragments(out,format).toString(format);
}
} else {
return null;
}
} | javascript | function(node, propertyType) {
var context = this,
children = [],
out = [],
child,
x,
i;
children = modules.domUtils.getChildren( node );
x = 0;
i = children.length;
while(x < i) {
child = children[x];
var value = null;
if(modules.domUtils.hasAttributeValue(child, 'class', 'value')) {
switch(propertyType) {
case 'p':
value = context.getPValue(child, false);
break;
case 'u':
value = context.getUValue(child, false);
break;
case 'dt':
value = context.getDTValue(child, '', null, false);
break;
}
if(value) {
out.push(modules.utils.trim(value));
}
}
x++;
}
if(out.length > 0) {
if(propertyType === 'p') {
return modules.text.parseText( this.document, out.join(''), this.options.textFormat);
}
if(propertyType === 'u') {
return out.join('');
}
if(propertyType === 'dt') {
var format = 'microformat2';
return modules.dates.concatFragments(out,format).toString(format);
}
} else {
return null;
}
} | [
"function",
"(",
"node",
",",
"propertyType",
")",
"{",
"var",
"context",
"=",
"this",
",",
"children",
"=",
"[",
"]",
",",
"out",
"=",
"[",
"]",
",",
"child",
",",
"x",
",",
"i",
";",
"children",
"=",
"modules",
".",
"domUtils",
".",
"getChildren",
"(",
"node",
")",
";",
"x",
"=",
"0",
";",
"i",
"=",
"children",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
"child",
"=",
"children",
"[",
"x",
"]",
";",
"var",
"value",
"=",
"null",
";",
"if",
"(",
"modules",
".",
"domUtils",
".",
"hasAttributeValue",
"(",
"child",
",",
"'class'",
",",
"'value'",
")",
")",
"{",
"switch",
"(",
"propertyType",
")",
"{",
"case",
"'p'",
":",
"value",
"=",
"context",
".",
"getPValue",
"(",
"child",
",",
"false",
")",
";",
"break",
";",
"case",
"'u'",
":",
"value",
"=",
"context",
".",
"getUValue",
"(",
"child",
",",
"false",
")",
";",
"break",
";",
"case",
"'dt'",
":",
"value",
"=",
"context",
".",
"getDTValue",
"(",
"child",
",",
"''",
",",
"null",
",",
"false",
")",
";",
"break",
";",
"}",
"if",
"(",
"value",
")",
"{",
"out",
".",
"push",
"(",
"modules",
".",
"utils",
".",
"trim",
"(",
"value",
")",
")",
";",
"}",
"}",
"x",
"++",
";",
"}",
"if",
"(",
"out",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"propertyType",
"===",
"'p'",
")",
"{",
"return",
"modules",
".",
"text",
".",
"parseText",
"(",
"this",
".",
"document",
",",
"out",
".",
"join",
"(",
"''",
")",
",",
"this",
".",
"options",
".",
"textFormat",
")",
";",
"}",
"if",
"(",
"propertyType",
"===",
"'u'",
")",
"{",
"return",
"out",
".",
"join",
"(",
"''",
")",
";",
"}",
"if",
"(",
"propertyType",
"===",
"'dt'",
")",
"{",
"var",
"format",
"=",
"'microformat2'",
";",
"return",
"modules",
".",
"dates",
".",
"concatFragments",
"(",
"out",
",",
"format",
")",
".",
"toString",
"(",
"format",
")",
";",
"}",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | gets the text of any child nodes with a class value
@param {DOM Node} node
@param {String} propertyName
@return {String || null} | [
"gets",
"the",
"text",
"of",
"any",
"child",
"nodes",
"with",
"a",
"class",
"value"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1050-L1097 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node) {
var out = [],
items,
i,
x;
items = modules.domUtils.getNodesByAttributeValue(node, 'class', 'value-title');
x = 0;
i = items.length;
while(x < i) {
if(modules.domUtils.hasAttribute(items[x], 'title')) {
out.push(modules.domUtils.getAttribute(items[x], 'title'));
}
x++;
}
return out.join('');
} | javascript | function(node) {
var out = [],
items,
i,
x;
items = modules.domUtils.getNodesByAttributeValue(node, 'class', 'value-title');
x = 0;
i = items.length;
while(x < i) {
if(modules.domUtils.hasAttribute(items[x], 'title')) {
out.push(modules.domUtils.getAttribute(items[x], 'title'));
}
x++;
}
return out.join('');
} | [
"function",
"(",
"node",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"items",
",",
"i",
",",
"x",
";",
"items",
"=",
"modules",
".",
"domUtils",
".",
"getNodesByAttributeValue",
"(",
"node",
",",
"'class'",
",",
"'value-title'",
")",
";",
"x",
"=",
"0",
";",
"i",
"=",
"items",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
"if",
"(",
"modules",
".",
"domUtils",
".",
"hasAttribute",
"(",
"items",
"[",
"x",
"]",
",",
"'title'",
")",
")",
"{",
"out",
".",
"push",
"(",
"modules",
".",
"domUtils",
".",
"getAttribute",
"(",
"items",
"[",
"x",
"]",
",",
"'title'",
")",
")",
";",
"}",
"x",
"++",
";",
"}",
"return",
"out",
".",
"join",
"(",
"''",
")",
";",
"}"
] | returns a single string of the 'title' attr from all
the child nodes with the class 'value-title'
@param {DOM Node} node
@return {String} | [
"returns",
"a",
"single",
"string",
"of",
"the",
"title",
"attr",
"from",
"all",
"the",
"child",
"nodes",
"with",
"the",
"class",
"value",
"-",
"title"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1107-L1123 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(name) {
var key;
for(key in modules.maps) {
if(modules.maps[key].root === name || key === name) {
return modules.maps[key];
}
}
return null;
} | javascript | function(name) {
var key;
for(key in modules.maps) {
if(modules.maps[key].root === name || key === name) {
return modules.maps[key];
}
}
return null;
} | [
"function",
"(",
"name",
")",
"{",
"var",
"key",
";",
"for",
"(",
"key",
"in",
"modules",
".",
"maps",
")",
"{",
"if",
"(",
"modules",
".",
"maps",
"[",
"key",
"]",
".",
"root",
"===",
"name",
"||",
"key",
"===",
"name",
")",
"{",
"return",
"modules",
".",
"maps",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | given a v1 or v2 root name, return mapping object
@param {String} name
@return {Object || null} | [
"given",
"a",
"v1",
"or",
"v2",
"root",
"name",
"return",
"mapping",
"object"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1300-L1308 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(names, typeVersion, value) {
var out = {};
// is more than just whitespace
if(value && modules.utils.isOnlyWhiteSpace(value) === false) {
out.value = value;
}
// add type i.e. ["h-card", "h-org"]
if(modules.utils.isArray(names)) {
out.type = names;
} else {
out.type = [names];
}
out.properties = {};
// metadata properties for parsing
out.typeVersion = typeVersion;
out.times = [];
out.dates = [];
out.altValue = null;
return out;
} | javascript | function(names, typeVersion, value) {
var out = {};
// is more than just whitespace
if(value && modules.utils.isOnlyWhiteSpace(value) === false) {
out.value = value;
}
// add type i.e. ["h-card", "h-org"]
if(modules.utils.isArray(names)) {
out.type = names;
} else {
out.type = [names];
}
out.properties = {};
// metadata properties for parsing
out.typeVersion = typeVersion;
out.times = [];
out.dates = [];
out.altValue = null;
return out;
} | [
"function",
"(",
"names",
",",
"typeVersion",
",",
"value",
")",
"{",
"var",
"out",
"=",
"{",
"}",
";",
"if",
"(",
"value",
"&&",
"modules",
".",
"utils",
".",
"isOnlyWhiteSpace",
"(",
"value",
")",
"===",
"false",
")",
"{",
"out",
".",
"value",
"=",
"value",
";",
"}",
"if",
"(",
"modules",
".",
"utils",
".",
"isArray",
"(",
"names",
")",
")",
"{",
"out",
".",
"type",
"=",
"names",
";",
"}",
"else",
"{",
"out",
".",
"type",
"=",
"[",
"names",
"]",
";",
"}",
"out",
".",
"properties",
"=",
"{",
"}",
";",
"out",
".",
"typeVersion",
"=",
"typeVersion",
";",
"out",
".",
"times",
"=",
"[",
"]",
";",
"out",
".",
"dates",
"=",
"[",
"]",
";",
"out",
".",
"altValue",
"=",
"null",
";",
"return",
"out",
";",
"}"
] | creates a blank microformats object
@param {String} name
@param {String} value
@return {Object} | [
"creates",
"a",
"blank",
"microformats",
"object"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1351-L1372 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( microformat ) {
delete microformat.times;
delete microformat.dates;
delete microformat.typeVersion;
delete microformat.altValue;
return microformat;
} | javascript | function( microformat ) {
delete microformat.times;
delete microformat.dates;
delete microformat.typeVersion;
delete microformat.altValue;
return microformat;
} | [
"function",
"(",
"microformat",
")",
"{",
"delete",
"microformat",
".",
"times",
";",
"delete",
"microformat",
".",
"dates",
";",
"delete",
"microformat",
".",
"typeVersion",
";",
"delete",
"microformat",
".",
"altValue",
";",
"return",
"microformat",
";",
"}"
] | removes unwanted microformats property before output
@param {Object} microformat | [
"removes",
"unwanted",
"microformats",
"property",
"before",
"output"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1380-L1386 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(text) {
var i;
i = this.propertyPrefixes.length;
while(i--) {
var prefix = this.propertyPrefixes[i];
if(modules.utils.startWith(text, prefix) && modules.utils.isLowerCase(text)) {
text = text.substr(prefix.length);
}
}
return text;
} | javascript | function(text) {
var i;
i = this.propertyPrefixes.length;
while(i--) {
var prefix = this.propertyPrefixes[i];
if(modules.utils.startWith(text, prefix) && modules.utils.isLowerCase(text)) {
text = text.substr(prefix.length);
}
}
return text;
} | [
"function",
"(",
"text",
")",
"{",
"var",
"i",
";",
"i",
"=",
"this",
".",
"propertyPrefixes",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"var",
"prefix",
"=",
"this",
".",
"propertyPrefixes",
"[",
"i",
"]",
";",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"text",
",",
"prefix",
")",
"&&",
"modules",
".",
"utils",
".",
"isLowerCase",
"(",
"text",
")",
")",
"{",
"text",
"=",
"text",
".",
"substr",
"(",
"prefix",
".",
"length",
")",
";",
"}",
"}",
"return",
"text",
";",
"}"
] | removes microformat property prefixes from text
@param {String} text
@return {String} | [
"removes",
"microformat",
"property",
"prefixes",
"from",
"text"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1396-L1407 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, attrName, baseUrl){
var i,
nodes,
attr;
nodes = modules.domUtils.getNodesByAttribute(node, attrName);
i = nodes.length;
while (i--) {
try{
// the url parser can blow up if the format is not right
attr = modules.domUtils.getAttribute(nodes[i], attrName);
if(attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) {
//attr = urlParser.resolve(baseUrl, attr);
attr = modules.url.resolve(attr, baseUrl);
modules.domUtils.setAttribute(nodes[i], attrName, attr);
}
}catch(err){
// do nothing - convert only the urls we can, leave the rest as they are
}
}
} | javascript | function(node, attrName, baseUrl){
var i,
nodes,
attr;
nodes = modules.domUtils.getNodesByAttribute(node, attrName);
i = nodes.length;
while (i--) {
try{
// the url parser can blow up if the format is not right
attr = modules.domUtils.getAttribute(nodes[i], attrName);
if(attr && attr !== '' && baseUrl !== '' && attr.indexOf('://') === -1) {
//attr = urlParser.resolve(baseUrl, attr);
attr = modules.url.resolve(attr, baseUrl);
modules.domUtils.setAttribute(nodes[i], attrName, attr);
}
}catch(err){
// do nothing - convert only the urls we can, leave the rest as they are
}
}
} | [
"function",
"(",
"node",
",",
"attrName",
",",
"baseUrl",
")",
"{",
"var",
"i",
",",
"nodes",
",",
"attr",
";",
"nodes",
"=",
"modules",
".",
"domUtils",
".",
"getNodesByAttribute",
"(",
"node",
",",
"attrName",
")",
";",
"i",
"=",
"nodes",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"try",
"{",
"attr",
"=",
"modules",
".",
"domUtils",
".",
"getAttribute",
"(",
"nodes",
"[",
"i",
"]",
",",
"attrName",
")",
";",
"if",
"(",
"attr",
"&&",
"attr",
"!==",
"''",
"&&",
"baseUrl",
"!==",
"''",
"&&",
"attr",
".",
"indexOf",
"(",
"'://'",
")",
"===",
"-",
"1",
")",
"{",
"attr",
"=",
"modules",
".",
"url",
".",
"resolve",
"(",
"attr",
",",
"baseUrl",
")",
";",
"modules",
".",
"domUtils",
".",
"setAttribute",
"(",
"nodes",
"[",
"i",
"]",
",",
"attrName",
",",
"attr",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"}",
"}",
"}"
] | expands all relative URLs to absolute ones where it can
@param {DOM Node} node
@param {String} attrName
@param {String} baseUrl | [
"expands",
"all",
"relative",
"URLs",
"to",
"absolute",
"ones",
"where",
"it",
"can"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1417-L1437 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(options) {
var key;
for(key in options) {
if(options.hasOwnProperty(key)) {
this.options[key] = options[key];
}
}
} | javascript | function(options) {
var key;
for(key in options) {
if(options.hasOwnProperty(key)) {
this.options[key] = options[key];
}
}
} | [
"function",
"(",
"options",
")",
"{",
"var",
"key",
";",
"for",
"(",
"key",
"in",
"options",
")",
"{",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"this",
".",
"options",
"[",
"key",
"]",
"=",
"options",
"[",
"key",
"]",
";",
"}",
"}",
"}"
] | merges passed and default options -single level clone of properties
@param {Object} options | [
"merges",
"passed",
"and",
"default",
"options",
"-",
"single",
"level",
"clone",
"of",
"properties"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1446-L1453 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(rootNode){
var arr,
i;
arr = modules.domUtils.getNodesByAttribute(rootNode, 'rootids');
i = arr.length;
while(i--) {
modules.domUtils.removeAttribute(arr[i],'rootids');
}
} | javascript | function(rootNode){
var arr,
i;
arr = modules.domUtils.getNodesByAttribute(rootNode, 'rootids');
i = arr.length;
while(i--) {
modules.domUtils.removeAttribute(arr[i],'rootids');
}
} | [
"function",
"(",
"rootNode",
")",
"{",
"var",
"arr",
",",
"i",
";",
"arr",
"=",
"modules",
".",
"domUtils",
".",
"getNodesByAttribute",
"(",
"rootNode",
",",
"'rootids'",
")",
";",
"i",
"=",
"arr",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"modules",
".",
"domUtils",
".",
"removeAttribute",
"(",
"arr",
"[",
"i",
"]",
",",
"'rootids'",
")",
";",
"}",
"}"
] | removes all rootid attributes
@param {DOM Node} rootNode | [
"removes",
"all",
"rootid",
"attributes"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L1461-L1470 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( text ) {
if(text && this.isString(text)){
return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, '');
}else{
return '';
}
} | javascript | function( text ) {
if(text && this.isString(text)){
return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, '');
}else{
return '';
}
} | [
"function",
"(",
"text",
")",
"{",
"if",
"(",
"text",
"&&",
"this",
".",
"isString",
"(",
"text",
")",
")",
"{",
"return",
"(",
"text",
".",
"trim",
"(",
")",
")",
"?",
"text",
".",
"trim",
"(",
")",
":",
"text",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | removes spaces at front and back of text
@param {String} text
@return {String} | [
"removes",
"spaces",
"at",
"front",
"and",
"back",
"of",
"text"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2321-L2327 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( text, index, character ) {
if(text && text.length > index){
return text.substr(0, index) + character + text.substr(index+character.length);
}else{
return text;
}
} | javascript | function( text, index, character ) {
if(text && text.length > index){
return text.substr(0, index) + character + text.substr(index+character.length);
}else{
return text;
}
} | [
"function",
"(",
"text",
",",
"index",
",",
"character",
")",
"{",
"if",
"(",
"text",
"&&",
"text",
".",
"length",
">",
"index",
")",
"{",
"return",
"text",
".",
"substr",
"(",
"0",
",",
"index",
")",
"+",
"character",
"+",
"text",
".",
"substr",
"(",
"index",
"+",
"character",
".",
"length",
")",
";",
"}",
"else",
"{",
"return",
"text",
";",
"}",
"}"
] | replaces a character in text
@param {String} text
@param {Int} index
@param {String} character
@return {String} | [
"replaces",
"a",
"character",
"in",
"text"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2338-L2344 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( text ){
if(text && text.length){
var i = text.length,
x = 0;
// turn all whitespace chars at end into spaces
while (i--) {
if(this.isOnlyWhiteSpace(text[i])){
text = this.replaceCharAt( text, i, ' ' );
}else{
break;
}
}
// turn all whitespace chars at start into spaces
i = text.length;
while (x < i) {
if(this.isOnlyWhiteSpace(text[x])){
text = this.replaceCharAt( text, i, ' ' );
}else{
break;
}
x++;
}
}
return this.trim(text);
} | javascript | function( text ){
if(text && text.length){
var i = text.length,
x = 0;
// turn all whitespace chars at end into spaces
while (i--) {
if(this.isOnlyWhiteSpace(text[i])){
text = this.replaceCharAt( text, i, ' ' );
}else{
break;
}
}
// turn all whitespace chars at start into spaces
i = text.length;
while (x < i) {
if(this.isOnlyWhiteSpace(text[x])){
text = this.replaceCharAt( text, i, ' ' );
}else{
break;
}
x++;
}
}
return this.trim(text);
} | [
"function",
"(",
"text",
")",
"{",
"if",
"(",
"text",
"&&",
"text",
".",
"length",
")",
"{",
"var",
"i",
"=",
"text",
".",
"length",
",",
"x",
"=",
"0",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"this",
".",
"isOnlyWhiteSpace",
"(",
"text",
"[",
"i",
"]",
")",
")",
"{",
"text",
"=",
"this",
".",
"replaceCharAt",
"(",
"text",
",",
"i",
",",
"' '",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"i",
"=",
"text",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
"if",
"(",
"this",
".",
"isOnlyWhiteSpace",
"(",
"text",
"[",
"x",
"]",
")",
")",
"{",
"text",
"=",
"this",
".",
"replaceCharAt",
"(",
"text",
",",
"i",
",",
"' '",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"x",
"++",
";",
"}",
"}",
"return",
"this",
".",
"trim",
"(",
"text",
")",
";",
"}"
] | removes whitespace, tabs and returns from start and end of text
@param {String} text
@return {String} | [
"removes",
"whitespace",
"tabs",
"and",
"returns",
"from",
"start",
"and",
"end",
"of",
"text"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2353-L2379 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(property, reverse) {
reverse = (reverse) ? -1 : 1;
return function (a, b) {
a = a[property];
b = b[property];
if (a < b) {
return reverse * -1;
}
if (a > b) {
return reverse * 1;
}
return 0;
};
} | javascript | function(property, reverse) {
reverse = (reverse) ? -1 : 1;
return function (a, b) {
a = a[property];
b = b[property];
if (a < b) {
return reverse * -1;
}
if (a > b) {
return reverse * 1;
}
return 0;
};
} | [
"function",
"(",
"property",
",",
"reverse",
")",
"{",
"reverse",
"=",
"(",
"reverse",
")",
"?",
"-",
"1",
":",
"1",
";",
"return",
"function",
"(",
"a",
",",
"b",
")",
"{",
"a",
"=",
"a",
"[",
"property",
"]",
";",
"b",
"=",
"b",
"[",
"property",
"]",
";",
"if",
"(",
"a",
"<",
"b",
")",
"{",
"return",
"reverse",
"*",
"-",
"1",
";",
"}",
"if",
"(",
"a",
">",
"b",
")",
"{",
"return",
"reverse",
"*",
"1",
";",
"}",
"return",
"0",
";",
"}",
";",
"}"
] | a sort function - to sort objects in an array by a given property
@param {String} property
@param {Boolean} reverse
@return {Int} | [
"a",
"sort",
"function",
"-",
"to",
"sort",
"objects",
"in",
"an",
"array",
"by",
"a",
"given",
"property"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2428-L2441 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function () {
if (typeof DOMParser === undefined) {
try {
return Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);
} catch (e) {
return;
}
} else {
return new DOMParser();
}
} | javascript | function () {
if (typeof DOMParser === undefined) {
try {
return Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);
} catch (e) {
return;
}
} else {
return new DOMParser();
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"DOMParser",
"===",
"undefined",
")",
"{",
"try",
"{",
"return",
"Components",
".",
"classes",
"[",
"\"@mozilla.org/xmlextras/domparser;1\"",
"]",
".",
"createInstance",
"(",
"Components",
".",
"interfaces",
".",
"nsIDOMParser",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"return",
"new",
"DOMParser",
"(",
")",
";",
"}",
"}"
] | gets DOMParser object
@return {Object || undefined} | [
"gets",
"DOMParser",
"object"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2458-L2469 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, attributeName) {
var out = [],
attList;
attList = node.getAttribute(attributeName);
if(attList && attList !== '') {
if(attList.indexOf(' ') > -1) {
out = attList.split(' ');
} else {
out.push(attList);
}
}
return out;
} | javascript | function(node, attributeName) {
var out = [],
attList;
attList = node.getAttribute(attributeName);
if(attList && attList !== '') {
if(attList.indexOf(' ') > -1) {
out = attList.split(' ');
} else {
out.push(attList);
}
}
return out;
} | [
"function",
"(",
"node",
",",
"attributeName",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"attList",
";",
"attList",
"=",
"node",
".",
"getAttribute",
"(",
"attributeName",
")",
";",
"if",
"(",
"attList",
"&&",
"attList",
"!==",
"''",
")",
"{",
"if",
"(",
"attList",
".",
"indexOf",
"(",
"' '",
")",
">",
"-",
"1",
")",
"{",
"out",
"=",
"attList",
".",
"split",
"(",
"' '",
")",
";",
"}",
"else",
"{",
"out",
".",
"push",
"(",
"attList",
")",
";",
"}",
"}",
"return",
"out",
";",
"}"
] | get value of a Node attribute as an array
@param {DOM Node} node
@param {String} attributeName
@return {Array} | [
"get",
"value",
"of",
"a",
"Node",
"attribute",
"as",
"an",
"array"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2671-L2684 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(rootNode, name, value) {
var arr = [],
x = 0,
i,
out = [];
arr = this.getNodesByAttribute(rootNode, name);
if(arr) {
i = arr.length;
while(x < i) {
if(this.hasAttributeValue(arr[x], name, value)) {
out.push(arr[x]);
}
x++;
}
}
return out;
} | javascript | function(rootNode, name, value) {
var arr = [],
x = 0,
i,
out = [];
arr = this.getNodesByAttribute(rootNode, name);
if(arr) {
i = arr.length;
while(x < i) {
if(this.hasAttributeValue(arr[x], name, value)) {
out.push(arr[x]);
}
x++;
}
}
return out;
} | [
"function",
"(",
"rootNode",
",",
"name",
",",
"value",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
",",
"x",
"=",
"0",
",",
"i",
",",
"out",
"=",
"[",
"]",
";",
"arr",
"=",
"this",
".",
"getNodesByAttribute",
"(",
"rootNode",
",",
"name",
")",
";",
"if",
"(",
"arr",
")",
"{",
"i",
"=",
"arr",
".",
"length",
";",
"while",
"(",
"x",
"<",
"i",
")",
"{",
"if",
"(",
"this",
".",
"hasAttributeValue",
"(",
"arr",
"[",
"x",
"]",
",",
"name",
",",
"value",
")",
")",
"{",
"out",
".",
"push",
"(",
"arr",
"[",
"x",
"]",
")",
";",
"}",
"x",
"++",
";",
"}",
"}",
"return",
"out",
";",
"}"
] | gets all child nodes with a given attribute containing a given value
@param {DOM Node} node
@param {String} attributeName
@return {DOM NodeList} | [
"gets",
"all",
"child",
"nodes",
"with",
"a",
"given",
"attribute",
"containing",
"a",
"given",
"value"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2707-L2724 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, tagNames, attributeName) {
var i = tagNames.length;
while(i--) {
if(node.tagName.toLowerCase() === tagNames[i]) {
var attrValue = this.getAttribute(node, attributeName);
if(attrValue && attrValue !== '') {
return attrValue;
}
}
}
return null;
} | javascript | function(node, tagNames, attributeName) {
var i = tagNames.length;
while(i--) {
if(node.tagName.toLowerCase() === tagNames[i]) {
var attrValue = this.getAttribute(node, attributeName);
if(attrValue && attrValue !== '') {
return attrValue;
}
}
}
return null;
} | [
"function",
"(",
"node",
",",
"tagNames",
",",
"attributeName",
")",
"{",
"var",
"i",
"=",
"tagNames",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"===",
"tagNames",
"[",
"i",
"]",
")",
"{",
"var",
"attrValue",
"=",
"this",
".",
"getAttribute",
"(",
"node",
",",
"attributeName",
")",
";",
"if",
"(",
"attrValue",
"&&",
"attrValue",
"!==",
"''",
")",
"{",
"return",
"attrValue",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | gets attribute value from controlled list of tags
@param {Array} tagNames
@param {String} attributeName
@return {String || null} | [
"gets",
"attribute",
"value",
"from",
"controlled",
"list",
"of",
"tags"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2734-L2746 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, tagNames){
var i = tagNames.length;
while(i--) {
if(node.tagName.toLowerCase() === tagNames[i]) {
return true;
}
}
return false;
} | javascript | function(node, tagNames){
var i = tagNames.length;
while(i--) {
if(node.tagName.toLowerCase() === tagNames[i]) {
return true;
}
}
return false;
} | [
"function",
"(",
"node",
",",
"tagNames",
")",
"{",
"var",
"i",
"=",
"tagNames",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"===",
"tagNames",
"[",
"i",
"]",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | is a node one of a list of tags
@param {DOM Node} rootNode
@param {Array} tagNames
@return {Boolean} | [
"is",
"a",
"node",
"one",
"of",
"a",
"list",
"of",
"tags"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2818-L2826 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node) {
var newNode = node.cloneNode(true);
if(this.hasAttribute(node, 'id')){
this.removeAttribute(node, 'id')
}
return newNode;
} | javascript | function(node) {
var newNode = node.cloneNode(true);
if(this.hasAttribute(node, 'id')){
this.removeAttribute(node, 'id')
}
return newNode;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"newNode",
"=",
"node",
".",
"cloneNode",
"(",
"true",
")",
";",
"if",
"(",
"this",
".",
"hasAttribute",
"(",
"node",
",",
"'id'",
")",
")",
"{",
"this",
".",
"removeAttribute",
"(",
"node",
",",
"'id'",
")",
"}",
"return",
"newNode",
";",
"}"
] | abstracts DOM cloneNode
@param {DOM Node} node
@return {DOM Node} | [
"abstracts",
"DOM",
"cloneNode"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2862-L2868 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(node, tagNames) {
for (var i = 0; i < tagNames.length; i++) {
if(node.getElementsByTagName){
var elements = node.getElementsByTagName(tagNames[i]);
while (elements[0]) {
elements[0].parentNode.removeChild(elements[0])
}
}
}
return node;
} | javascript | function(node, tagNames) {
for (var i = 0; i < tagNames.length; i++) {
if(node.getElementsByTagName){
var elements = node.getElementsByTagName(tagNames[i]);
while (elements[0]) {
elements[0].parentNode.removeChild(elements[0])
}
}
}
return node;
} | [
"function",
"(",
"node",
",",
"tagNames",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tagNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"node",
".",
"getElementsByTagName",
")",
"{",
"var",
"elements",
"=",
"node",
".",
"getElementsByTagName",
"(",
"tagNames",
"[",
"i",
"]",
")",
";",
"while",
"(",
"elements",
"[",
"0",
"]",
")",
"{",
"elements",
"[",
"0",
"]",
".",
"parentNode",
".",
"removeChild",
"(",
"elements",
"[",
"0",
"]",
")",
"}",
"}",
"}",
"return",
"node",
";",
"}"
] | removes all the descendant tags by name
@param {DOM Node} node
@param {Array} tagNames
@return {DOM Node} | [
"removes",
"all",
"the",
"descendant",
"tags",
"by",
"name"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2878-L2888 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( node ){
var nodeStr = node.outerHTML,
attrs = [];
for (var i = 0; i < node.attributes.length; i++) {
var attr = node.attributes[i];
attr.indexNum = nodeStr.indexOf(attr.name);
attrs.push( attr );
}
return attrs.sort( modules.utils.sortObjects( 'indexNum' ) );
} | javascript | function( node ){
var nodeStr = node.outerHTML,
attrs = [];
for (var i = 0; i < node.attributes.length; i++) {
var attr = node.attributes[i];
attr.indexNum = nodeStr.indexOf(attr.name);
attrs.push( attr );
}
return attrs.sort( modules.utils.sortObjects( 'indexNum' ) );
} | [
"function",
"(",
"node",
")",
"{",
"var",
"nodeStr",
"=",
"node",
".",
"outerHTML",
",",
"attrs",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
"attributes",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"attr",
"=",
"node",
".",
"attributes",
"[",
"i",
"]",
";",
"attr",
".",
"indexNum",
"=",
"nodeStr",
".",
"indexOf",
"(",
"attr",
".",
"name",
")",
";",
"attrs",
".",
"push",
"(",
"attr",
")",
";",
"}",
"return",
"attrs",
".",
"sort",
"(",
"modules",
".",
"utils",
".",
"sortObjects",
"(",
"'indexNum'",
")",
")",
";",
"}"
] | gets the attributes of a node - ordered by sequence in html
@param {DOM Node} node
@return {Array} | [
"gets",
"the",
"attributes",
"of",
"a",
"node",
"-",
"ordered",
"by",
"sequence",
"in",
"html"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2912-L2923 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( document ){
var newNode,
newDocument = null;
if( this.canCloneDocument( document )){
newDocument = document.implementation.createHTMLDocument('');
newNode = newDocument.importNode( document.documentElement, true );
newDocument.replaceChild(newNode, newDocument.querySelector('html'));
}
return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document;
} | javascript | function( document ){
var newNode,
newDocument = null;
if( this.canCloneDocument( document )){
newDocument = document.implementation.createHTMLDocument('');
newNode = newDocument.importNode( document.documentElement, true );
newDocument.replaceChild(newNode, newDocument.querySelector('html'));
}
return (newNode && newNode.nodeType && newNode.nodeType === 1)? newDocument : document;
} | [
"function",
"(",
"document",
")",
"{",
"var",
"newNode",
",",
"newDocument",
"=",
"null",
";",
"if",
"(",
"this",
".",
"canCloneDocument",
"(",
"document",
")",
")",
"{",
"newDocument",
"=",
"document",
".",
"implementation",
".",
"createHTMLDocument",
"(",
"''",
")",
";",
"newNode",
"=",
"newDocument",
".",
"importNode",
"(",
"document",
".",
"documentElement",
",",
"true",
")",
";",
"newDocument",
".",
"replaceChild",
"(",
"newNode",
",",
"newDocument",
".",
"querySelector",
"(",
"'html'",
")",
")",
";",
"}",
"return",
"(",
"newNode",
"&&",
"newNode",
".",
"nodeType",
"&&",
"newNode",
".",
"nodeType",
"===",
"1",
")",
"?",
"newDocument",
":",
"document",
";",
"}"
] | clones a DOM document
@param {DOM Document} document
@return {DOM Document} | [
"clones",
"a",
"DOM",
"document"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2945-L2955 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function (node) {
var parent = node.parentNode,
i = -1,
child;
while (parent && (child = parent.childNodes[++i])){
if (child === node){
return i;
}
}
return -1;
} | javascript | function (node) {
var parent = node.parentNode,
i = -1,
child;
while (parent && (child = parent.childNodes[++i])){
if (child === node){
return i;
}
}
return -1;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parentNode",
",",
"i",
"=",
"-",
"1",
",",
"child",
";",
"while",
"(",
"parent",
"&&",
"(",
"child",
"=",
"parent",
".",
"childNodes",
"[",
"++",
"i",
"]",
")",
")",
"{",
"if",
"(",
"child",
"===",
"node",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | get the child index of a node. Used to create a node path
@param {DOM Node} node
@return {Int} | [
"get",
"the",
"child",
"index",
"of",
"a",
"node",
".",
"Used",
"to",
"create",
"a",
"node",
"path"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L2975-L2985 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function (document, path) {
var node = document.documentElement,
i = 0,
index;
while ((index = path[++i]) > -1){
node = node.childNodes[index];
}
return node;
} | javascript | function (document, path) {
var node = document.documentElement,
i = 0,
index;
while ((index = path[++i]) > -1){
node = node.childNodes[index];
}
return node;
} | [
"function",
"(",
"document",
",",
"path",
")",
"{",
"var",
"node",
"=",
"document",
".",
"documentElement",
",",
"i",
"=",
"0",
",",
"index",
";",
"while",
"(",
"(",
"index",
"=",
"path",
"[",
"++",
"i",
"]",
")",
">",
"-",
"1",
")",
"{",
"node",
"=",
"node",
".",
"childNodes",
"[",
"index",
"]",
";",
"}",
"return",
"node",
";",
"}"
] | get a node from a path.
@param {DOM document} document
@param {Array} path
@return {DOM Node} | [
"get",
"a",
"node",
"from",
"a",
"path",
"."
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3039-L3047 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( tagName, text ){
var node = this.document.createElement(tagName);
node.innerHTML = text;
return node;
} | javascript | function( tagName, text ){
var node = this.document.createElement(tagName);
node.innerHTML = text;
return node;
} | [
"function",
"(",
"tagName",
",",
"text",
")",
"{",
"var",
"node",
"=",
"this",
".",
"document",
".",
"createElement",
"(",
"tagName",
")",
";",
"node",
".",
"innerHTML",
"=",
"text",
";",
"return",
"node",
";",
"}"
] | create a node with text content
@param {String} tagName
@param {String} text
@return {DOM node} | [
"create",
"a",
"node",
"with",
"text",
"content"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3079-L3083 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(){
//this._domParser = new DOMParser();
this._domParser = modules.domUtils.getDOMParser();
// do not use a head tag it does not work with IE9
this._html = '<base id="base" href=""></base><a id="link" href=""></a>';
this._nodes = this._domParser.parseFromString( this._html, 'text/html' );
this._baseNode = modules.domUtils.getElementById(this._nodes,'base');
this._linkNode = modules.domUtils.getElementById(this._nodes,'link');
} | javascript | function(){
//this._domParser = new DOMParser();
this._domParser = modules.domUtils.getDOMParser();
// do not use a head tag it does not work with IE9
this._html = '<base id="base" href=""></base><a id="link" href=""></a>';
this._nodes = this._domParser.parseFromString( this._html, 'text/html' );
this._baseNode = modules.domUtils.getElementById(this._nodes,'base');
this._linkNode = modules.domUtils.getElementById(this._nodes,'link');
} | [
"function",
"(",
")",
"{",
"this",
".",
"_domParser",
"=",
"modules",
".",
"domUtils",
".",
"getDOMParser",
"(",
")",
";",
"this",
".",
"_html",
"=",
"'<base id=\"base\" href=\"\"></base><a id=\"link\" href=\"\"></a>'",
";",
"this",
".",
"_nodes",
"=",
"this",
".",
"_domParser",
".",
"parseFromString",
"(",
"this",
".",
"_html",
",",
"'text/html'",
")",
";",
"this",
".",
"_baseNode",
"=",
"modules",
".",
"domUtils",
".",
"getElementById",
"(",
"this",
".",
"_nodes",
",",
"'base'",
")",
";",
"this",
".",
"_linkNode",
"=",
"modules",
".",
"domUtils",
".",
"getElementById",
"(",
"this",
".",
"_nodes",
",",
"'link'",
")",
";",
"}"
] | creates DOM objects needed to resolve URLs | [
"creates",
"DOM",
"objects",
"needed",
"to",
"resolve",
"URLs"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3096-L3104 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(url, baseUrl) {
// use modern URL web API where we can
if(modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1){
// this try catch is required as IE has an URL object but no constuctor support
// http://glennjones.net/articles/the-problem-with-window-url
try {
var resolved = new URL(url, baseUrl).toString();
// deal with early Webkit not throwing an error - for Safari
if(resolved === '[object URL]'){
resolved = URI.resolve(baseUrl, url);
}
return resolved;
}catch(e){
// otherwise fallback to DOM
if(this._domParser === undefined){
this.init();
}
// do not use setAttribute it does not work with IE9
this._baseNode.href = baseUrl;
this._linkNode.href = url;
// dont use getAttribute as it returns orginal value not resolved
return this._linkNode.href;
}
}else{
if(modules.utils.isString(url)){
return url;
}
return '';
}
} | javascript | function(url, baseUrl) {
// use modern URL web API where we can
if(modules.utils.isString(url) && modules.utils.isString(baseUrl) && url.indexOf('://') === -1){
// this try catch is required as IE has an URL object but no constuctor support
// http://glennjones.net/articles/the-problem-with-window-url
try {
var resolved = new URL(url, baseUrl).toString();
// deal with early Webkit not throwing an error - for Safari
if(resolved === '[object URL]'){
resolved = URI.resolve(baseUrl, url);
}
return resolved;
}catch(e){
// otherwise fallback to DOM
if(this._domParser === undefined){
this.init();
}
// do not use setAttribute it does not work with IE9
this._baseNode.href = baseUrl;
this._linkNode.href = url;
// dont use getAttribute as it returns orginal value not resolved
return this._linkNode.href;
}
}else{
if(modules.utils.isString(url)){
return url;
}
return '';
}
} | [
"function",
"(",
"url",
",",
"baseUrl",
")",
"{",
"if",
"(",
"modules",
".",
"utils",
".",
"isString",
"(",
"url",
")",
"&&",
"modules",
".",
"utils",
".",
"isString",
"(",
"baseUrl",
")",
"&&",
"url",
".",
"indexOf",
"(",
"'://'",
")",
"===",
"-",
"1",
")",
"{",
"try",
"{",
"var",
"resolved",
"=",
"new",
"URL",
"(",
"url",
",",
"baseUrl",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"resolved",
"===",
"'[object URL]'",
")",
"{",
"resolved",
"=",
"URI",
".",
"resolve",
"(",
"baseUrl",
",",
"url",
")",
";",
"}",
"return",
"resolved",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"this",
".",
"_domParser",
"===",
"undefined",
")",
"{",
"this",
".",
"init",
"(",
")",
";",
"}",
"this",
".",
"_baseNode",
".",
"href",
"=",
"baseUrl",
";",
"this",
".",
"_linkNode",
".",
"href",
"=",
"url",
";",
"return",
"this",
".",
"_linkNode",
".",
"href",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"modules",
".",
"utils",
".",
"isString",
"(",
"url",
")",
")",
"{",
"return",
"url",
";",
"}",
"return",
"''",
";",
"}",
"}"
] | resolves url to absolute version using baseUrl
@param {String} url
@param {String} baseUrl
@return {String} | [
"resolves",
"url",
"to",
"absolute",
"version",
"using",
"baseUrl"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3114-L3145 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function() {
switch( this.format.toLowerCase() ) {
case 'microformat2':
this.sep = ' ';
this.dsep = '-';
this.tsep = ':';
this.tzsep = '';
this.tzZulu = 'Z';
break;
case 'rfc3339':
this.sep = 'T';
this.dsep = '';
this.tsep = '';
this.tzsep = '';
this.tzZulu = 'Z';
break;
case 'w3c':
this.sep = 'T';
this.dsep = '-';
this.tsep = ':';
this.tzsep = ':';
this.tzZulu = 'Z';
break;
case 'html5':
this.sep = ' ';
this.dsep = '-';
this.tsep = ':';
this.tzsep = ':';
this.tzZulu = 'Z';
break;
default:
// auto - defined by format of input string
this.sep = this.autoProfile.sep;
this.dsep = this.autoProfile.dsep;
this.tsep = this.autoProfile.tsep;
this.tzsep = this.autoProfile.tzsep;
this.tzZulu = this.autoProfile.tzZulu;
}
} | javascript | function() {
switch( this.format.toLowerCase() ) {
case 'microformat2':
this.sep = ' ';
this.dsep = '-';
this.tsep = ':';
this.tzsep = '';
this.tzZulu = 'Z';
break;
case 'rfc3339':
this.sep = 'T';
this.dsep = '';
this.tsep = '';
this.tzsep = '';
this.tzZulu = 'Z';
break;
case 'w3c':
this.sep = 'T';
this.dsep = '-';
this.tsep = ':';
this.tzsep = ':';
this.tzZulu = 'Z';
break;
case 'html5':
this.sep = ' ';
this.dsep = '-';
this.tsep = ':';
this.tzsep = ':';
this.tzZulu = 'Z';
break;
default:
// auto - defined by format of input string
this.sep = this.autoProfile.sep;
this.dsep = this.autoProfile.dsep;
this.tsep = this.autoProfile.tsep;
this.tzsep = this.autoProfile.tzsep;
this.tzZulu = this.autoProfile.tzZulu;
}
} | [
"function",
"(",
")",
"{",
"switch",
"(",
"this",
".",
"format",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"'microformat2'",
":",
"this",
".",
"sep",
"=",
"' '",
";",
"this",
".",
"dsep",
"=",
"'-'",
";",
"this",
".",
"tsep",
"=",
"':'",
";",
"this",
".",
"tzsep",
"=",
"''",
";",
"this",
".",
"tzZulu",
"=",
"'Z'",
";",
"break",
";",
"case",
"'rfc3339'",
":",
"this",
".",
"sep",
"=",
"'T'",
";",
"this",
".",
"dsep",
"=",
"''",
";",
"this",
".",
"tsep",
"=",
"''",
";",
"this",
".",
"tzsep",
"=",
"''",
";",
"this",
".",
"tzZulu",
"=",
"'Z'",
";",
"break",
";",
"case",
"'w3c'",
":",
"this",
".",
"sep",
"=",
"'T'",
";",
"this",
".",
"dsep",
"=",
"'-'",
";",
"this",
".",
"tsep",
"=",
"':'",
";",
"this",
".",
"tzsep",
"=",
"':'",
";",
"this",
".",
"tzZulu",
"=",
"'Z'",
";",
"break",
";",
"case",
"'html5'",
":",
"this",
".",
"sep",
"=",
"' '",
";",
"this",
".",
"dsep",
"=",
"'-'",
";",
"this",
".",
"tsep",
"=",
"':'",
";",
"this",
".",
"tzsep",
"=",
"':'",
";",
"this",
".",
"tzZulu",
"=",
"'Z'",
";",
"break",
";",
"default",
":",
"this",
".",
"sep",
"=",
"this",
".",
"autoProfile",
".",
"sep",
";",
"this",
".",
"dsep",
"=",
"this",
".",
"autoProfile",
".",
"dsep",
";",
"this",
".",
"tsep",
"=",
"this",
".",
"autoProfile",
".",
"tsep",
";",
"this",
".",
"tzsep",
"=",
"this",
".",
"autoProfile",
".",
"tzsep",
";",
"this",
".",
"tzZulu",
"=",
"this",
".",
"autoProfile",
".",
"tzZulu",
";",
"}",
"}"
] | set the current profile to W3C Note, RFC 3339, HTML5, or auto profile | [
"set",
"the",
"current",
"profile",
"to",
"W3C",
"Note",
"RFC",
"3339",
"HTML5",
"or",
"auto",
"profile"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3544-L3582 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( text ) {
if(modules.utils.isString( text )){
text = text.toLowerCase();
if(modules.utils.startWith(text, 'p') ){
return true;
}
}
return false;
} | javascript | function( text ) {
if(modules.utils.isString( text )){
text = text.toLowerCase();
if(modules.utils.startWith(text, 'p') ){
return true;
}
}
return false;
} | [
"function",
"(",
"text",
")",
"{",
"if",
"(",
"modules",
".",
"utils",
".",
"isString",
"(",
"text",
")",
")",
"{",
"text",
"=",
"text",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"modules",
".",
"utils",
".",
"startWith",
"(",
"text",
",",
"'p'",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | simple test of whether ISO date string is a duration i.e. PY17M or PW12
@param {String} text
@return {Boolean} | [
"simple",
"test",
"of",
"whether",
"ISO",
"date",
"string",
"is",
"a",
"duration",
"i",
".",
"e",
".",
"PY17M",
"or",
"PW12"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3672-L3680 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(date, time, format) {
var isodate = new modules.ISODate(date, format),
isotime = new modules.ISODate();
isotime.parseTime(this.parseAmPmTime(time), format);
if(isodate.hasFullDate() && isotime.hasTime()) {
isodate.tH = isotime.tH;
isodate.tM = isotime.tM;
isodate.tS = isotime.tS;
isodate.tD = isotime.tD;
return isodate;
} else {
if(isodate.hasFullDate()){
return isodate;
}
return new modules.ISODate();
}
} | javascript | function(date, time, format) {
var isodate = new modules.ISODate(date, format),
isotime = new modules.ISODate();
isotime.parseTime(this.parseAmPmTime(time), format);
if(isodate.hasFullDate() && isotime.hasTime()) {
isodate.tH = isotime.tH;
isodate.tM = isotime.tM;
isodate.tS = isotime.tS;
isodate.tD = isotime.tD;
return isodate;
} else {
if(isodate.hasFullDate()){
return isodate;
}
return new modules.ISODate();
}
} | [
"function",
"(",
"date",
",",
"time",
",",
"format",
")",
"{",
"var",
"isodate",
"=",
"new",
"modules",
".",
"ISODate",
"(",
"date",
",",
"format",
")",
",",
"isotime",
"=",
"new",
"modules",
".",
"ISODate",
"(",
")",
";",
"isotime",
".",
"parseTime",
"(",
"this",
".",
"parseAmPmTime",
"(",
"time",
")",
",",
"format",
")",
";",
"if",
"(",
"isodate",
".",
"hasFullDate",
"(",
")",
"&&",
"isotime",
".",
"hasTime",
"(",
")",
")",
"{",
"isodate",
".",
"tH",
"=",
"isotime",
".",
"tH",
";",
"isodate",
".",
"tM",
"=",
"isotime",
".",
"tM",
";",
"isodate",
".",
"tS",
"=",
"isotime",
".",
"tS",
";",
"isodate",
".",
"tD",
"=",
"isotime",
".",
"tD",
";",
"return",
"isodate",
";",
"}",
"else",
"{",
"if",
"(",
"isodate",
".",
"hasFullDate",
"(",
")",
")",
"{",
"return",
"isodate",
";",
"}",
"return",
"new",
"modules",
".",
"ISODate",
"(",
")",
";",
"}",
"}"
] | overlays a time on a date to return the union of the two
@param {String} date
@param {String} time
@param {String} format ( Modules.ISODate profile format )
@return {Object} Modules.ISODate | [
"overlays",
"a",
"time",
"on",
"a",
"date",
"to",
"return",
"the",
"union",
"of",
"the",
"two"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3777-L3794 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function (arr, format) {
var out = new modules.ISODate(),
i = 0,
value = '';
// if the fragment already contains a full date just return it once
if(arr[0].toUpperCase().match('T')) {
return new modules.ISODate(arr[0], format);
}else{
for(i = 0; i < arr.length; i++) {
value = arr[i];
// date pattern
if( value.charAt(4) === '-' && out.hasFullDate() === false ){
out.parseDate(value);
}
// time pattern
if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) {
// split time and timezone
var items = this.splitTimeAndZone(value);
value = items[0];
// parse any use of am/pm
value = this.parseAmPmTime(value);
out.parseTime(value);
// parse any timezone
if(items.length > 1){
out.parseTimeZone(items[1], format);
}
}
// timezone pattern
if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') {
if( out.hasTimeZone() === false ){
out.parseTimeZone(value);
}
}
}
// alway imply minutes
if(out.tM === -1){
out.tM = '00';
}
return out;
}
} | javascript | function (arr, format) {
var out = new modules.ISODate(),
i = 0,
value = '';
// if the fragment already contains a full date just return it once
if(arr[0].toUpperCase().match('T')) {
return new modules.ISODate(arr[0], format);
}else{
for(i = 0; i < arr.length; i++) {
value = arr[i];
// date pattern
if( value.charAt(4) === '-' && out.hasFullDate() === false ){
out.parseDate(value);
}
// time pattern
if( (value.indexOf(':') > -1 || modules.utils.isNumber( this.parseAmPmTime(value) )) && out.hasTime() === false ) {
// split time and timezone
var items = this.splitTimeAndZone(value);
value = items[0];
// parse any use of am/pm
value = this.parseAmPmTime(value);
out.parseTime(value);
// parse any timezone
if(items.length > 1){
out.parseTimeZone(items[1], format);
}
}
// timezone pattern
if(value.charAt(0) === '-' || value.charAt(0) === '+' || value.toUpperCase() === 'Z') {
if( out.hasTimeZone() === false ){
out.parseTimeZone(value);
}
}
}
// alway imply minutes
if(out.tM === -1){
out.tM = '00';
}
return out;
}
} | [
"function",
"(",
"arr",
",",
"format",
")",
"{",
"var",
"out",
"=",
"new",
"modules",
".",
"ISODate",
"(",
")",
",",
"i",
"=",
"0",
",",
"value",
"=",
"''",
";",
"if",
"(",
"arr",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
".",
"match",
"(",
"'T'",
")",
")",
"{",
"return",
"new",
"modules",
".",
"ISODate",
"(",
"arr",
"[",
"0",
"]",
",",
"format",
")",
";",
"}",
"else",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"value",
"=",
"arr",
"[",
"i",
"]",
";",
"if",
"(",
"value",
".",
"charAt",
"(",
"4",
")",
"===",
"'-'",
"&&",
"out",
".",
"hasFullDate",
"(",
")",
"===",
"false",
")",
"{",
"out",
".",
"parseDate",
"(",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
".",
"indexOf",
"(",
"':'",
")",
">",
"-",
"1",
"||",
"modules",
".",
"utils",
".",
"isNumber",
"(",
"this",
".",
"parseAmPmTime",
"(",
"value",
")",
")",
")",
"&&",
"out",
".",
"hasTime",
"(",
")",
"===",
"false",
")",
"{",
"var",
"items",
"=",
"this",
".",
"splitTimeAndZone",
"(",
"value",
")",
";",
"value",
"=",
"items",
"[",
"0",
"]",
";",
"value",
"=",
"this",
".",
"parseAmPmTime",
"(",
"value",
")",
";",
"out",
".",
"parseTime",
"(",
"value",
")",
";",
"if",
"(",
"items",
".",
"length",
">",
"1",
")",
"{",
"out",
".",
"parseTimeZone",
"(",
"items",
"[",
"1",
"]",
",",
"format",
")",
";",
"}",
"}",
"if",
"(",
"value",
".",
"charAt",
"(",
"0",
")",
"===",
"'-'",
"||",
"value",
".",
"charAt",
"(",
"0",
")",
"===",
"'+'",
"||",
"value",
".",
"toUpperCase",
"(",
")",
"===",
"'Z'",
")",
"{",
"if",
"(",
"out",
".",
"hasTimeZone",
"(",
")",
"===",
"false",
")",
"{",
"out",
".",
"parseTimeZone",
"(",
"value",
")",
";",
"}",
"}",
"}",
"if",
"(",
"out",
".",
"tM",
"===",
"-",
"1",
")",
"{",
"out",
".",
"tM",
"=",
"'00'",
";",
"}",
"return",
"out",
";",
"}",
"}"
] | concatenate an array of date and time text fragments to create an ISODate object
used for microformat value and value-title rules
@param {Array} arr ( Array of Strings )
@param {String} format ( Modules.ISODate profile format )
@return {Object} Modules.ISODate | [
"concatenate",
"an",
"array",
"of",
"date",
"and",
"time",
"text",
"fragments",
"to",
"create",
"an",
"ISODate",
"object",
"used",
"for",
"microformat",
"value",
"and",
"value",
"-",
"title",
"rules"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3805-L3852 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function ( text ){
var out = [text],
chars = ['-','+','z','Z'],
i = chars.length;
while (i--) {
if(text.indexOf(chars[i]) > -1){
out[0] = text.slice( 0, text.indexOf(chars[i]) );
out.push( text.slice( text.indexOf(chars[i]) ) );
break;
}
}
return out;
} | javascript | function ( text ){
var out = [text],
chars = ['-','+','z','Z'],
i = chars.length;
while (i--) {
if(text.indexOf(chars[i]) > -1){
out[0] = text.slice( 0, text.indexOf(chars[i]) );
out.push( text.slice( text.indexOf(chars[i]) ) );
break;
}
}
return out;
} | [
"function",
"(",
"text",
")",
"{",
"var",
"out",
"=",
"[",
"text",
"]",
",",
"chars",
"=",
"[",
"'-'",
",",
"'+'",
",",
"'z'",
",",
"'Z'",
"]",
",",
"i",
"=",
"chars",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"text",
".",
"indexOf",
"(",
"chars",
"[",
"i",
"]",
")",
">",
"-",
"1",
")",
"{",
"out",
"[",
"0",
"]",
"=",
"text",
".",
"slice",
"(",
"0",
",",
"text",
".",
"indexOf",
"(",
"chars",
"[",
"i",
"]",
")",
")",
";",
"out",
".",
"push",
"(",
"text",
".",
"slice",
"(",
"text",
".",
"indexOf",
"(",
"chars",
"[",
"i",
"]",
")",
")",
")",
";",
"break",
";",
"}",
"}",
"return",
"out",
";",
"}"
] | parses text by splitting it into an array of time and timezone strings
@param {String} text
@return {Array} Modules.ISODate | [
"parses",
"text",
"by",
"splitting",
"it",
"into",
"an",
"array",
"of",
"time",
"and",
"timezone",
"strings"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3861-L3874 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function(doc, node, textFormat){
var out;
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(this.textFormat === 'normalised'){
out = this.walkTreeForText( node );
if(out !== undefined){
return this.normalise( doc, out );
}else{
return '';
}
}else{
var clonedNode = modules.domUtils.clone(node);
var trimmedNode = modules.domUtils.removeDescendantsByTagName( clonedNode, this.excludeTags );
return this.formatText( doc, modules.domUtils.textContent(trimmedNode), this.textFormat );
}
} | javascript | function(doc, node, textFormat){
var out;
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(this.textFormat === 'normalised'){
out = this.walkTreeForText( node );
if(out !== undefined){
return this.normalise( doc, out );
}else{
return '';
}
}else{
var clonedNode = modules.domUtils.clone(node);
var trimmedNode = modules.domUtils.removeDescendantsByTagName( clonedNode, this.excludeTags );
return this.formatText( doc, modules.domUtils.textContent(trimmedNode), this.textFormat );
}
} | [
"function",
"(",
"doc",
",",
"node",
",",
"textFormat",
")",
"{",
"var",
"out",
";",
"this",
".",
"textFormat",
"=",
"(",
"textFormat",
")",
"?",
"textFormat",
":",
"this",
".",
"textFormat",
";",
"if",
"(",
"this",
".",
"textFormat",
"===",
"'normalised'",
")",
"{",
"out",
"=",
"this",
".",
"walkTreeForText",
"(",
"node",
")",
";",
"if",
"(",
"out",
"!==",
"undefined",
")",
"{",
"return",
"this",
".",
"normalise",
"(",
"doc",
",",
"out",
")",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}",
"else",
"{",
"var",
"clonedNode",
"=",
"modules",
".",
"domUtils",
".",
"clone",
"(",
"node",
")",
";",
"var",
"trimmedNode",
"=",
"modules",
".",
"domUtils",
".",
"removeDescendantsByTagName",
"(",
"clonedNode",
",",
"this",
".",
"excludeTags",
")",
";",
"return",
"this",
".",
"formatText",
"(",
"doc",
",",
"modules",
".",
"domUtils",
".",
"textContent",
"(",
"trimmedNode",
")",
",",
"this",
".",
"textFormat",
")",
";",
"}",
"}"
] | parses the text from the DOM Node
@param {DOM Node} node
@param {String} textFormat
@return {String} | [
"parses",
"the",
"text",
"from",
"the",
"DOM",
"Node"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3902-L3918 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( doc, text, textFormat ){
var node = modules.domUtils.createNodeWithText( 'div', text );
return this.parse( doc, node, textFormat );
} | javascript | function( doc, text, textFormat ){
var node = modules.domUtils.createNodeWithText( 'div', text );
return this.parse( doc, node, textFormat );
} | [
"function",
"(",
"doc",
",",
"text",
",",
"textFormat",
")",
"{",
"var",
"node",
"=",
"modules",
".",
"domUtils",
".",
"createNodeWithText",
"(",
"'div'",
",",
"text",
")",
";",
"return",
"this",
".",
"parse",
"(",
"doc",
",",
"node",
",",
"textFormat",
")",
";",
"}"
] | parses the text from a html string
@param {DOM Document} doc
@param {String} text
@param {String} textFormat
@return {String} | [
"parses",
"the",
"text",
"from",
"a",
"html",
"string"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3929-L3932 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( doc, text, textFormat ){
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(text){
var out = text
if(this.textFormat === 'whitespacetrimmed') {
out = modules.utils.trimWhitespace( out );
}
return out;
}else{
return '';
}
} | javascript | function( doc, text, textFormat ){
this.textFormat = (textFormat)? textFormat : this.textFormat;
if(text){
var out = text
if(this.textFormat === 'whitespacetrimmed') {
out = modules.utils.trimWhitespace( out );
}
return out;
}else{
return '';
}
} | [
"function",
"(",
"doc",
",",
"text",
",",
"textFormat",
")",
"{",
"this",
".",
"textFormat",
"=",
"(",
"textFormat",
")",
"?",
"textFormat",
":",
"this",
".",
"textFormat",
";",
"if",
"(",
"text",
")",
"{",
"var",
"out",
"=",
"text",
"if",
"(",
"this",
".",
"textFormat",
"===",
"'whitespacetrimmed'",
")",
"{",
"out",
"=",
"modules",
".",
"utils",
".",
"trimWhitespace",
"(",
"out",
")",
";",
"}",
"return",
"out",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | parses the text from a html string - only for whitespace or whitespacetrimmed formats
@param {String} text
@param {String} textFormat
@return {String} | [
"parses",
"the",
"text",
"from",
"a",
"html",
"string",
"-",
"only",
"for",
"whitespace",
"or",
"whitespacetrimmed",
"formats"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3942-L3953 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( doc, text ){
text = text.replace( / /g, ' ') ; // exchanges html entity for space into space char
text = modules.utils.collapseWhiteSpace( text ); // removes linefeeds, tabs and addtional spaces
text = modules.domUtils.decodeEntities( doc, text ); // decode HTML entities
text = text.replace( '–', '-' ); // correct dash decoding
return modules.utils.trim( text );
} | javascript | function( doc, text ){
text = text.replace( / /g, ' ') ; // exchanges html entity for space into space char
text = modules.utils.collapseWhiteSpace( text ); // removes linefeeds, tabs and addtional spaces
text = modules.domUtils.decodeEntities( doc, text ); // decode HTML entities
text = text.replace( '–', '-' ); // correct dash decoding
return modules.utils.trim( text );
} | [
"function",
"(",
"doc",
",",
"text",
")",
"{",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
" ",
"/",
"g",
",",
"' '",
")",
";",
"text",
"=",
"modules",
".",
"utils",
".",
"collapseWhiteSpace",
"(",
"text",
")",
";",
"text",
"=",
"modules",
".",
"domUtils",
".",
"decodeEntities",
"(",
"doc",
",",
"text",
")",
";",
"text",
"=",
"text",
".",
"replace",
"(",
"'–', ",
" ",
"'",
"' )",
")",
" ",
"}"
] | normalises whitespace in given text
@param {String} text
@return {String} | [
"normalises",
"whitespace",
"in",
"given",
"text"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3962-L3968 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( node ) {
var out = '',
j = 0;
if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1){
return out;
}
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
out += modules.domUtils.getElementText( node );
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForText( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
// if it's a block level tag add an additional space at the end
if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1){
out += ' ';
}
return (out === '')? undefined : out ;
} | javascript | function( node ) {
var out = '',
j = 0;
if(node.tagName && this.excludeTags.indexOf( node.tagName.toLowerCase() ) > -1){
return out;
}
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
out += modules.domUtils.getElementText( node );
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForText( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
// if it's a block level tag add an additional space at the end
if(node.tagName && this.blockLevelTags.indexOf( node.tagName.toLowerCase() ) !== -1){
out += ' ';
}
return (out === '')? undefined : out ;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"out",
"=",
"''",
",",
"j",
"=",
"0",
";",
"if",
"(",
"node",
".",
"tagName",
"&&",
"this",
".",
"excludeTags",
".",
"indexOf",
"(",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
")",
">",
"-",
"1",
")",
"{",
"return",
"out",
";",
"}",
"if",
"(",
"node",
".",
"nodeType",
"&&",
"node",
".",
"nodeType",
"===",
"3",
")",
"{",
"out",
"+=",
"modules",
".",
"domUtils",
".",
"getElementText",
"(",
"node",
")",
";",
"}",
"if",
"(",
"node",
".",
"childNodes",
"&&",
"node",
".",
"childNodes",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"node",
".",
"childNodes",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"text",
"=",
"this",
".",
"walkTreeForText",
"(",
"node",
".",
"childNodes",
"[",
"j",
"]",
")",
";",
"if",
"(",
"text",
"!==",
"undefined",
")",
"{",
"out",
"+=",
"text",
";",
"}",
"}",
"}",
"if",
"(",
"node",
".",
"tagName",
"&&",
"this",
".",
"blockLevelTags",
".",
"indexOf",
"(",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
")",
"!==",
"-",
"1",
")",
"{",
"out",
"+=",
"' '",
";",
"}",
"return",
"(",
"out",
"===",
"''",
")",
"?",
"undefined",
":",
"out",
";",
"}"
] | walks DOM tree parsing the text from DOM Nodes
@param {DOM Node} node
@return {String} | [
"walks",
"DOM",
"tree",
"parsing",
"the",
"text",
"from",
"DOM",
"Nodes"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L3977-L4006 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( node ){
var out = '',
j = 0;
// we do not want the outer container
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
return out;
} | javascript | function( node ){
var out = '',
j = 0;
// we do not want the outer container
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
return out;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"out",
"=",
"''",
",",
"j",
"=",
"0",
";",
"if",
"(",
"node",
".",
"childNodes",
"&&",
"node",
".",
"childNodes",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"node",
".",
"childNodes",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"text",
"=",
"this",
".",
"walkTreeForHtml",
"(",
"node",
".",
"childNodes",
"[",
"j",
"]",
")",
";",
"if",
"(",
"text",
"!==",
"undefined",
")",
"{",
"out",
"+=",
"text",
";",
"}",
"}",
"}",
"return",
"out",
";",
"}"
] | parse the html string from DOM Node
@param {DOM Node} node
@return {String} | [
"parse",
"the",
"html",
"string",
"from",
"DOM",
"Node"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L4023-L4038 | train |
|
glennjones/microformat-shiv | microformat-shiv.js | function( node ) {
var out = '',
j = 0;
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
//out += modules.domUtils.getElementText( node );
var containerNode = modules.domUtils.createNode('div');
modules.domUtils.appendChild(containerNode, modules.domUtils.clone(node));
out += modules.domUtils.innerHTML(containerNode);
}
// exclude text which has been added with include pattern -
if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){
// begin tag
out += '<' + node.tagName.toLowerCase();
// add attributes
var attrs = modules.domUtils.getOrderedAttributes(node);
for (j = 0; j < attrs.length; j++) {
out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"';
}
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){
out += '>';
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
// end tag
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){
out += ' />';
}else{
out += '</' + node.tagName.toLowerCase() + '>';
}
}
return (out === '')? undefined : out;
} | javascript | function( node ) {
var out = '',
j = 0;
// if node is a text node get its text
if(node.nodeType && node.nodeType === 3){
//out += modules.domUtils.getElementText( node );
var containerNode = modules.domUtils.createNode('div');
modules.domUtils.appendChild(containerNode, modules.domUtils.clone(node));
out += modules.domUtils.innerHTML(containerNode);
}
// exclude text which has been added with include pattern -
if(node.nodeType && node.nodeType === 1 && modules.domUtils.hasAttribute(node, 'data-include') === false){
// begin tag
out += '<' + node.tagName.toLowerCase();
// add attributes
var attrs = modules.domUtils.getOrderedAttributes(node);
for (j = 0; j < attrs.length; j++) {
out += ' ' + attrs[j].name + '=' + '"' + attrs[j].value + '"';
}
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) === -1){
out += '>';
}
// get the text of the child nodes
if(node.childNodes && node.childNodes.length > 0){
for (j = 0; j < node.childNodes.length; j++) {
var text = this.walkTreeForHtml( node.childNodes[j] );
if(text !== undefined){
out += text;
}
}
}
// end tag
if(this.selfClosingElt.indexOf(node.tagName.toLowerCase()) > -1){
out += ' />';
}else{
out += '</' + node.tagName.toLowerCase() + '>';
}
}
return (out === '')? undefined : out;
} | [
"function",
"(",
"node",
")",
"{",
"var",
"out",
"=",
"''",
",",
"j",
"=",
"0",
";",
"if",
"(",
"node",
".",
"nodeType",
"&&",
"node",
".",
"nodeType",
"===",
"3",
")",
"{",
"var",
"containerNode",
"=",
"modules",
".",
"domUtils",
".",
"createNode",
"(",
"'div'",
")",
";",
"modules",
".",
"domUtils",
".",
"appendChild",
"(",
"containerNode",
",",
"modules",
".",
"domUtils",
".",
"clone",
"(",
"node",
")",
")",
";",
"out",
"+=",
"modules",
".",
"domUtils",
".",
"innerHTML",
"(",
"containerNode",
")",
";",
"}",
"if",
"(",
"node",
".",
"nodeType",
"&&",
"node",
".",
"nodeType",
"===",
"1",
"&&",
"modules",
".",
"domUtils",
".",
"hasAttribute",
"(",
"node",
",",
"'data-include'",
")",
"===",
"false",
")",
"{",
"out",
"+=",
"'<'",
"+",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"var",
"attrs",
"=",
"modules",
".",
"domUtils",
".",
"getOrderedAttributes",
"(",
"node",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"attrs",
".",
"length",
";",
"j",
"++",
")",
"{",
"out",
"+=",
"' '",
"+",
"attrs",
"[",
"j",
"]",
".",
"name",
"+",
"'='",
"+",
"'\"'",
"+",
"attrs",
"[",
"j",
"]",
".",
"value",
"+",
"'\"'",
";",
"}",
"if",
"(",
"this",
".",
"selfClosingElt",
".",
"indexOf",
"(",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
")",
"===",
"-",
"1",
")",
"{",
"out",
"+=",
"'>'",
";",
"}",
"if",
"(",
"node",
".",
"childNodes",
"&&",
"node",
".",
"childNodes",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"node",
".",
"childNodes",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"text",
"=",
"this",
".",
"walkTreeForHtml",
"(",
"node",
".",
"childNodes",
"[",
"j",
"]",
")",
";",
"if",
"(",
"text",
"!==",
"undefined",
")",
"{",
"out",
"+=",
"text",
";",
"}",
"}",
"}",
"if",
"(",
"this",
".",
"selfClosingElt",
".",
"indexOf",
"(",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
")",
">",
"-",
"1",
")",
"{",
"out",
"+=",
"' />'",
";",
"}",
"else",
"{",
"out",
"+=",
"'</'",
"+",
"node",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"+",
"'>'",
";",
"}",
"}",
"return",
"(",
"out",
"===",
"''",
")",
"?",
"undefined",
":",
"out",
";",
"}"
] | walks the DOM tree parsing the html string from the nodes
@param {DOM Document} doc
@param {DOM Node} node
@return {String} | [
"walks",
"the",
"DOM",
"tree",
"parsing",
"the",
"html",
"string",
"from",
"the",
"nodes"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/microformat-shiv.js#L4048-L4097 | train |
|
seandmurray/aws_athena_client | lib/request.js | validateQuery | function validateQuery(query) {
Assert.ok(((query) && ((typeof query) === 'object')),
'The Query object was not set?');
Assert.ok(((query.QueryString) && ((typeof query.QueryString) === 'string')),
'The query string was not set?');
Assert.ok(((query.ResultConfiguration) && ((typeof query.ResultConfiguration) === 'object')),
'The result configuation in the query object was not set?');
Assert.ok(((query.ResultConfiguration.OutputLocation) && ((typeof query.ResultConfiguration.OutputLocation) === 'string')),
'The output location of the result configuration in the query object was not set?');
return query;
} | javascript | function validateQuery(query) {
Assert.ok(((query) && ((typeof query) === 'object')),
'The Query object was not set?');
Assert.ok(((query.QueryString) && ((typeof query.QueryString) === 'string')),
'The query string was not set?');
Assert.ok(((query.ResultConfiguration) && ((typeof query.ResultConfiguration) === 'object')),
'The result configuation in the query object was not set?');
Assert.ok(((query.ResultConfiguration.OutputLocation) && ((typeof query.ResultConfiguration.OutputLocation) === 'string')),
'The output location of the result configuration in the query object was not set?');
return query;
} | [
"function",
"validateQuery",
"(",
"query",
")",
"{",
"Assert",
".",
"ok",
"(",
"(",
"(",
"query",
")",
"&&",
"(",
"(",
"typeof",
"query",
")",
"===",
"'object'",
")",
")",
",",
"'The Query object was not set?'",
")",
";",
"Assert",
".",
"ok",
"(",
"(",
"(",
"query",
".",
"QueryString",
")",
"&&",
"(",
"(",
"typeof",
"query",
".",
"QueryString",
")",
"===",
"'string'",
")",
")",
",",
"'The query string was not set?'",
")",
";",
"Assert",
".",
"ok",
"(",
"(",
"(",
"query",
".",
"ResultConfiguration",
")",
"&&",
"(",
"(",
"typeof",
"query",
".",
"ResultConfiguration",
")",
"===",
"'object'",
")",
")",
",",
"'The result configuation in the query object was not set?'",
")",
";",
"Assert",
".",
"ok",
"(",
"(",
"(",
"query",
".",
"ResultConfiguration",
".",
"OutputLocation",
")",
"&&",
"(",
"(",
"typeof",
"query",
".",
"ResultConfiguration",
".",
"OutputLocation",
")",
"===",
"'string'",
")",
")",
",",
"'The output location of the result configuration in the query object was not set?'",
")",
";",
"return",
"query",
";",
"}"
] | Fails if the minium set of values are not in a request. | [
"Fails",
"if",
"the",
"minium",
"set",
"of",
"values",
"are",
"not",
"in",
"a",
"request",
"."
] | 31a33755748fed78d8e15fa90dd723bd6f441f74 | https://github.com/seandmurray/aws_athena_client/blob/31a33755748fed78d8e15fa90dd723bd6f441f74/lib/request.js#L82-L92 | train |
christophermina/connect-couchbase | lib/connect-couchbase.js | CouchbaseStore | function CouchbaseStore(options) {
var self = this;
options = options || {};
Store.call(this, options);
this.prefix = null == options.prefix
? 'sess:'
: options.prefix;
var connectOptions = {};
if (options.hasOwnProperty("host")) {
connectOptions.host = options.host;
} else if (options.hasOwnProperty("hosts")) {
connectOptions.host = options.hosts;
}
if (options.hasOwnProperty("username")) {
connectOptions.username = options.username;
}
if (options.hasOwnProperty("password")) {
connectOptions.password = options.password;
}
if (options.hasOwnProperty("bucket")) {
connectOptions.bucket = options.bucket;
}
if (options.hasOwnProperty("cachefile")) {
connectOptions.cachefile = options.cachefile;
}
if (options.hasOwnProperty("connectionTimeout")) {
connectOptions.connectionTimeout = options.connectionTimeout;
}
if (options.hasOwnProperty("operationTimeout")) {
connectOptions.operationTimeout = options.operationTimeout;
}
if (options.hasOwnProperty("db")) {
connectOptions.db = options.db; // DB Instance
}
if ( typeof(connectOptions.db) != 'undefined' ) {
this.client = connectOptions.db;
} else {
var Couchbase = require('couchbase');
var cluster = new Couchbase.Cluster(connectOptions.host);
var bucket = connectOptions.bucket;
var prefix = this.prefix;
this.queryAll = Couchbase.N1qlQuery.fromString('SELECT `'
+ bucket + '`.* FROM `'
+ bucket + '` WHERE SUBSTR(META(`'
+ bucket + '`).id, 0, '
+ prefix.length + ') = "'
+ prefix + '"');
this.client = cluster.openBucket(connectOptions.bucket, connectOptions.password, function(err) {
if (err) {
console.log("Could not connect to couchbase with bucket: " + connectOptions.bucket);
self.emit('disconnect', err);
} else {
self.emit('connect');
}
});
}
this.client.connectionTimeout = connectOptions.connectionTimeout || 10000;
this.client.operationTimeout = connectOptions.operationTimeout || 10000;
this.ttl = options.ttl || null;
} | javascript | function CouchbaseStore(options) {
var self = this;
options = options || {};
Store.call(this, options);
this.prefix = null == options.prefix
? 'sess:'
: options.prefix;
var connectOptions = {};
if (options.hasOwnProperty("host")) {
connectOptions.host = options.host;
} else if (options.hasOwnProperty("hosts")) {
connectOptions.host = options.hosts;
}
if (options.hasOwnProperty("username")) {
connectOptions.username = options.username;
}
if (options.hasOwnProperty("password")) {
connectOptions.password = options.password;
}
if (options.hasOwnProperty("bucket")) {
connectOptions.bucket = options.bucket;
}
if (options.hasOwnProperty("cachefile")) {
connectOptions.cachefile = options.cachefile;
}
if (options.hasOwnProperty("connectionTimeout")) {
connectOptions.connectionTimeout = options.connectionTimeout;
}
if (options.hasOwnProperty("operationTimeout")) {
connectOptions.operationTimeout = options.operationTimeout;
}
if (options.hasOwnProperty("db")) {
connectOptions.db = options.db; // DB Instance
}
if ( typeof(connectOptions.db) != 'undefined' ) {
this.client = connectOptions.db;
} else {
var Couchbase = require('couchbase');
var cluster = new Couchbase.Cluster(connectOptions.host);
var bucket = connectOptions.bucket;
var prefix = this.prefix;
this.queryAll = Couchbase.N1qlQuery.fromString('SELECT `'
+ bucket + '`.* FROM `'
+ bucket + '` WHERE SUBSTR(META(`'
+ bucket + '`).id, 0, '
+ prefix.length + ') = "'
+ prefix + '"');
this.client = cluster.openBucket(connectOptions.bucket, connectOptions.password, function(err) {
if (err) {
console.log("Could not connect to couchbase with bucket: " + connectOptions.bucket);
self.emit('disconnect', err);
} else {
self.emit('connect');
}
});
}
this.client.connectionTimeout = connectOptions.connectionTimeout || 10000;
this.client.operationTimeout = connectOptions.operationTimeout || 10000;
this.ttl = options.ttl || null;
} | [
"function",
"CouchbaseStore",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"Store",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"prefix",
"=",
"null",
"==",
"options",
".",
"prefix",
"?",
"'sess:'",
":",
"options",
".",
"prefix",
";",
"var",
"connectOptions",
"=",
"{",
"}",
";",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"host\"",
")",
")",
"{",
"connectOptions",
".",
"host",
"=",
"options",
".",
"host",
";",
"}",
"else",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"hosts\"",
")",
")",
"{",
"connectOptions",
".",
"host",
"=",
"options",
".",
"hosts",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"username\"",
")",
")",
"{",
"connectOptions",
".",
"username",
"=",
"options",
".",
"username",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"password\"",
")",
")",
"{",
"connectOptions",
".",
"password",
"=",
"options",
".",
"password",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"bucket\"",
")",
")",
"{",
"connectOptions",
".",
"bucket",
"=",
"options",
".",
"bucket",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"cachefile\"",
")",
")",
"{",
"connectOptions",
".",
"cachefile",
"=",
"options",
".",
"cachefile",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"connectionTimeout\"",
")",
")",
"{",
"connectOptions",
".",
"connectionTimeout",
"=",
"options",
".",
"connectionTimeout",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"operationTimeout\"",
")",
")",
"{",
"connectOptions",
".",
"operationTimeout",
"=",
"options",
".",
"operationTimeout",
";",
"}",
"if",
"(",
"options",
".",
"hasOwnProperty",
"(",
"\"db\"",
")",
")",
"{",
"connectOptions",
".",
"db",
"=",
"options",
".",
"db",
";",
"}",
"if",
"(",
"typeof",
"(",
"connectOptions",
".",
"db",
")",
"!=",
"'undefined'",
")",
"{",
"this",
".",
"client",
"=",
"connectOptions",
".",
"db",
";",
"}",
"else",
"{",
"var",
"Couchbase",
"=",
"require",
"(",
"'couchbase'",
")",
";",
"var",
"cluster",
"=",
"new",
"Couchbase",
".",
"Cluster",
"(",
"connectOptions",
".",
"host",
")",
";",
"var",
"bucket",
"=",
"connectOptions",
".",
"bucket",
";",
"var",
"prefix",
"=",
"this",
".",
"prefix",
";",
"this",
".",
"queryAll",
"=",
"Couchbase",
".",
"N1qlQuery",
".",
"fromString",
"(",
"'SELECT `'",
"+",
"bucket",
"+",
"'`.* FROM `'",
"+",
"bucket",
"+",
"'` WHERE SUBSTR(META(`'",
"+",
"bucket",
"+",
"'`).id, 0, '",
"+",
"prefix",
".",
"length",
"+",
"') = \"'",
"+",
"prefix",
"+",
"'\"'",
")",
";",
"this",
".",
"client",
"=",
"cluster",
".",
"openBucket",
"(",
"connectOptions",
".",
"bucket",
",",
"connectOptions",
".",
"password",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"\"Could not connect to couchbase with bucket: \"",
"+",
"connectOptions",
".",
"bucket",
")",
";",
"self",
".",
"emit",
"(",
"'disconnect'",
",",
"err",
")",
";",
"}",
"else",
"{",
"self",
".",
"emit",
"(",
"'connect'",
")",
";",
"}",
"}",
")",
";",
"}",
"this",
".",
"client",
".",
"connectionTimeout",
"=",
"connectOptions",
".",
"connectionTimeout",
"||",
"10000",
";",
"this",
".",
"client",
".",
"operationTimeout",
"=",
"connectOptions",
".",
"operationTimeout",
"||",
"10000",
";",
"this",
".",
"ttl",
"=",
"options",
".",
"ttl",
"||",
"null",
";",
"}"
] | Initialize CouchbaseStore with the given `options`.
@param {Object} options
{
host: 127.0.0.1:8091 (default) -- Can be one or more address:ports, separated by semi-colon, or an array
username: '', -- Should be same as bucket name, if provided
password: '',
bucket: 'default' (default)
cachefile: ''
ttl: 86400,
prefix: 'sess',
operationTimeout:2000,
connectionTimeout:2000,
}
@api public | [
"Initialize",
"CouchbaseStore",
"with",
"the",
"given",
"options",
"."
] | fe011702ec8fa72fdf088556324dc46ed879518b | https://github.com/christophermina/connect-couchbase/blob/fe011702ec8fa72fdf088556324dc46ed879518b/lib/connect-couchbase.js#L64-L139 | train |
lhkbob/eve-swagger-js | dist/util/type-generator/namespace.js | getRouteNamespaces | function getRouteNamespaces(spec) {
let names = new Map();
for (let id of spec.routeIDs) {
let [namespace, explicit] = Namespace.forRoute(spec.route(id));
namespace.log.push(`Route ${id} maps to ${namespace.fullName} (explicit = ${explicit})`);
names.set(id, [namespace, explicit]);
}
return names;
} | javascript | function getRouteNamespaces(spec) {
let names = new Map();
for (let id of spec.routeIDs) {
let [namespace, explicit] = Namespace.forRoute(spec.route(id));
namespace.log.push(`Route ${id} maps to ${namespace.fullName} (explicit = ${explicit})`);
names.set(id, [namespace, explicit]);
}
return names;
} | [
"function",
"getRouteNamespaces",
"(",
"spec",
")",
"{",
"let",
"names",
"=",
"new",
"Map",
"(",
")",
";",
"for",
"(",
"let",
"id",
"of",
"spec",
".",
"routeIDs",
")",
"{",
"let",
"[",
"namespace",
",",
"explicit",
"]",
"=",
"Namespace",
".",
"forRoute",
"(",
"spec",
".",
"route",
"(",
"id",
")",
")",
";",
"namespace",
".",
"log",
".",
"push",
"(",
"`",
"${",
"id",
"}",
"${",
"namespace",
".",
"fullName",
"}",
"${",
"explicit",
"}",
"`",
")",
";",
"names",
".",
"set",
"(",
"id",
",",
"[",
"namespace",
",",
"explicit",
"]",
")",
";",
"}",
"return",
"names",
";",
"}"
] | Generate the names for all route ids in the specification | [
"Generate",
"the",
"names",
"for",
"all",
"route",
"ids",
"in",
"the",
"specification"
] | 1353126546b988dd4811fc4256c94f4d96f26c37 | https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/type-generator/namespace.js#L302-L310 | train |
pubfood/pubfood | src/provider/bidprovider.js | BidProvider | function BidProvider(bidDelegate) {
if (this.init_) {
this.init_();
}
var delegate = bidDelegate || {};
this.name = delegate.name || '';
this.bidDelegate = delegate;
this.enabled_ = true;
this.timeout_ = delegate && delegate.timeout ? delegate.timeout : 0;
} | javascript | function BidProvider(bidDelegate) {
if (this.init_) {
this.init_();
}
var delegate = bidDelegate || {};
this.name = delegate.name || '';
this.bidDelegate = delegate;
this.enabled_ = true;
this.timeout_ = delegate && delegate.timeout ? delegate.timeout : 0;
} | [
"function",
"BidProvider",
"(",
"bidDelegate",
")",
"{",
"if",
"(",
"this",
".",
"init_",
")",
"{",
"this",
".",
"init_",
"(",
")",
";",
"}",
"var",
"delegate",
"=",
"bidDelegate",
"||",
"{",
"}",
";",
"this",
".",
"name",
"=",
"delegate",
".",
"name",
"||",
"''",
";",
"this",
".",
"bidDelegate",
"=",
"delegate",
";",
"this",
".",
"enabled_",
"=",
"true",
";",
"this",
".",
"timeout_",
"=",
"delegate",
"&&",
"delegate",
".",
"timeout",
"?",
"delegate",
".",
"timeout",
":",
"0",
";",
"}"
] | BidProvider implements bidding partner requests.
@class
@param {BidDelegate} delegate the delegate object that implements [libUri()]{@link pubfood#provider.BidProvider#libUri}, [init()]{@link pubfood#provider.BidProvider#init} and [refresh()]{@link pubfood#provider.BidProvider#refresh}
@property {string} name the name of the provider
@augments PubfoodObject
@augments PubfoodProvider
@memberof pubfood#provider | [
"BidProvider",
"implements",
"bidding",
"partner",
"requests",
"."
] | be666e922d92f86fd1542e7c43f81126a9301771 | https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/provider/bidprovider.js#L22-L31 | train |
tim-evans/ember-pop-over | addon/mixins/scroll_sandbox.js | mouseWheel | function mouseWheel(evt) {
let oevt = evt.originalEvent;
let delta = 0;
let deltaY = 0;
let deltaX = 0;
if (oevt.wheelDelta) {
delta = oevt.wheelDelta / 120;
}
if (oevt.detail) {
delta = oevt.detail / -3;
}
deltaY = delta;
if (oevt.hasOwnProperty) {
// Gecko
if (oevt.hasOwnProperty('axis') && oevt.axis === oevt.HORIZONTAL_AXIS) {
deltaY = 0;
deltaX = -1 * delta;
}
// Webkit
if (oevt.hasOwnProperty('wheelDeltaY')) {
deltaY = oevt.wheelDeltaY / +120;
}
if (oevt.hasOwnProperty('wheelDeltaX')) {
deltaX = oevt.wheelDeltaX / -120;
}
}
evt.wheelDeltaX = deltaX;
evt.wheelDeltaY = deltaY;
return this.mouseWheel(evt);
} | javascript | function mouseWheel(evt) {
let oevt = evt.originalEvent;
let delta = 0;
let deltaY = 0;
let deltaX = 0;
if (oevt.wheelDelta) {
delta = oevt.wheelDelta / 120;
}
if (oevt.detail) {
delta = oevt.detail / -3;
}
deltaY = delta;
if (oevt.hasOwnProperty) {
// Gecko
if (oevt.hasOwnProperty('axis') && oevt.axis === oevt.HORIZONTAL_AXIS) {
deltaY = 0;
deltaX = -1 * delta;
}
// Webkit
if (oevt.hasOwnProperty('wheelDeltaY')) {
deltaY = oevt.wheelDeltaY / +120;
}
if (oevt.hasOwnProperty('wheelDeltaX')) {
deltaX = oevt.wheelDeltaX / -120;
}
}
evt.wheelDeltaX = deltaX;
evt.wheelDeltaY = deltaY;
return this.mouseWheel(evt);
} | [
"function",
"mouseWheel",
"(",
"evt",
")",
"{",
"let",
"oevt",
"=",
"evt",
".",
"originalEvent",
";",
"let",
"delta",
"=",
"0",
";",
"let",
"deltaY",
"=",
"0",
";",
"let",
"deltaX",
"=",
"0",
";",
"if",
"(",
"oevt",
".",
"wheelDelta",
")",
"{",
"delta",
"=",
"oevt",
".",
"wheelDelta",
"/",
"120",
";",
"}",
"if",
"(",
"oevt",
".",
"detail",
")",
"{",
"delta",
"=",
"oevt",
".",
"detail",
"/",
"-",
"3",
";",
"}",
"deltaY",
"=",
"delta",
";",
"if",
"(",
"oevt",
".",
"hasOwnProperty",
")",
"{",
"if",
"(",
"oevt",
".",
"hasOwnProperty",
"(",
"'axis'",
")",
"&&",
"oevt",
".",
"axis",
"===",
"oevt",
".",
"HORIZONTAL_AXIS",
")",
"{",
"deltaY",
"=",
"0",
";",
"deltaX",
"=",
"-",
"1",
"*",
"delta",
";",
"}",
"if",
"(",
"oevt",
".",
"hasOwnProperty",
"(",
"'wheelDeltaY'",
")",
")",
"{",
"deltaY",
"=",
"oevt",
".",
"wheelDeltaY",
"/",
"+",
"120",
";",
"}",
"if",
"(",
"oevt",
".",
"hasOwnProperty",
"(",
"'wheelDeltaX'",
")",
")",
"{",
"deltaX",
"=",
"oevt",
".",
"wheelDeltaX",
"/",
"-",
"120",
";",
"}",
"}",
"evt",
".",
"wheelDeltaX",
"=",
"deltaX",
";",
"evt",
".",
"wheelDeltaY",
"=",
"deltaY",
";",
"return",
"this",
".",
"mouseWheel",
"(",
"evt",
")",
";",
"}"
] | Normalize mouseWheel events | [
"Normalize",
"mouseWheel",
"events"
] | 79b4b59a9d81c4929cfd38d83ee6b01c36184eef | https://github.com/tim-evans/ember-pop-over/blob/79b4b59a9d81c4929cfd38d83ee6b01c36184eef/addon/mixins/scroll_sandbox.js#L7-L42 | train |
pubfood/pubfood | src/mediator/auctionmediator.js | AuctionMediator | function AuctionMediator(config) {
if (this.init_) {
this.init_();
}
/** @property {boolean} prefix if false, do not add bid provider name to bid targeting key. Default: true */
this.prefix = config && config.hasOwnProperty('prefix') ? config.prefix : true;
// store slots by name for easy lookup
this.slotMap = {};
this.bidProviders = {};
this.auctionProvider = null;
this.auctionRun = {};
this.timeout_ = AuctionMediator.NO_TIMEOUT;
this.trigger_ = null;
this.bidAssembler = new BidAssembler();
this.requestAssembler = new RequestAssembler();
this.auctionIdx_ = 0;
this.doneCallbackOffset_ = AuctionMediator.DEFAULT_DONE_CALLBACK_OFFSET;
this.omitDefaultBidKey_ = false;
this.throwErrors_ = false;
Event.setAuctionId(this.getAuctionId());
} | javascript | function AuctionMediator(config) {
if (this.init_) {
this.init_();
}
/** @property {boolean} prefix if false, do not add bid provider name to bid targeting key. Default: true */
this.prefix = config && config.hasOwnProperty('prefix') ? config.prefix : true;
// store slots by name for easy lookup
this.slotMap = {};
this.bidProviders = {};
this.auctionProvider = null;
this.auctionRun = {};
this.timeout_ = AuctionMediator.NO_TIMEOUT;
this.trigger_ = null;
this.bidAssembler = new BidAssembler();
this.requestAssembler = new RequestAssembler();
this.auctionIdx_ = 0;
this.doneCallbackOffset_ = AuctionMediator.DEFAULT_DONE_CALLBACK_OFFSET;
this.omitDefaultBidKey_ = false;
this.throwErrors_ = false;
Event.setAuctionId(this.getAuctionId());
} | [
"function",
"AuctionMediator",
"(",
"config",
")",
"{",
"if",
"(",
"this",
".",
"init_",
")",
"{",
"this",
".",
"init_",
"(",
")",
";",
"}",
"this",
".",
"prefix",
"=",
"config",
"&&",
"config",
".",
"hasOwnProperty",
"(",
"'prefix'",
")",
"?",
"config",
".",
"prefix",
":",
"true",
";",
"this",
".",
"slotMap",
"=",
"{",
"}",
";",
"this",
".",
"bidProviders",
"=",
"{",
"}",
";",
"this",
".",
"auctionProvider",
"=",
"null",
";",
"this",
".",
"auctionRun",
"=",
"{",
"}",
";",
"this",
".",
"timeout_",
"=",
"AuctionMediator",
".",
"NO_TIMEOUT",
";",
"this",
".",
"trigger_",
"=",
"null",
";",
"this",
".",
"bidAssembler",
"=",
"new",
"BidAssembler",
"(",
")",
";",
"this",
".",
"requestAssembler",
"=",
"new",
"RequestAssembler",
"(",
")",
";",
"this",
".",
"auctionIdx_",
"=",
"0",
";",
"this",
".",
"doneCallbackOffset_",
"=",
"AuctionMediator",
".",
"DEFAULT_DONE_CALLBACK_OFFSET",
";",
"this",
".",
"omitDefaultBidKey_",
"=",
"false",
";",
"this",
".",
"throwErrors_",
"=",
"false",
";",
"Event",
".",
"setAuctionId",
"(",
"this",
".",
"getAuctionId",
"(",
")",
")",
";",
"}"
] | AuctionMediator coordiates requests to Publisher Ad Servers.
@class
@memberof pubfood#mediator
@private | [
"AuctionMediator",
"coordiates",
"requests",
"to",
"Publisher",
"Ad",
"Servers",
"."
] | be666e922d92f86fd1542e7c43f81126a9301771 | https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/mediator/auctionmediator.js#L25-L46 | train |
glennjones/microformat-shiv | examples/firefox/lib/main.js | getTabData | function getTabData(url){
var key,
data;
key = urlToKey(url);
obj = tabData[key];
return (obj)? obj : {data: {}, url: url};
} | javascript | function getTabData(url){
var key,
data;
key = urlToKey(url);
obj = tabData[key];
return (obj)? obj : {data: {}, url: url};
} | [
"function",
"getTabData",
"(",
"url",
")",
"{",
"var",
"key",
",",
"data",
";",
"key",
"=",
"urlToKey",
"(",
"url",
")",
";",
"obj",
"=",
"tabData",
"[",
"key",
"]",
";",
"return",
"(",
"obj",
")",
"?",
"obj",
":",
"{",
"data",
":",
"{",
"}",
",",
"url",
":",
"url",
"}",
";",
"}"
] | get data from object store | [
"get",
"data",
"from",
"object",
"store"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/examples/firefox/lib/main.js#L91-L98 | train |
glennjones/microformat-shiv | examples/firefox/lib/main.js | appendTabData | function appendTabData(json){
var key;
if(!getTabData(json.url).data.items){
key = urlToKey(json.url);
tabData[key] = json;
}
} | javascript | function appendTabData(json){
var key;
if(!getTabData(json.url).data.items){
key = urlToKey(json.url);
tabData[key] = json;
}
} | [
"function",
"appendTabData",
"(",
"json",
")",
"{",
"var",
"key",
";",
"if",
"(",
"!",
"getTabData",
"(",
"json",
".",
"url",
")",
".",
"data",
".",
"items",
")",
"{",
"key",
"=",
"urlToKey",
"(",
"json",
".",
"url",
")",
";",
"tabData",
"[",
"key",
"]",
"=",
"json",
";",
"}",
"}"
] | append data to the object store | [
"append",
"data",
"to",
"the",
"object",
"store"
] | 90c5ea5e43ae95fc460aef79f8c19832c6f1dc26 | https://github.com/glennjones/microformat-shiv/blob/90c5ea5e43ae95fc460aef79f8c19832c6f1dc26/examples/firefox/lib/main.js#L101-L108 | train |
deitch/smtp-tester | lib/index.js | buildEmail | function buildEmail(envelope, data) {
return simpleParser(data)
.then(function(parsedEmail) {
const sender = envelope.mailFrom.address;
const receivers = envelope.rcptTo
.map(recipient => [ recipient.address, true ])
.reduce(tupleToObject, {});
const headers = [ ... parsedEmail.headers ]
.map(readHeader)
.reduce(tupleToObject, {});
const email = {
sender,
receivers,
data,
headers,
body: parsedEmail.text,
html: parsedEmail.html,
attachments: parsedEmail.attachments
};
return email;
});
} | javascript | function buildEmail(envelope, data) {
return simpleParser(data)
.then(function(parsedEmail) {
const sender = envelope.mailFrom.address;
const receivers = envelope.rcptTo
.map(recipient => [ recipient.address, true ])
.reduce(tupleToObject, {});
const headers = [ ... parsedEmail.headers ]
.map(readHeader)
.reduce(tupleToObject, {});
const email = {
sender,
receivers,
data,
headers,
body: parsedEmail.text,
html: parsedEmail.html,
attachments: parsedEmail.attachments
};
return email;
});
} | [
"function",
"buildEmail",
"(",
"envelope",
",",
"data",
")",
"{",
"return",
"simpleParser",
"(",
"data",
")",
".",
"then",
"(",
"function",
"(",
"parsedEmail",
")",
"{",
"const",
"sender",
"=",
"envelope",
".",
"mailFrom",
".",
"address",
";",
"const",
"receivers",
"=",
"envelope",
".",
"rcptTo",
".",
"map",
"(",
"recipient",
"=>",
"[",
"recipient",
".",
"address",
",",
"true",
"]",
")",
".",
"reduce",
"(",
"tupleToObject",
",",
"{",
"}",
")",
";",
"const",
"headers",
"=",
"[",
"...",
"parsedEmail",
".",
"headers",
"]",
".",
"map",
"(",
"readHeader",
")",
".",
"reduce",
"(",
"tupleToObject",
",",
"{",
"}",
")",
";",
"const",
"email",
"=",
"{",
"sender",
",",
"receivers",
",",
"data",
",",
"headers",
",",
"body",
":",
"parsedEmail",
".",
"text",
",",
"html",
":",
"parsedEmail",
".",
"html",
",",
"attachments",
":",
"parsedEmail",
".",
"attachments",
"}",
";",
"return",
"email",
";",
"}",
")",
";",
"}"
] | Resolves to the email object handlers receive. | [
"Resolves",
"to",
"the",
"email",
"object",
"handlers",
"receive",
"."
] | 02a150809efda61127344d56a332780b8f830d18 | https://github.com/deitch/smtp-tester/blob/02a150809efda61127344d56a332780b8f830d18/lib/index.js#L113-L137 | train |
hegemonic/catharsis | catharsis.js | prepareFrozenObject | function prepareFrozenObject(obj, expr, {jsdoc}) {
Object.defineProperty(obj, 'jsdoc', {
value: jsdoc === true ? jsdoc : false
});
if (expr) {
Object.defineProperty(obj, 'typeExpression', {
value: expr
});
}
return Object.freeze(obj);
} | javascript | function prepareFrozenObject(obj, expr, {jsdoc}) {
Object.defineProperty(obj, 'jsdoc', {
value: jsdoc === true ? jsdoc : false
});
if (expr) {
Object.defineProperty(obj, 'typeExpression', {
value: expr
});
}
return Object.freeze(obj);
} | [
"function",
"prepareFrozenObject",
"(",
"obj",
",",
"expr",
",",
"{",
"jsdoc",
"}",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"'jsdoc'",
",",
"{",
"value",
":",
"jsdoc",
"===",
"true",
"?",
"jsdoc",
":",
"false",
"}",
")",
";",
"if",
"(",
"expr",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"obj",
",",
"'typeExpression'",
",",
"{",
"value",
":",
"expr",
"}",
")",
";",
"}",
"return",
"Object",
".",
"freeze",
"(",
"obj",
")",
";",
"}"
] | Add non-enumerable properties to a result object, then freeze it. | [
"Add",
"non",
"-",
"enumerable",
"properties",
"to",
"a",
"result",
"object",
"then",
"freeze",
"it",
"."
] | b4a29feee5bbeffa512eaf997f8e5480c0d2476f | https://github.com/hegemonic/catharsis/blob/b4a29feee5bbeffa512eaf997f8e5480c0d2476f/catharsis.js#L67-L79 | train |
lhkbob/eve-swagger-js | dist/util/type-generator/exportable-type.js | isSchema | function isSchema(blob) {
// A schema will have one of these
return blob.properties !== undefined || blob.enum !== undefined || blob.items
!== undefined || blob.type !== undefined;
} | javascript | function isSchema(blob) {
// A schema will have one of these
return blob.properties !== undefined || blob.enum !== undefined || blob.items
!== undefined || blob.type !== undefined;
} | [
"function",
"isSchema",
"(",
"blob",
")",
"{",
"return",
"blob",
".",
"properties",
"!==",
"undefined",
"||",
"blob",
".",
"enum",
"!==",
"undefined",
"||",
"blob",
".",
"items",
"!==",
"undefined",
"||",
"blob",
".",
"type",
"!==",
"undefined",
";",
"}"
] | The official swagger type spec makes it a little bit of a pain to work with the wrappers around type definitions. | [
"The",
"official",
"swagger",
"type",
"spec",
"makes",
"it",
"a",
"little",
"bit",
"of",
"a",
"pain",
"to",
"work",
"with",
"the",
"wrappers",
"around",
"type",
"definitions",
"."
] | 1353126546b988dd4811fc4256c94f4d96f26c37 | https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/type-generator/exportable-type.js#L876-L880 | train |
groupon/nlm | lib/git/ensure-tag.js | ensureTag | function ensureTag(cwd, tag) {
if (tag === 'v0.0.0') {
// There is no such thing (most likely)
return null;
}
const tagFile = path.join(cwd, '.git', 'refs', 'tags', tag);
try {
return fs.readFileSync(tagFile);
} catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}
return fetchTag(cwd, tag);
}
} | javascript | function ensureTag(cwd, tag) {
if (tag === 'v0.0.0') {
// There is no such thing (most likely)
return null;
}
const tagFile = path.join(cwd, '.git', 'refs', 'tags', tag);
try {
return fs.readFileSync(tagFile);
} catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}
return fetchTag(cwd, tag);
}
} | [
"function",
"ensureTag",
"(",
"cwd",
",",
"tag",
")",
"{",
"if",
"(",
"tag",
"===",
"'v0.0.0'",
")",
"{",
"return",
"null",
";",
"}",
"const",
"tagFile",
"=",
"path",
".",
"join",
"(",
"cwd",
",",
"'.git'",
",",
"'refs'",
",",
"'tags'",
",",
"tag",
")",
";",
"try",
"{",
"return",
"fs",
".",
"readFileSync",
"(",
"tagFile",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"if",
"(",
"error",
".",
"code",
"!==",
"'ENOENT'",
")",
"{",
"throw",
"error",
";",
"}",
"return",
"fetchTag",
"(",
"cwd",
",",
"tag",
")",
";",
"}",
"}"
] | Ensure that a tag was fetched from the remote
DotCI only fetches the ref that is currently being built.
We need the last version tag to determine the changes.
This checks if a tag exists locally. If it doesn't, it will
fetch the tag from `origin`. | [
"Ensure",
"that",
"a",
"tag",
"was",
"fetched",
"from",
"the",
"remote"
] | f9bf02954b5d27b83d26c37a07312d922843b892 | https://github.com/groupon/nlm/blob/f9bf02954b5d27b83d26c37a07312d922843b892/lib/git/ensure-tag.js#L52-L67 | train |
reklatsmasters/saslprep | generate-code-points.js | traverse | function traverse(bits, src) {
for (const code of src.keys()) {
bits.set(code, true);
}
const buffer = bits.toBuffer();
return Buffer.concat([createSize(buffer), buffer]);
} | javascript | function traverse(bits, src) {
for (const code of src.keys()) {
bits.set(code, true);
}
const buffer = bits.toBuffer();
return Buffer.concat([createSize(buffer), buffer]);
} | [
"function",
"traverse",
"(",
"bits",
",",
"src",
")",
"{",
"for",
"(",
"const",
"code",
"of",
"src",
".",
"keys",
"(",
")",
")",
"{",
"bits",
".",
"set",
"(",
"code",
",",
"true",
")",
";",
"}",
"const",
"buffer",
"=",
"bits",
".",
"toBuffer",
"(",
")",
";",
"return",
"Buffer",
".",
"concat",
"(",
"[",
"createSize",
"(",
"buffer",
")",
",",
"buffer",
"]",
")",
";",
"}"
] | Iterare over code points and
convert it into an buffer.
@param {bitfield} bits
@param {Array} src
@returns {Buffer} | [
"Iterare",
"over",
"code",
"points",
"and",
"convert",
"it",
"into",
"an",
"buffer",
"."
] | 4ad8884b461a6a8e496d6e648ad5da0a1b43cb42 | https://github.com/reklatsmasters/saslprep/blob/4ad8884b461a6a8e496d6e648ad5da0a1b43cb42/generate-code-points.js#L20-L27 | train |
pubfood/pubfood | src/pubfood.js | function(pfo) {
var bidProviders = pfo.getBidProviders();
// check for core api method calls
for (var apiMethod in pfo.requiredApiCalls) {
if (pfo.requiredApiCalls[apiMethod] === 0) {
pfo.configErrors.push('"' + apiMethod + '" was not called');
}
}
// validate through all the slots bid provider
var slots = pfo.getSlots();
for (var i = 0; i < slots.length; i++) {
for (var k = 0; k < slots[i].bidProviders.length; k++) {
var providerName = slots[i].bidProviders[k];
// make sure there's config for each bid provider
if (!bidProviders[providerName]) {
pfo.configErrors.push('No configuration found for bid provider "' + providerName + '"');
}
}
}
return {
hasError: pfo.configErrors.length > 0,
details: pfo.configErrors
};
} | javascript | function(pfo) {
var bidProviders = pfo.getBidProviders();
// check for core api method calls
for (var apiMethod in pfo.requiredApiCalls) {
if (pfo.requiredApiCalls[apiMethod] === 0) {
pfo.configErrors.push('"' + apiMethod + '" was not called');
}
}
// validate through all the slots bid provider
var slots = pfo.getSlots();
for (var i = 0; i < slots.length; i++) {
for (var k = 0; k < slots[i].bidProviders.length; k++) {
var providerName = slots[i].bidProviders[k];
// make sure there's config for each bid provider
if (!bidProviders[providerName]) {
pfo.configErrors.push('No configuration found for bid provider "' + providerName + '"');
}
}
}
return {
hasError: pfo.configErrors.length > 0,
details: pfo.configErrors
};
} | [
"function",
"(",
"pfo",
")",
"{",
"var",
"bidProviders",
"=",
"pfo",
".",
"getBidProviders",
"(",
")",
";",
"for",
"(",
"var",
"apiMethod",
"in",
"pfo",
".",
"requiredApiCalls",
")",
"{",
"if",
"(",
"pfo",
".",
"requiredApiCalls",
"[",
"apiMethod",
"]",
"===",
"0",
")",
"{",
"pfo",
".",
"configErrors",
".",
"push",
"(",
"'\"'",
"+",
"apiMethod",
"+",
"'\" was not called'",
")",
";",
"}",
"}",
"var",
"slots",
"=",
"pfo",
".",
"getSlots",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"slots",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"slots",
"[",
"i",
"]",
".",
"bidProviders",
".",
"length",
";",
"k",
"++",
")",
"{",
"var",
"providerName",
"=",
"slots",
"[",
"i",
"]",
".",
"bidProviders",
"[",
"k",
"]",
";",
"if",
"(",
"!",
"bidProviders",
"[",
"providerName",
"]",
")",
"{",
"pfo",
".",
"configErrors",
".",
"push",
"(",
"'No configuration found for bid provider \"'",
"+",
"providerName",
"+",
"'\"'",
")",
";",
"}",
"}",
"}",
"return",
"{",
"hasError",
":",
"pfo",
".",
"configErrors",
".",
"length",
">",
"0",
",",
"details",
":",
"pfo",
".",
"configErrors",
"}",
";",
"}"
] | validate the api configurations
@param {object} pfo a the pubfood object
@private
@return {{hasError: boolean, details: string[]}} | [
"validate",
"the",
"api",
"configurations"
] | be666e922d92f86fd1542e7c43f81126a9301771 | https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/pubfood.js#L44-L70 | train |
|
pubfood/pubfood | src/model/slot.js | Slot | function Slot(name, elementId) {
if (this.init_) {
this.init_();
}
this.name = name;
this.elementId = elementId;
this.bidProviders = [];
this.sizes = [];
} | javascript | function Slot(name, elementId) {
if (this.init_) {
this.init_();
}
this.name = name;
this.elementId = elementId;
this.bidProviders = [];
this.sizes = [];
} | [
"function",
"Slot",
"(",
"name",
",",
"elementId",
")",
"{",
"if",
"(",
"this",
".",
"init_",
")",
"{",
"this",
".",
"init_",
"(",
")",
";",
"}",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"elementId",
"=",
"elementId",
";",
"this",
".",
"bidProviders",
"=",
"[",
"]",
";",
"this",
".",
"sizes",
"=",
"[",
"]",
";",
"}"
] | Slot contains a definition of a publisher ad unit.
@class
@param {string} name the slot name
@param {string} elementId target DOM element id for the slot
@augments PubfoodObject
@memberof pubfood#model | [
"Slot",
"contains",
"a",
"definition",
"of",
"a",
"publisher",
"ad",
"unit",
"."
] | be666e922d92f86fd1542e7c43f81126a9301771 | https://github.com/pubfood/pubfood/blob/be666e922d92f86fd1542e7c43f81126a9301771/src/model/slot.js#L20-L28 | train |
strongloop/strong-mq | lib/adapters/stomp.js | encode | function encode(body) {
// Handles 3 cases
// - body is utf8 string
// - body is instance of Buffer
// - body is an object and its JSON representation is sent
// Does not handle the case for streaming bodies.
// Returns buffer.
if (typeof(body) == 'string') {
return [new Buffer(body, 'utf8')];
} else if (body instanceof Buffer) {
return [body];
} else {
var jsonBody = JSON.stringify(body);
return [new Buffer(jsonBody, 'utf8'), 'application/json'];
}
} | javascript | function encode(body) {
// Handles 3 cases
// - body is utf8 string
// - body is instance of Buffer
// - body is an object and its JSON representation is sent
// Does not handle the case for streaming bodies.
// Returns buffer.
if (typeof(body) == 'string') {
return [new Buffer(body, 'utf8')];
} else if (body instanceof Buffer) {
return [body];
} else {
var jsonBody = JSON.stringify(body);
return [new Buffer(jsonBody, 'utf8'), 'application/json'];
}
} | [
"function",
"encode",
"(",
"body",
")",
"{",
"if",
"(",
"typeof",
"(",
"body",
")",
"==",
"'string'",
")",
"{",
"return",
"[",
"new",
"Buffer",
"(",
"body",
",",
"'utf8'",
")",
"]",
";",
"}",
"else",
"if",
"(",
"body",
"instanceof",
"Buffer",
")",
"{",
"return",
"[",
"body",
"]",
";",
"}",
"else",
"{",
"var",
"jsonBody",
"=",
"JSON",
".",
"stringify",
"(",
"body",
")",
";",
"return",
"[",
"new",
"Buffer",
"(",
"jsonBody",
",",
"'utf8'",
")",
",",
"'application/json'",
"]",
";",
"}",
"}"
] | either encode msg as json, and return encoded msg and content-type value, or use string value and return null content-type @return [contentType, buffer] Note: implementation ripped out of node-amqp XXX should this be merged to STOMP? if so, could be optional, triggered only if body is not a string/buffer, and if header has no content-type. | [
"either",
"encode",
"msg",
"as",
"json",
"and",
"return",
"encoded",
"msg",
"and",
"content",
"-",
"type",
"value",
"or",
"use",
"string",
"value",
"and",
"return",
"null",
"content",
"-",
"type"
] | f46709850ce218168a2b45e2006e5ae55cf8e01b | https://github.com/strongloop/strong-mq/blob/f46709850ce218168a2b45e2006e5ae55cf8e01b/lib/adapters/stomp.js#L191-L206 | train |
lhkbob/eve-swagger-js | dist/util/esi-api.js | buildSimpleExample | function buildSimpleExample(type, example) {
// The values in schemaOrType refer to the type names of Swagger types
if (type === 'string') {
return typeof example === 'string' ? example : '';
}
else if (type === 'integer' || type === 'float' || type === 'number') {
return typeof example === 'number' ? example : 0;
}
else if (type === 'boolean') {
return typeof example === 'boolean' ? example : false;
}
else if (type === 'array') {
return Array.isArray(example) ? example : [];
}
else if (type === 'object') {
return typeof example === 'object' ? example : {};
}
else {
return null;
}
} | javascript | function buildSimpleExample(type, example) {
// The values in schemaOrType refer to the type names of Swagger types
if (type === 'string') {
return typeof example === 'string' ? example : '';
}
else if (type === 'integer' || type === 'float' || type === 'number') {
return typeof example === 'number' ? example : 0;
}
else if (type === 'boolean') {
return typeof example === 'boolean' ? example : false;
}
else if (type === 'array') {
return Array.isArray(example) ? example : [];
}
else if (type === 'object') {
return typeof example === 'object' ? example : {};
}
else {
return null;
}
} | [
"function",
"buildSimpleExample",
"(",
"type",
",",
"example",
")",
"{",
"if",
"(",
"type",
"===",
"'string'",
")",
"{",
"return",
"typeof",
"example",
"===",
"'string'",
"?",
"example",
":",
"''",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'integer'",
"||",
"type",
"===",
"'float'",
"||",
"type",
"===",
"'number'",
")",
"{",
"return",
"typeof",
"example",
"===",
"'number'",
"?",
"example",
":",
"0",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'boolean'",
")",
"{",
"return",
"typeof",
"example",
"===",
"'boolean'",
"?",
"example",
":",
"false",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'array'",
")",
"{",
"return",
"Array",
".",
"isArray",
"(",
"example",
")",
"?",
"example",
":",
"[",
"]",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'object'",
")",
"{",
"return",
"typeof",
"example",
"===",
"'object'",
"?",
"example",
":",
"{",
"}",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Implementation functions for constructing and validating dynamic objects with the types defined in the spec. | [
"Implementation",
"functions",
"for",
"constructing",
"and",
"validating",
"dynamic",
"objects",
"with",
"the",
"types",
"defined",
"in",
"the",
"spec",
"."
] | 1353126546b988dd4811fc4256c94f4d96f26c37 | https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/esi-api.js#L19-L39 | train |
lhkbob/eve-swagger-js | dist/util/type-generator/get-type-name.js | getTypeName | function getTypeName(namespace, type) {
let namespaceName = namespace.fullName;
let finalName;
for (let title of type.titles) {
let name = titleToTypeName(namespaceName, title);
if (finalName) {
if (name[1]) {
// An explicit type name, so make sure it isn't masking anything
if (finalName[1] && name[0] !== finalName[0]) {
// Previous explicit name from another title is different
throw new Error(title + '\'s override to ' + name[0]
+ ' would shadow explicit name of ' + finalName[0]);
}
// Otherwise take this name since it either is the same, or overrides
// a non-explicit name
finalName = name;
}
else if (!finalName[1] && name[0].length < finalName[0].length) {
// Take the shorter of the generated names
finalName = name;
}
}
else {
// First valid name
finalName = name;
}
}
if (finalName) {
return finalName;
}
else {
throw new Error('Unable to generate typename for ' + type.titles[0]);
}
} | javascript | function getTypeName(namespace, type) {
let namespaceName = namespace.fullName;
let finalName;
for (let title of type.titles) {
let name = titleToTypeName(namespaceName, title);
if (finalName) {
if (name[1]) {
// An explicit type name, so make sure it isn't masking anything
if (finalName[1] && name[0] !== finalName[0]) {
// Previous explicit name from another title is different
throw new Error(title + '\'s override to ' + name[0]
+ ' would shadow explicit name of ' + finalName[0]);
}
// Otherwise take this name since it either is the same, or overrides
// a non-explicit name
finalName = name;
}
else if (!finalName[1] && name[0].length < finalName[0].length) {
// Take the shorter of the generated names
finalName = name;
}
}
else {
// First valid name
finalName = name;
}
}
if (finalName) {
return finalName;
}
else {
throw new Error('Unable to generate typename for ' + type.titles[0]);
}
} | [
"function",
"getTypeName",
"(",
"namespace",
",",
"type",
")",
"{",
"let",
"namespaceName",
"=",
"namespace",
".",
"fullName",
";",
"let",
"finalName",
";",
"for",
"(",
"let",
"title",
"of",
"type",
".",
"titles",
")",
"{",
"let",
"name",
"=",
"titleToTypeName",
"(",
"namespaceName",
",",
"title",
")",
";",
"if",
"(",
"finalName",
")",
"{",
"if",
"(",
"name",
"[",
"1",
"]",
")",
"{",
"if",
"(",
"finalName",
"[",
"1",
"]",
"&&",
"name",
"[",
"0",
"]",
"!==",
"finalName",
"[",
"0",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"title",
"+",
"'\\'s override to '",
"+",
"\\'",
"+",
"name",
"[",
"0",
"]",
"+",
"' would shadow explicit name of '",
")",
";",
"}",
"finalName",
"[",
"0",
"]",
"}",
"else",
"finalName",
"=",
"name",
";",
"}",
"else",
"if",
"(",
"!",
"finalName",
"[",
"1",
"]",
"&&",
"name",
"[",
"0",
"]",
".",
"length",
"<",
"finalName",
"[",
"0",
"]",
".",
"length",
")",
"{",
"finalName",
"=",
"name",
";",
"}",
"}",
"{",
"finalName",
"=",
"name",
";",
"}",
"}"
] | No typings associated | [
"No",
"typings",
"associated"
] | 1353126546b988dd4811fc4256c94f4d96f26c37 | https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/util/type-generator/get-type-name.js#L5-L38 | train |
reklatsmasters/saslprep | lib/memory-code-points.js | read | function read() {
const size = memory.readUInt32BE(offset);
offset += 4;
const codepoints = memory.slice(offset, offset + size);
offset += size;
return bitfield({ buffer: codepoints });
} | javascript | function read() {
const size = memory.readUInt32BE(offset);
offset += 4;
const codepoints = memory.slice(offset, offset + size);
offset += size;
return bitfield({ buffer: codepoints });
} | [
"function",
"read",
"(",
")",
"{",
"const",
"size",
"=",
"memory",
".",
"readUInt32BE",
"(",
"offset",
")",
";",
"offset",
"+=",
"4",
";",
"const",
"codepoints",
"=",
"memory",
".",
"slice",
"(",
"offset",
",",
"offset",
"+",
"size",
")",
";",
"offset",
"+=",
"size",
";",
"return",
"bitfield",
"(",
"{",
"buffer",
":",
"codepoints",
"}",
")",
";",
"}"
] | Loads each code points sequence from buffer.
@returns {bitfield} | [
"Loads",
"each",
"code",
"points",
"sequence",
"from",
"buffer",
"."
] | 4ad8884b461a6a8e496d6e648ad5da0a1b43cb42 | https://github.com/reklatsmasters/saslprep/blob/4ad8884b461a6a8e496d6e648ad5da0a1b43cb42/lib/memory-code-points.js#L15-L23 | train |
mbanting/metalsmith-prismic | lib/index.js | processRetrievedContent | function processRetrievedContent(content, filePrismicMetadata, queryKey, ctx) {
if (content.results != null && content.results.length > 0) {
var queryMetadata = filePrismicMetadata[queryKey];
for (var i = 0; i < content.results.length; i++) {
var result = processRetrievedDocument(content.results[i], filePrismicMetadata, queryKey, ctx);
filePrismicMetadata[queryKey].results.push(result);
}
}
} | javascript | function processRetrievedContent(content, filePrismicMetadata, queryKey, ctx) {
if (content.results != null && content.results.length > 0) {
var queryMetadata = filePrismicMetadata[queryKey];
for (var i = 0; i < content.results.length; i++) {
var result = processRetrievedDocument(content.results[i], filePrismicMetadata, queryKey, ctx);
filePrismicMetadata[queryKey].results.push(result);
}
}
} | [
"function",
"processRetrievedContent",
"(",
"content",
",",
"filePrismicMetadata",
",",
"queryKey",
",",
"ctx",
")",
"{",
"if",
"(",
"content",
".",
"results",
"!=",
"null",
"&&",
"content",
".",
"results",
".",
"length",
">",
"0",
")",
"{",
"var",
"queryMetadata",
"=",
"filePrismicMetadata",
"[",
"queryKey",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"content",
".",
"results",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"result",
"=",
"processRetrievedDocument",
"(",
"content",
".",
"results",
"[",
"i",
"]",
",",
"filePrismicMetadata",
",",
"queryKey",
",",
"ctx",
")",
";",
"filePrismicMetadata",
"[",
"queryKey",
"]",
".",
"results",
".",
"push",
"(",
"result",
")",
";",
"}",
"}",
"}"
] | processes the retrieved content and adds it to the metadata | [
"processes",
"the",
"retrieved",
"content",
"and",
"adds",
"it",
"to",
"the",
"metadata"
] | f5b55568f68ee11975b36ddeaee3e55f9c8e4740 | https://github.com/mbanting/metalsmith-prismic/blob/f5b55568f68ee11975b36ddeaee3e55f9c8e4740/lib/index.js#L192-L200 | train |
mbanting/metalsmith-prismic | lib/index.js | processRetrievedDocument | function processRetrievedDocument(document, filePrismicMetadata, queryKey, ctx) {
// add the complete result except for the data fragments
var result = _.omit(document, 'fragments');
result.data = {};
// process the data fragments, invoking helpers to make the data more usable
if (document.fragments != null && Object.keys(document.fragments).length > 0) {
for (var fragmentFullName in document.fragments) {
// strip the document type from the fragment name
var fragmentName = fragmentFullName.substr(fragmentFullName.lastIndexOf('.') + 1);
var fragment = document.fragments[fragmentFullName];
result.data[fragmentName] = processSingleFragment(fragment, ctx, filePrismicMetadata[queryKey]);
}
}
return result;
} | javascript | function processRetrievedDocument(document, filePrismicMetadata, queryKey, ctx) {
// add the complete result except for the data fragments
var result = _.omit(document, 'fragments');
result.data = {};
// process the data fragments, invoking helpers to make the data more usable
if (document.fragments != null && Object.keys(document.fragments).length > 0) {
for (var fragmentFullName in document.fragments) {
// strip the document type from the fragment name
var fragmentName = fragmentFullName.substr(fragmentFullName.lastIndexOf('.') + 1);
var fragment = document.fragments[fragmentFullName];
result.data[fragmentName] = processSingleFragment(fragment, ctx, filePrismicMetadata[queryKey]);
}
}
return result;
} | [
"function",
"processRetrievedDocument",
"(",
"document",
",",
"filePrismicMetadata",
",",
"queryKey",
",",
"ctx",
")",
"{",
"var",
"result",
"=",
"_",
".",
"omit",
"(",
"document",
",",
"'fragments'",
")",
";",
"result",
".",
"data",
"=",
"{",
"}",
";",
"if",
"(",
"document",
".",
"fragments",
"!=",
"null",
"&&",
"Object",
".",
"keys",
"(",
"document",
".",
"fragments",
")",
".",
"length",
">",
"0",
")",
"{",
"for",
"(",
"var",
"fragmentFullName",
"in",
"document",
".",
"fragments",
")",
"{",
"var",
"fragmentName",
"=",
"fragmentFullName",
".",
"substr",
"(",
"fragmentFullName",
".",
"lastIndexOf",
"(",
"'.'",
")",
"+",
"1",
")",
";",
"var",
"fragment",
"=",
"document",
".",
"fragments",
"[",
"fragmentFullName",
"]",
";",
"result",
".",
"data",
"[",
"fragmentName",
"]",
"=",
"processSingleFragment",
"(",
"fragment",
",",
"ctx",
",",
"filePrismicMetadata",
"[",
"queryKey",
"]",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | processes and return single retrieved document | [
"processes",
"and",
"return",
"single",
"retrieved",
"document"
] | f5b55568f68ee11975b36ddeaee3e55f9c8e4740 | https://github.com/mbanting/metalsmith-prismic/blob/f5b55568f68ee11975b36ddeaee3e55f9c8e4740/lib/index.js#L203-L221 | train |
mbanting/metalsmith-prismic | lib/index.js | generateCollectionFiles | function generateCollectionFiles(fileName, collectionQuery, callback, ctx) {
if (collectionQuery != null) {
var file = files[fileName];
var newFiles = {};
var fileExtension = file.prismic[collectionQuery].collection.fileExtension;
var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:"";
// for every result in the collection query
for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) {
// clone the file and replace the original collectionQuery results with the current result
var newFile = clone(file);
newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]];
// add the filename to the ctx object to make it available for use in the linkResolver function
ctx.path = fileName;
// use the linkResolver to generate the filename removing the leading slash if present
newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile;
}
delete files[fileName];
_.extend(files, newFiles);
}
callback();
} | javascript | function generateCollectionFiles(fileName, collectionQuery, callback, ctx) {
if (collectionQuery != null) {
var file = files[fileName];
var newFiles = {};
var fileExtension = file.prismic[collectionQuery].collection.fileExtension;
var fileSuffix = (fileExtension != undefined && fileExtension !== "")? "." + fileExtension:"";
// for every result in the collection query
for (var i = 0; i < file.prismic[collectionQuery].results.length; i++) {
// clone the file and replace the original collectionQuery results with the current result
var newFile = clone(file);
newFile.prismic[collectionQuery].results = [file.prismic[collectionQuery].results[i]];
// add the filename to the ctx object to make it available for use in the linkResolver function
ctx.path = fileName;
// use the linkResolver to generate the filename removing the leading slash if present
newFiles[(ctx.linkResolver(file.prismic[collectionQuery].results[i]) + fileSuffix).replace(/^\//g, '')] = newFile;
}
delete files[fileName];
_.extend(files, newFiles);
}
callback();
} | [
"function",
"generateCollectionFiles",
"(",
"fileName",
",",
"collectionQuery",
",",
"callback",
",",
"ctx",
")",
"{",
"if",
"(",
"collectionQuery",
"!=",
"null",
")",
"{",
"var",
"file",
"=",
"files",
"[",
"fileName",
"]",
";",
"var",
"newFiles",
"=",
"{",
"}",
";",
"var",
"fileExtension",
"=",
"file",
".",
"prismic",
"[",
"collectionQuery",
"]",
".",
"collection",
".",
"fileExtension",
";",
"var",
"fileSuffix",
"=",
"(",
"fileExtension",
"!=",
"undefined",
"&&",
"fileExtension",
"!==",
"\"\"",
")",
"?",
"\".\"",
"+",
"fileExtension",
":",
"\"\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"file",
".",
"prismic",
"[",
"collectionQuery",
"]",
".",
"results",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"newFile",
"=",
"clone",
"(",
"file",
")",
";",
"newFile",
".",
"prismic",
"[",
"collectionQuery",
"]",
".",
"results",
"=",
"[",
"file",
".",
"prismic",
"[",
"collectionQuery",
"]",
".",
"results",
"[",
"i",
"]",
"]",
";",
"ctx",
".",
"path",
"=",
"fileName",
";",
"newFiles",
"[",
"(",
"ctx",
".",
"linkResolver",
"(",
"file",
".",
"prismic",
"[",
"collectionQuery",
"]",
".",
"results",
"[",
"i",
"]",
")",
"+",
"fileSuffix",
")",
".",
"replace",
"(",
"/",
"^\\/",
"/",
"g",
",",
"''",
")",
"]",
"=",
"newFile",
";",
"}",
"delete",
"files",
"[",
"fileName",
"]",
";",
"_",
".",
"extend",
"(",
"files",
",",
"newFiles",
")",
";",
"}",
"callback",
"(",
")",
";",
"}"
] | if any of the queries are designated the collection query, then generate a file for each of the results | [
"if",
"any",
"of",
"the",
"queries",
"are",
"designated",
"the",
"collection",
"query",
"then",
"generate",
"a",
"file",
"for",
"each",
"of",
"the",
"results"
] | f5b55568f68ee11975b36ddeaee3e55f9c8e4740 | https://github.com/mbanting/metalsmith-prismic/blob/f5b55568f68ee11975b36ddeaee3e55f9c8e4740/lib/index.js#L310-L335 | train |
strongloop/strong-mq | lib/adapters/native/broker.js | _final | function _final() {
var self = this;
cluster.removeListener('fork', self._onFork);
cluster.removeListener('disconnect', self._onDisconnect);
} | javascript | function _final() {
var self = this;
cluster.removeListener('fork', self._onFork);
cluster.removeListener('disconnect', self._onDisconnect);
} | [
"function",
"_final",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"cluster",
".",
"removeListener",
"(",
"'fork'",
",",
"self",
".",
"_onFork",
")",
";",
"cluster",
".",
"removeListener",
"(",
"'disconnect'",
",",
"self",
".",
"_onDisconnect",
")",
";",
"}"
] | Not normally called, but we might need something like it in tests to reset state back to initial. | [
"Not",
"normally",
"called",
"but",
"we",
"might",
"need",
"something",
"like",
"it",
"in",
"tests",
"to",
"reset",
"state",
"back",
"to",
"initial",
"."
] | f46709850ce218168a2b45e2006e5ae55cf8e01b | https://github.com/strongloop/strong-mq/blob/f46709850ce218168a2b45e2006e5ae55cf8e01b/lib/adapters/native/broker.js#L74-L79 | train |
Nicklason/node-bptf-listings | index.js | Listings | function Listings (options) {
options = options || {};
EventEmitter.call(this);
this.accessToken = options.accessToken;
this.steamid64 = options.steamid64;
this.waitTime = options.waitTime || 1000;
this.cap = -1;
this.promotes = -1;
this.listings = [];
this.actions = {
create: [],
remove: []
};
this.items = options.items || new Items({ apiKey: options.apiKey });
this.ready = false;
} | javascript | function Listings (options) {
options = options || {};
EventEmitter.call(this);
this.accessToken = options.accessToken;
this.steamid64 = options.steamid64;
this.waitTime = options.waitTime || 1000;
this.cap = -1;
this.promotes = -1;
this.listings = [];
this.actions = {
create: [],
remove: []
};
this.items = options.items || new Items({ apiKey: options.apiKey });
this.ready = false;
} | [
"function",
"Listings",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"accessToken",
"=",
"options",
".",
"accessToken",
";",
"this",
".",
"steamid64",
"=",
"options",
".",
"steamid64",
";",
"this",
".",
"waitTime",
"=",
"options",
".",
"waitTime",
"||",
"1000",
";",
"this",
".",
"cap",
"=",
"-",
"1",
";",
"this",
".",
"promotes",
"=",
"-",
"1",
";",
"this",
".",
"listings",
"=",
"[",
"]",
";",
"this",
".",
"actions",
"=",
"{",
"create",
":",
"[",
"]",
",",
"remove",
":",
"[",
"]",
"}",
";",
"this",
".",
"items",
"=",
"options",
".",
"items",
"||",
"new",
"Items",
"(",
"{",
"apiKey",
":",
"options",
".",
"apiKey",
"}",
")",
";",
"this",
".",
"ready",
"=",
"false",
";",
"}"
] | Creates a new instance of bptf-listings
@class
@param {object} options Optional settings | [
"Creates",
"a",
"new",
"instance",
"of",
"bptf",
"-",
"listings"
] | 8ed38a4e2457603ec2941991e8af924531e8389b | https://github.com/Nicklason/node-bptf-listings/blob/8ed38a4e2457603ec2941991e8af924531e8389b/index.js#L19-L41 | train |
polygonplanet/Chiffon | chiffon.js | function() {
switch (this.type) {
case _Numeric:
case _String:
case _RegularExpression:
case _Boolean:
case _Null:
return this.parseLiteral();
case _Identifier:
return this.parseIdentifier();
case _Keyword:
return this.parsePrimaryKeywordExpression();
case _Punctuator:
return this.parsePrimaryPunctuatorExpression();
case _Template:
return this.parseTemplateLiteral();
default:
this.unexpected();
}
} | javascript | function() {
switch (this.type) {
case _Numeric:
case _String:
case _RegularExpression:
case _Boolean:
case _Null:
return this.parseLiteral();
case _Identifier:
return this.parseIdentifier();
case _Keyword:
return this.parsePrimaryKeywordExpression();
case _Punctuator:
return this.parsePrimaryPunctuatorExpression();
case _Template:
return this.parseTemplateLiteral();
default:
this.unexpected();
}
} | [
"function",
"(",
")",
"{",
"switch",
"(",
"this",
".",
"type",
")",
"{",
"case",
"_Numeric",
":",
"case",
"_String",
":",
"case",
"_RegularExpression",
":",
"case",
"_Boolean",
":",
"case",
"_Null",
":",
"return",
"this",
".",
"parseLiteral",
"(",
")",
";",
"case",
"_Identifier",
":",
"return",
"this",
".",
"parseIdentifier",
"(",
")",
";",
"case",
"_Keyword",
":",
"return",
"this",
".",
"parsePrimaryKeywordExpression",
"(",
")",
";",
"case",
"_Punctuator",
":",
"return",
"this",
".",
"parsePrimaryPunctuatorExpression",
"(",
")",
";",
"case",
"_Template",
":",
"return",
"this",
".",
"parseTemplateLiteral",
"(",
")",
";",
"default",
":",
"this",
".",
"unexpected",
"(",
")",
";",
"}",
"}"
] | ECMA-262 12.2 Primary Expression | [
"ECMA",
"-",
"262",
"12",
".",
"2",
"Primary",
"Expression"
] | 4adb7066aff6b58b60b1b72995a216b334421b84 | https://github.com/polygonplanet/Chiffon/blob/4adb7066aff6b58b60b1b72995a216b334421b84/chiffon.js#L1267-L1286 | train |
|
polygonplanet/Chiffon | chiffon.js | function(allowIn) {
var node = this.startNode(_SequenceExpression);
var expr = this.parseAssignmentExpression(allowIn);
if (this.value !== ',') {
return expr;
}
var exprs = [expr];
do {
this.next();
exprs[exprs.length] = this.parseAssignmentExpression(allowIn);
} while (this.value === ',');
node.expressions = exprs;
return this.finishNode(node);
} | javascript | function(allowIn) {
var node = this.startNode(_SequenceExpression);
var expr = this.parseAssignmentExpression(allowIn);
if (this.value !== ',') {
return expr;
}
var exprs = [expr];
do {
this.next();
exprs[exprs.length] = this.parseAssignmentExpression(allowIn);
} while (this.value === ',');
node.expressions = exprs;
return this.finishNode(node);
} | [
"function",
"(",
"allowIn",
")",
"{",
"var",
"node",
"=",
"this",
".",
"startNode",
"(",
"_SequenceExpression",
")",
";",
"var",
"expr",
"=",
"this",
".",
"parseAssignmentExpression",
"(",
"allowIn",
")",
";",
"if",
"(",
"this",
".",
"value",
"!==",
"','",
")",
"{",
"return",
"expr",
";",
"}",
"var",
"exprs",
"=",
"[",
"expr",
"]",
";",
"do",
"{",
"this",
".",
"next",
"(",
")",
";",
"exprs",
"[",
"exprs",
".",
"length",
"]",
"=",
"this",
".",
"parseAssignmentExpression",
"(",
"allowIn",
")",
";",
"}",
"while",
"(",
"this",
".",
"value",
"===",
"','",
")",
";",
"node",
".",
"expressions",
"=",
"exprs",
";",
"return",
"this",
".",
"finishNode",
"(",
"node",
")",
";",
"}"
] | ECMA-262 A.2 Expressions | [
"ECMA",
"-",
"262",
"A",
".",
"2",
"Expressions"
] | 4adb7066aff6b58b60b1b72995a216b334421b84 | https://github.com/polygonplanet/Chiffon/blob/4adb7066aff6b58b60b1b72995a216b334421b84/chiffon.js#L1520-L1536 | train |
|
polygonplanet/Chiffon | chiffon.js | function() {
var node = this.startNode(_IfStatement);
this.expect('if');
this.expect('(');
var expr = this.parseExpression(true);
this.expect(')');
var consequent = this.parseStatement();
var alternate = null;
if (this.value === 'else') {
this.next();
alternate = this.parseStatement();
}
node.test = expr;
node.consequent = consequent;
node.alternate = alternate;
return this.finishNode(node);
} | javascript | function() {
var node = this.startNode(_IfStatement);
this.expect('if');
this.expect('(');
var expr = this.parseExpression(true);
this.expect(')');
var consequent = this.parseStatement();
var alternate = null;
if (this.value === 'else') {
this.next();
alternate = this.parseStatement();
}
node.test = expr;
node.consequent = consequent;
node.alternate = alternate;
return this.finishNode(node);
} | [
"function",
"(",
")",
"{",
"var",
"node",
"=",
"this",
".",
"startNode",
"(",
"_IfStatement",
")",
";",
"this",
".",
"expect",
"(",
"'if'",
")",
";",
"this",
".",
"expect",
"(",
"'('",
")",
";",
"var",
"expr",
"=",
"this",
".",
"parseExpression",
"(",
"true",
")",
";",
"this",
".",
"expect",
"(",
"')'",
")",
";",
"var",
"consequent",
"=",
"this",
".",
"parseStatement",
"(",
")",
";",
"var",
"alternate",
"=",
"null",
";",
"if",
"(",
"this",
".",
"value",
"===",
"'else'",
")",
"{",
"this",
".",
"next",
"(",
")",
";",
"alternate",
"=",
"this",
".",
"parseStatement",
"(",
")",
";",
"}",
"node",
".",
"test",
"=",
"expr",
";",
"node",
".",
"consequent",
"=",
"consequent",
";",
"node",
".",
"alternate",
"=",
"alternate",
";",
"return",
"this",
".",
"finishNode",
"(",
"node",
")",
";",
"}"
] | ECMA-262 13 Statements and Declarations | [
"ECMA",
"-",
"262",
"13",
"Statements",
"and",
"Declarations"
] | 4adb7066aff6b58b60b1b72995a216b334421b84 | https://github.com/polygonplanet/Chiffon/blob/4adb7066aff6b58b60b1b72995a216b334421b84/chiffon.js#L2198-L2217 | train |
|
lhkbob/eve-swagger-js | dist/src/internal/names.js | getNames | function getNames(agent, category, ids) {
return _getNames(agent, category, ids).then(array => {
let map = new Map();
for (let n of array) {
map.set(n.id, n.name);
}
return map;
});
} | javascript | function getNames(agent, category, ids) {
return _getNames(agent, category, ids).then(array => {
let map = new Map();
for (let n of array) {
map.set(n.id, n.name);
}
return map;
});
} | [
"function",
"getNames",
"(",
"agent",
",",
"category",
",",
"ids",
")",
"{",
"return",
"_getNames",
"(",
"agent",
",",
"category",
",",
"ids",
")",
".",
"then",
"(",
"array",
"=>",
"{",
"let",
"map",
"=",
"new",
"Map",
"(",
")",
";",
"for",
"(",
"let",
"n",
"of",
"array",
")",
"{",
"map",
".",
"set",
"(",
"n",
".",
"id",
",",
"n",
".",
"name",
")",
";",
"}",
"return",
"map",
";",
"}",
")",
";",
"}"
] | Look up the names of a set of ids, restricted to a particular name category.
This utility function automatically splits large arrays of ids into lists of
500 elements and then recombines the results. It also maps the response data
from the internal ESI representation into a more useful Map from id to name.
@param agent The agent making requests
@param category The category of names to look up
@param ids The list of ids to resolve, should not contain duplicates
@returns Promise resolving to a Map from id to name | [
"Look",
"up",
"the",
"names",
"of",
"a",
"set",
"of",
"ids",
"restricted",
"to",
"a",
"particular",
"name",
"category",
".",
"This",
"utility",
"function",
"automatically",
"splits",
"large",
"arrays",
"of",
"ids",
"into",
"lists",
"of",
"500",
"elements",
"and",
"then",
"recombines",
"the",
"results",
".",
"It",
"also",
"maps",
"the",
"response",
"data",
"from",
"the",
"internal",
"ESI",
"representation",
"into",
"a",
"more",
"useful",
"Map",
"from",
"id",
"to",
"name",
"."
] | 1353126546b988dd4811fc4256c94f4d96f26c37 | https://github.com/lhkbob/eve-swagger-js/blob/1353126546b988dd4811fc4256c94f4d96f26c37/dist/src/internal/names.js#L14-L22 | train |
nathanhammond/ember-route-alias | addon/initializers/route-alias.js | createAlias | function createAlias() {
Ember.RouterDSL.prototype.alias = function(aliasRoute, aliasPath, aliasTarget) {
Ember.assert('You must create a route prior to creating an alias.', this.handlers || this.intercepting);
Ember.assert('The alias target must exist before attempting to alias it.', this.handlers[aliasTarget]);
// Grab a reference to the arguments passed in for the original route.
let [options, callback] = this.handlers[aliasTarget];
options.path = aliasPath;
this.intercepting.push({ aliasRoute, aliasTarget });
this.route(aliasRoute, options, callback);
};
} | javascript | function createAlias() {
Ember.RouterDSL.prototype.alias = function(aliasRoute, aliasPath, aliasTarget) {
Ember.assert('You must create a route prior to creating an alias.', this.handlers || this.intercepting);
Ember.assert('The alias target must exist before attempting to alias it.', this.handlers[aliasTarget]);
// Grab a reference to the arguments passed in for the original route.
let [options, callback] = this.handlers[aliasTarget];
options.path = aliasPath;
this.intercepting.push({ aliasRoute, aliasTarget });
this.route(aliasRoute, options, callback);
};
} | [
"function",
"createAlias",
"(",
")",
"{",
"Ember",
".",
"RouterDSL",
".",
"prototype",
".",
"alias",
"=",
"function",
"(",
"aliasRoute",
",",
"aliasPath",
",",
"aliasTarget",
")",
"{",
"Ember",
".",
"assert",
"(",
"'You must create a route prior to creating an alias.'",
",",
"this",
".",
"handlers",
"||",
"this",
".",
"intercepting",
")",
";",
"Ember",
".",
"assert",
"(",
"'The alias target must exist before attempting to alias it.'",
",",
"this",
".",
"handlers",
"[",
"aliasTarget",
"]",
")",
";",
"let",
"[",
"options",
",",
"callback",
"]",
"=",
"this",
".",
"handlers",
"[",
"aliasTarget",
"]",
";",
"options",
".",
"path",
"=",
"aliasPath",
";",
"this",
".",
"intercepting",
".",
"push",
"(",
"{",
"aliasRoute",
",",
"aliasTarget",
"}",
")",
";",
"this",
".",
"route",
"(",
"aliasRoute",
",",
"options",
",",
"callback",
")",
";",
"}",
";",
"}"
] | Sets up our magic alias function. | [
"Sets",
"up",
"our",
"magic",
"alias",
"function",
"."
] | e1f39cd775662b6e5dbae1654b8584902f8f44e2 | https://github.com/nathanhammond/ember-route-alias/blob/e1f39cd775662b6e5dbae1654b8584902f8f44e2/addon/initializers/route-alias.js#L16-L29 | train |
nathanhammond/ember-route-alias | addon/initializers/route-alias.js | patchRoute | function patchRoute(lookup) {
// Save off the original method in scope of the prototype modifications.
let originalRouteMethod = Ember.RouterDSL.prototype.route;
// We need to do a few things before and after the original route function.
Ember.RouterDSL.prototype.route = function(name, options, callback) {
Ember.assert('You may not include a "." in your route name.', !~name.indexOf('.'));
// Method signature identification from the original method.
if (arguments.length === 2 && typeof options === 'function') {
callback = options;
options = {};
}
if (arguments.length === 1) {
options = {};
}
// Save off a reference to the original arguments in a reachable scope.
// This is so later calls to `alias` have something to find.
if (!this.handlers) { this.handlers = {}; }
this.handlers[name] = [ options, callback ];
// For storing the root of the aliased route.
if (!this.intercepting) { this.intercepting = []; }
// So, we're "recursing" through a structure, but we can sneak in by wrapping the invoked function.
if (this.intercepting.length) {
// Make the callback modify the DSL generated for nested routes.
// Necessary so they can register themselves.
// Propogate the original interception information forward.
var currentIntercepting = this.intercepting[this.intercepting.length - 1];
let interceptingCallback = function() {
this.intercepting = [currentIntercepting];
callback.call(this);
};
// Figure out how many routes we created.
let originalLength = [].concat.apply([], this.matches).length;
originalRouteMethod.call(this, name, options, callback ? interceptingCallback : undefined);
let newMatches = [].concat.apply([], this.matches);
let newLength = newMatches.length;
// Add each of them to the lookup.
for (let i = originalLength; i < newLength; i += 3) {
let intermediate = newMatches[i + 1].split('.');
let qualifiedAliasRoute = intermediate.join('/');
let qualifiedTargetRoute = qualifiedAliasRoute.replace(currentIntercepting.aliasRoute, currentIntercepting.aliasTarget);
if (qualifiedAliasRoute !== qualifiedTargetRoute) {
lookup[qualifiedAliasRoute] = qualifiedTargetRoute;
} else {
// For index routes we need to try again with the base intercepting object.
let isIndex = intermediate.pop().indexOf('index') === 0;
qualifiedTargetRoute = qualifiedAliasRoute.replace(this.intercepting[0].aliasRoute, this.intercepting[0].aliasTarget);
if (isIndex && qualifiedAliasRoute !== qualifiedTargetRoute) {
lookup[qualifiedAliasRoute] = qualifiedTargetRoute;
}
}
}
} else {
originalRouteMethod.call(this, name, options, callback);
}
};
} | javascript | function patchRoute(lookup) {
// Save off the original method in scope of the prototype modifications.
let originalRouteMethod = Ember.RouterDSL.prototype.route;
// We need to do a few things before and after the original route function.
Ember.RouterDSL.prototype.route = function(name, options, callback) {
Ember.assert('You may not include a "." in your route name.', !~name.indexOf('.'));
// Method signature identification from the original method.
if (arguments.length === 2 && typeof options === 'function') {
callback = options;
options = {};
}
if (arguments.length === 1) {
options = {};
}
// Save off a reference to the original arguments in a reachable scope.
// This is so later calls to `alias` have something to find.
if (!this.handlers) { this.handlers = {}; }
this.handlers[name] = [ options, callback ];
// For storing the root of the aliased route.
if (!this.intercepting) { this.intercepting = []; }
// So, we're "recursing" through a structure, but we can sneak in by wrapping the invoked function.
if (this.intercepting.length) {
// Make the callback modify the DSL generated for nested routes.
// Necessary so they can register themselves.
// Propogate the original interception information forward.
var currentIntercepting = this.intercepting[this.intercepting.length - 1];
let interceptingCallback = function() {
this.intercepting = [currentIntercepting];
callback.call(this);
};
// Figure out how many routes we created.
let originalLength = [].concat.apply([], this.matches).length;
originalRouteMethod.call(this, name, options, callback ? interceptingCallback : undefined);
let newMatches = [].concat.apply([], this.matches);
let newLength = newMatches.length;
// Add each of them to the lookup.
for (let i = originalLength; i < newLength; i += 3) {
let intermediate = newMatches[i + 1].split('.');
let qualifiedAliasRoute = intermediate.join('/');
let qualifiedTargetRoute = qualifiedAliasRoute.replace(currentIntercepting.aliasRoute, currentIntercepting.aliasTarget);
if (qualifiedAliasRoute !== qualifiedTargetRoute) {
lookup[qualifiedAliasRoute] = qualifiedTargetRoute;
} else {
// For index routes we need to try again with the base intercepting object.
let isIndex = intermediate.pop().indexOf('index') === 0;
qualifiedTargetRoute = qualifiedAliasRoute.replace(this.intercepting[0].aliasRoute, this.intercepting[0].aliasTarget);
if (isIndex && qualifiedAliasRoute !== qualifiedTargetRoute) {
lookup[qualifiedAliasRoute] = qualifiedTargetRoute;
}
}
}
} else {
originalRouteMethod.call(this, name, options, callback);
}
};
} | [
"function",
"patchRoute",
"(",
"lookup",
")",
"{",
"let",
"originalRouteMethod",
"=",
"Ember",
".",
"RouterDSL",
".",
"prototype",
".",
"route",
";",
"Ember",
".",
"RouterDSL",
".",
"prototype",
".",
"route",
"=",
"function",
"(",
"name",
",",
"options",
",",
"callback",
")",
"{",
"Ember",
".",
"assert",
"(",
"'You may not include a \".\" in your route name.'",
",",
"!",
"~",
"name",
".",
"indexOf",
"(",
"'.'",
")",
")",
";",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
"&&",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
";",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"this",
".",
"handlers",
")",
"{",
"this",
".",
"handlers",
"=",
"{",
"}",
";",
"}",
"this",
".",
"handlers",
"[",
"name",
"]",
"=",
"[",
"options",
",",
"callback",
"]",
";",
"if",
"(",
"!",
"this",
".",
"intercepting",
")",
"{",
"this",
".",
"intercepting",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"this",
".",
"intercepting",
".",
"length",
")",
"{",
"var",
"currentIntercepting",
"=",
"this",
".",
"intercepting",
"[",
"this",
".",
"intercepting",
".",
"length",
"-",
"1",
"]",
";",
"let",
"interceptingCallback",
"=",
"function",
"(",
")",
"{",
"this",
".",
"intercepting",
"=",
"[",
"currentIntercepting",
"]",
";",
"callback",
".",
"call",
"(",
"this",
")",
";",
"}",
";",
"let",
"originalLength",
"=",
"[",
"]",
".",
"concat",
".",
"apply",
"(",
"[",
"]",
",",
"this",
".",
"matches",
")",
".",
"length",
";",
"originalRouteMethod",
".",
"call",
"(",
"this",
",",
"name",
",",
"options",
",",
"callback",
"?",
"interceptingCallback",
":",
"undefined",
")",
";",
"let",
"newMatches",
"=",
"[",
"]",
".",
"concat",
".",
"apply",
"(",
"[",
"]",
",",
"this",
".",
"matches",
")",
";",
"let",
"newLength",
"=",
"newMatches",
".",
"length",
";",
"for",
"(",
"let",
"i",
"=",
"originalLength",
";",
"i",
"<",
"newLength",
";",
"i",
"+=",
"3",
")",
"{",
"let",
"intermediate",
"=",
"newMatches",
"[",
"i",
"+",
"1",
"]",
".",
"split",
"(",
"'.'",
")",
";",
"let",
"qualifiedAliasRoute",
"=",
"intermediate",
".",
"join",
"(",
"'/'",
")",
";",
"let",
"qualifiedTargetRoute",
"=",
"qualifiedAliasRoute",
".",
"replace",
"(",
"currentIntercepting",
".",
"aliasRoute",
",",
"currentIntercepting",
".",
"aliasTarget",
")",
";",
"if",
"(",
"qualifiedAliasRoute",
"!==",
"qualifiedTargetRoute",
")",
"{",
"lookup",
"[",
"qualifiedAliasRoute",
"]",
"=",
"qualifiedTargetRoute",
";",
"}",
"else",
"{",
"let",
"isIndex",
"=",
"intermediate",
".",
"pop",
"(",
")",
".",
"indexOf",
"(",
"'index'",
")",
"===",
"0",
";",
"qualifiedTargetRoute",
"=",
"qualifiedAliasRoute",
".",
"replace",
"(",
"this",
".",
"intercepting",
"[",
"0",
"]",
".",
"aliasRoute",
",",
"this",
".",
"intercepting",
"[",
"0",
"]",
".",
"aliasTarget",
")",
";",
"if",
"(",
"isIndex",
"&&",
"qualifiedAliasRoute",
"!==",
"qualifiedTargetRoute",
")",
"{",
"lookup",
"[",
"qualifiedAliasRoute",
"]",
"=",
"qualifiedTargetRoute",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"originalRouteMethod",
".",
"call",
"(",
"this",
",",
"name",
",",
"options",
",",
"callback",
")",
";",
"}",
"}",
";",
"}"
] | Patches the RouterDSL route function to work with aliases. | [
"Patches",
"the",
"RouterDSL",
"route",
"function",
"to",
"work",
"with",
"aliases",
"."
] | e1f39cd775662b6e5dbae1654b8584902f8f44e2 | https://github.com/nathanhammond/ember-route-alias/blob/e1f39cd775662b6e5dbae1654b8584902f8f44e2/addon/initializers/route-alias.js#L32-L98 | train |
ethjs/ethjs-account | src/index.js | getAddress | function getAddress(addressInput) {
var address = addressInput; // eslint-disable-line
var result = null; // eslint-disable-line
if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); }
// Missing the 0x prefix
if (address.substring(0, 2) !== '0x' &&
address.substring(0, 2) !== 'XE') { address = `0x${address}`; }
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
result = getChecksumAddress(address);
// It is a checksummed address with a bad checksum
if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
throw new Error('[ethjs-account] invalid address checksum');
}
// Maybe ICAP? (we only support direct mode)
} else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..');
/*
// It is an ICAP address with a bad checksum
if (address.substring(2, 4) !== ibanChecksum(address)) {
throw new Error('invalid address icap checksum');
}
result = (new BN(address.substring(4), 36)).toString(16);
while (result.length < 40) { result = '0' + result; }
result = getChecksumAddress('0x' + result);
*/
} else {
throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`);
}
return result;
} | javascript | function getAddress(addressInput) {
var address = addressInput; // eslint-disable-line
var result = null; // eslint-disable-line
if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); }
// Missing the 0x prefix
if (address.substring(0, 2) !== '0x' &&
address.substring(0, 2) !== 'XE') { address = `0x${address}`; }
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
result = getChecksumAddress(address);
// It is a checksummed address with a bad checksum
if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
throw new Error('[ethjs-account] invalid address checksum');
}
// Maybe ICAP? (we only support direct mode)
} else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..');
/*
// It is an ICAP address with a bad checksum
if (address.substring(2, 4) !== ibanChecksum(address)) {
throw new Error('invalid address icap checksum');
}
result = (new BN(address.substring(4), 36)).toString(16);
while (result.length < 40) { result = '0' + result; }
result = getChecksumAddress('0x' + result);
*/
} else {
throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`);
}
return result;
} | [
"function",
"getAddress",
"(",
"addressInput",
")",
"{",
"var",
"address",
"=",
"addressInput",
";",
"var",
"result",
"=",
"null",
";",
"if",
"(",
"typeof",
"(",
"address",
")",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"address",
")",
"}",
"`",
")",
";",
"}",
"if",
"(",
"address",
".",
"substring",
"(",
"0",
",",
"2",
")",
"!==",
"'0x'",
"&&",
"address",
".",
"substring",
"(",
"0",
",",
"2",
")",
"!==",
"'XE'",
")",
"{",
"address",
"=",
"`",
"${",
"address",
"}",
"`",
";",
"}",
"if",
"(",
"address",
".",
"match",
"(",
"/",
"^(0x)?[0-9a-fA-F]{40}$",
"/",
")",
")",
"{",
"result",
"=",
"getChecksumAddress",
"(",
"address",
")",
";",
"if",
"(",
"address",
".",
"match",
"(",
"/",
"([A-F].*[a-f])|([a-f].*[A-F])",
"/",
")",
"&&",
"result",
"!==",
"address",
")",
"{",
"throw",
"new",
"Error",
"(",
"'[ethjs-account] invalid address checksum'",
")",
";",
"}",
"}",
"else",
"if",
"(",
"address",
".",
"match",
"(",
"/",
"^XE[0-9]{2}[0-9A-Za-z]{30,31}$",
"/",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'[ethjs-account] ICAP and IBAN addresses, not supported yet..'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"address",
")",
"}",
"`",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Get the address from a public key
@method getAddress
@param {String} addressInput
@returns {String} output the string is a hex string | [
"Get",
"the",
"address",
"from",
"a",
"public",
"key"
] | 7cbdd667a8c21c8546436650d17bcc9735d7d6bb | https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L25-L62 | train |
ethjs/ethjs-account | src/index.js | privateToPublic | function privateToPublic(privateKey) {
if (typeof privateKey !== 'string') { throw new Error(`[ethjs-account] private key must be type String, got ${typeof(privateKey)}`); }
if (!privateKey.match(/^(0x)?[0-9a-fA-F]{64}$/)) { throw new Error('[ethjs-account] private key must be an alphanumeric hex string that is 32 bytes long.'); }
const privateKeyBuffer = new Buffer(stripHexPrefix(privateKey), 'hex');
return (new Buffer(secp256k1.keyFromPrivate(privateKeyBuffer).getPublic(false, 'hex'), 'hex')).slice(1);
} | javascript | function privateToPublic(privateKey) {
if (typeof privateKey !== 'string') { throw new Error(`[ethjs-account] private key must be type String, got ${typeof(privateKey)}`); }
if (!privateKey.match(/^(0x)?[0-9a-fA-F]{64}$/)) { throw new Error('[ethjs-account] private key must be an alphanumeric hex string that is 32 bytes long.'); }
const privateKeyBuffer = new Buffer(stripHexPrefix(privateKey), 'hex');
return (new Buffer(secp256k1.keyFromPrivate(privateKeyBuffer).getPublic(false, 'hex'), 'hex')).slice(1);
} | [
"function",
"privateToPublic",
"(",
"privateKey",
")",
"{",
"if",
"(",
"typeof",
"privateKey",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"typeof",
"(",
"privateKey",
")",
"}",
"`",
")",
";",
"}",
"if",
"(",
"!",
"privateKey",
".",
"match",
"(",
"/",
"^(0x)?[0-9a-fA-F]{64}$",
"/",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'[ethjs-account] private key must be an alphanumeric hex string that is 32 bytes long.'",
")",
";",
"}",
"const",
"privateKeyBuffer",
"=",
"new",
"Buffer",
"(",
"stripHexPrefix",
"(",
"privateKey",
")",
",",
"'hex'",
")",
";",
"return",
"(",
"new",
"Buffer",
"(",
"secp256k1",
".",
"keyFromPrivate",
"(",
"privateKeyBuffer",
")",
".",
"getPublic",
"(",
"false",
",",
"'hex'",
")",
",",
"'hex'",
")",
")",
".",
"slice",
"(",
"1",
")",
";",
"}"
] | Returns the public key for this private key.
@method privateToPublic
@param {String} privateKey a valid private key hex
@returns {Object} publicKey the sepk 160 byte public key for this private key | [
"Returns",
"the",
"public",
"key",
"for",
"this",
"private",
"key",
"."
] | 7cbdd667a8c21c8546436650d17bcc9735d7d6bb | https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L72-L78 | train |
ethjs/ethjs-account | src/index.js | publicToAddress | function publicToAddress(publicKey) {
if (!Buffer.isBuffer(publicKey)) { throw new Error('[ethjs-account] public key must be a buffer object in order to get public key address'); }
return getAddress(sha3(publicKey, true).slice(12).toString('hex'));
} | javascript | function publicToAddress(publicKey) {
if (!Buffer.isBuffer(publicKey)) { throw new Error('[ethjs-account] public key must be a buffer object in order to get public key address'); }
return getAddress(sha3(publicKey, true).slice(12).toString('hex'));
} | [
"function",
"publicToAddress",
"(",
"publicKey",
")",
"{",
"if",
"(",
"!",
"Buffer",
".",
"isBuffer",
"(",
"publicKey",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'[ethjs-account] public key must be a buffer object in order to get public key address'",
")",
";",
"}",
"return",
"getAddress",
"(",
"sha3",
"(",
"publicKey",
",",
"true",
")",
".",
"slice",
"(",
"12",
")",
".",
"toString",
"(",
"'hex'",
")",
")",
";",
"}"
] | Returns the Ethereum standard address of a public sepk key.
@method publicToAddress
@param {Object} publicKey a single public key Buffer object
@returns {String} address the 20 byte Ethereum address | [
"Returns",
"the",
"Ethereum",
"standard",
"address",
"of",
"a",
"public",
"sepk",
"key",
"."
] | 7cbdd667a8c21c8546436650d17bcc9735d7d6bb | https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L88-L92 | train |
ethjs/ethjs-account | src/index.js | privateToAccount | function privateToAccount(privateKey) {
const publicKey = privateToPublic(privateKey, true);
return {
privateKey: `0x${stripHexPrefix(privateKey)}`,
publicKey: `0x${publicKey.toString('hex')}`,
address: publicToAddress(publicKey),
};
} | javascript | function privateToAccount(privateKey) {
const publicKey = privateToPublic(privateKey, true);
return {
privateKey: `0x${stripHexPrefix(privateKey)}`,
publicKey: `0x${publicKey.toString('hex')}`,
address: publicToAddress(publicKey),
};
} | [
"function",
"privateToAccount",
"(",
"privateKey",
")",
"{",
"const",
"publicKey",
"=",
"privateToPublic",
"(",
"privateKey",
",",
"true",
")",
";",
"return",
"{",
"privateKey",
":",
"`",
"${",
"stripHexPrefix",
"(",
"privateKey",
")",
"}",
"`",
",",
"publicKey",
":",
"`",
"${",
"publicKey",
".",
"toString",
"(",
"'hex'",
")",
"}",
"`",
",",
"address",
":",
"publicToAddress",
"(",
"publicKey",
")",
",",
"}",
";",
"}"
] | Returns an Ethereum account address, private and public key based on the public key.
@method privateToAccount
@param {String} privateKey a single string of entropy longer than 32 chars
@returns {Object} output the Ethereum account address, and keys as hex strings | [
"Returns",
"an",
"Ethereum",
"account",
"address",
"private",
"and",
"public",
"key",
"based",
"on",
"the",
"public",
"key",
"."
] | 7cbdd667a8c21c8546436650d17bcc9735d7d6bb | https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L102-L110 | train |
ethjs/ethjs-account | src/index.js | generate | function generate(entropy) {
if (typeof entropy !== 'string') { throw new Error(`[ethjs-account] while generating account, invalid input type: '${typeof(entropy)}' should be type 'String'.`); }
if (entropy.length < 32) { throw new Error(`[ethjs-account] while generating account, entropy value not random and long enough, should be at least 32 characters of random information, is only ${entropy.length}`); }
return privateToAccount(sha3(`${randomhex(16)}${sha3(`${randomhex(32)}${entropy}`)}${randomhex(32)}`));
} | javascript | function generate(entropy) {
if (typeof entropy !== 'string') { throw new Error(`[ethjs-account] while generating account, invalid input type: '${typeof(entropy)}' should be type 'String'.`); }
if (entropy.length < 32) { throw new Error(`[ethjs-account] while generating account, entropy value not random and long enough, should be at least 32 characters of random information, is only ${entropy.length}`); }
return privateToAccount(sha3(`${randomhex(16)}${sha3(`${randomhex(32)}${entropy}`)}${randomhex(32)}`));
} | [
"function",
"generate",
"(",
"entropy",
")",
"{",
"if",
"(",
"typeof",
"entropy",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"typeof",
"(",
"entropy",
")",
"}",
"`",
")",
";",
"}",
"if",
"(",
"entropy",
".",
"length",
"<",
"32",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"entropy",
".",
"length",
"}",
"`",
")",
";",
"}",
"return",
"privateToAccount",
"(",
"sha3",
"(",
"`",
"${",
"randomhex",
"(",
"16",
")",
"}",
"${",
"sha3",
"(",
"`",
"${",
"randomhex",
"(",
"32",
")",
"}",
"${",
"entropy",
"}",
"`",
")",
"}",
"${",
"randomhex",
"(",
"32",
")",
"}",
"`",
")",
")",
";",
"}"
] | Create a single Ethereum account address, private and public key.
@method generate
@param {String} entropy a single string of entropy longer than 32 chars
@returns {Object} output the Ethereum account address, and keys | [
"Create",
"a",
"single",
"Ethereum",
"account",
"address",
"private",
"and",
"public",
"key",
"."
] | 7cbdd667a8c21c8546436650d17bcc9735d7d6bb | https://github.com/ethjs/ethjs-account/blob/7cbdd667a8c21c8546436650d17bcc9735d7d6bb/src/index.js#L120-L125 | train |
doggan/diablo-file-formats | lib/dun.js | DunFile | function DunFile(startCoord, rawPillarData, dunName) {
this.startCol = startCoord[0];
this.startRow = startCoord[1];
this.fileName = dunName;
this.rawPillarData = rawPillarData;
this.rawColCount = this.rawPillarData.length;
this.rawRowCount = (this.rawColCount > 0) ? this.rawPillarData[0].length : 0;
this.pillarData = null; // Initialized during unpack operation.
this.colCount = this.rawColCount * 2;
this.rowCount = this.rawRowCount * 2;
} | javascript | function DunFile(startCoord, rawPillarData, dunName) {
this.startCol = startCoord[0];
this.startRow = startCoord[1];
this.fileName = dunName;
this.rawPillarData = rawPillarData;
this.rawColCount = this.rawPillarData.length;
this.rawRowCount = (this.rawColCount > 0) ? this.rawPillarData[0].length : 0;
this.pillarData = null; // Initialized during unpack operation.
this.colCount = this.rawColCount * 2;
this.rowCount = this.rawRowCount * 2;
} | [
"function",
"DunFile",
"(",
"startCoord",
",",
"rawPillarData",
",",
"dunName",
")",
"{",
"this",
".",
"startCol",
"=",
"startCoord",
"[",
"0",
"]",
";",
"this",
".",
"startRow",
"=",
"startCoord",
"[",
"1",
"]",
";",
"this",
".",
"fileName",
"=",
"dunName",
";",
"this",
".",
"rawPillarData",
"=",
"rawPillarData",
";",
"this",
".",
"rawColCount",
"=",
"this",
".",
"rawPillarData",
".",
"length",
";",
"this",
".",
"rawRowCount",
"=",
"(",
"this",
".",
"rawColCount",
">",
"0",
")",
"?",
"this",
".",
"rawPillarData",
"[",
"0",
"]",
".",
"length",
":",
"0",
";",
"this",
".",
"pillarData",
"=",
"null",
";",
"this",
".",
"colCount",
"=",
"this",
".",
"rawColCount",
"*",
"2",
";",
"this",
".",
"rowCount",
"=",
"this",
".",
"rawRowCount",
"*",
"2",
";",
"}"
] | DUN files contain information for arranging the squares of a TIL file.
Multiple DUN files can be pieced together to form entire levels.
For example, the 'town' level is a combination of 4 DUN files.
In addition, DUN files also provide information regarding dungeon
monsters and object ids. | [
"DUN",
"files",
"contain",
"information",
"for",
"arranging",
"the",
"squares",
"of",
"a",
"TIL",
"file",
".",
"Multiple",
"DUN",
"files",
"can",
"be",
"pieced",
"together",
"to",
"form",
"entire",
"levels",
".",
"For",
"example",
"the",
"town",
"level",
"is",
"a",
"combination",
"of",
"4",
"DUN",
"files",
"."
] | 1c468868361752b01a1164d6135939621e18dab5 | https://github.com/doggan/diablo-file-formats/blob/1c468868361752b01a1164d6135939621e18dab5/lib/dun.js#L15-L27 | train |
simoami/mimik | runner/reporters/html/base/js/vendor/magnific-popup/jquery.magnific-popup.js | function(isLarge) {
var el;
if(isLarge) {
el = mfp.currItem.img;
} else {
el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
}
var offset = el.offset();
var paddingTop = parseInt(el.css('padding-top'),10);
var paddingBottom = parseInt(el.css('padding-bottom'),10);
offset.top -= ( $(window).scrollTop() - paddingTop );
/*
Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
*/
var obj = {
width: el.width(),
// fix Zepto height+padding issue
height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
};
// I hate to do this, but there is no another option
if( getHasMozTransform() ) {
obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
} else {
obj.left = offset.left;
obj.top = offset.top;
}
return obj;
} | javascript | function(isLarge) {
var el;
if(isLarge) {
el = mfp.currItem.img;
} else {
el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem);
}
var offset = el.offset();
var paddingTop = parseInt(el.css('padding-top'),10);
var paddingBottom = parseInt(el.css('padding-bottom'),10);
offset.top -= ( $(window).scrollTop() - paddingTop );
/*
Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa.
*/
var obj = {
width: el.width(),
// fix Zepto height+padding issue
height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop
};
// I hate to do this, but there is no another option
if( getHasMozTransform() ) {
obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)';
} else {
obj.left = offset.left;
obj.top = offset.top;
}
return obj;
} | [
"function",
"(",
"isLarge",
")",
"{",
"var",
"el",
";",
"if",
"(",
"isLarge",
")",
"{",
"el",
"=",
"mfp",
".",
"currItem",
".",
"img",
";",
"}",
"else",
"{",
"el",
"=",
"mfp",
".",
"st",
".",
"zoom",
".",
"opener",
"(",
"mfp",
".",
"currItem",
".",
"el",
"||",
"mfp",
".",
"currItem",
")",
";",
"}",
"var",
"offset",
"=",
"el",
".",
"offset",
"(",
")",
";",
"var",
"paddingTop",
"=",
"parseInt",
"(",
"el",
".",
"css",
"(",
"'padding-top'",
")",
",",
"10",
")",
";",
"var",
"paddingBottom",
"=",
"parseInt",
"(",
"el",
".",
"css",
"(",
"'padding-bottom'",
")",
",",
"10",
")",
";",
"offset",
".",
"top",
"-=",
"(",
"$",
"(",
"window",
")",
".",
"scrollTop",
"(",
")",
"-",
"paddingTop",
")",
";",
"var",
"obj",
"=",
"{",
"width",
":",
"el",
".",
"width",
"(",
")",
",",
"height",
":",
"(",
"_isJQ",
"?",
"el",
".",
"innerHeight",
"(",
")",
":",
"el",
"[",
"0",
"]",
".",
"offsetHeight",
")",
"-",
"paddingBottom",
"-",
"paddingTop",
"}",
";",
"if",
"(",
"getHasMozTransform",
"(",
")",
")",
"{",
"obj",
"[",
"'-moz-transform'",
"]",
"=",
"obj",
"[",
"'transform'",
"]",
"=",
"'translate('",
"+",
"offset",
".",
"left",
"+",
"'px,'",
"+",
"offset",
".",
"top",
"+",
"'px)'",
";",
"}",
"else",
"{",
"obj",
".",
"left",
"=",
"offset",
".",
"left",
";",
"obj",
".",
"top",
"=",
"offset",
".",
"top",
";",
"}",
"return",
"obj",
";",
"}"
] | Get element postion relative to viewport | [
"Get",
"element",
"postion",
"relative",
"to",
"viewport"
] | 464a4679bba671d43aea6660485d8db9fa767b1b | https://github.com/simoami/mimik/blob/464a4679bba671d43aea6660485d8db9fa767b1b/runner/reporters/html/base/js/vendor/magnific-popup/jquery.magnific-popup.js#L1531-L1564 | train |
|
quorrajs/Ouch | handler/JsonResponseHandler.js | JsonResponseHandler | function JsonResponseHandler(onlyForAjaxOrJsonRequests, returnFrames, sendResponse) {
JsonResponseHandler.super_.call(this);
/**
* Should Ouch push output directly to the client?
* If this is false, output will be passed to the callback
* provided to the handle method.
*
* @type {boolean}
* @protected
*/
this.__sendResponse = sendResponse === undefined ? true : Boolean(sendResponse);
/**
* @var {boolean}
* @protected
*/
this.__returnFrames = returnFrames ? Boolean(returnFrames) : false;
/**
* If this is true handler will process this error if and only
* if request is ajax or request accepts json.
*
* @var {boolean}
* @protected
*/
this.__onlyForAjaxOrJsonRequests = onlyForAjaxOrJsonRequests ? Boolean(onlyForAjaxOrJsonRequests) : false;
} | javascript | function JsonResponseHandler(onlyForAjaxOrJsonRequests, returnFrames, sendResponse) {
JsonResponseHandler.super_.call(this);
/**
* Should Ouch push output directly to the client?
* If this is false, output will be passed to the callback
* provided to the handle method.
*
* @type {boolean}
* @protected
*/
this.__sendResponse = sendResponse === undefined ? true : Boolean(sendResponse);
/**
* @var {boolean}
* @protected
*/
this.__returnFrames = returnFrames ? Boolean(returnFrames) : false;
/**
* If this is true handler will process this error if and only
* if request is ajax or request accepts json.
*
* @var {boolean}
* @protected
*/
this.__onlyForAjaxOrJsonRequests = onlyForAjaxOrJsonRequests ? Boolean(onlyForAjaxOrJsonRequests) : false;
} | [
"function",
"JsonResponseHandler",
"(",
"onlyForAjaxOrJsonRequests",
",",
"returnFrames",
",",
"sendResponse",
")",
"{",
"JsonResponseHandler",
".",
"super_",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"__sendResponse",
"=",
"sendResponse",
"===",
"undefined",
"?",
"true",
":",
"Boolean",
"(",
"sendResponse",
")",
";",
"this",
".",
"__returnFrames",
"=",
"returnFrames",
"?",
"Boolean",
"(",
"returnFrames",
")",
":",
"false",
";",
"this",
".",
"__onlyForAjaxOrJsonRequests",
"=",
"onlyForAjaxOrJsonRequests",
"?",
"Boolean",
"(",
"onlyForAjaxOrJsonRequests",
")",
":",
"false",
";",
"}"
] | Catches an exception and converts it to a JSON
response. Additionally can also return exception
frames for consumption by an API. | [
"Catches",
"an",
"exception",
"and",
"converts",
"it",
"to",
"a",
"JSON",
"response",
".",
"Additionally",
"can",
"also",
"return",
"exception",
"frames",
"for",
"consumption",
"by",
"an",
"API",
"."
] | cbadf54eaa78633761e295c8566a36bb1567d130 | https://github.com/quorrajs/Ouch/blob/cbadf54eaa78633761e295c8566a36bb1567d130/handler/JsonResponseHandler.js#L20-L47 | train |
quorrajs/Ouch | handler/Handler.js | Handler | function Handler() {
if (this.constructor === Handler) {
throw new Error("Can't instantiate abstract class!");
}
/**
* @var {Object}
* @protected
*/
this.__inspector;
/**
* @var {Object}
* @protected
*/
this.__run;
/**
* @var {Object}
* @protected
*/
this.__request = null;
/**
* @var {Object}
* @protected
*/
this.__response = null;
} | javascript | function Handler() {
if (this.constructor === Handler) {
throw new Error("Can't instantiate abstract class!");
}
/**
* @var {Object}
* @protected
*/
this.__inspector;
/**
* @var {Object}
* @protected
*/
this.__run;
/**
* @var {Object}
* @protected
*/
this.__request = null;
/**
* @var {Object}
* @protected
*/
this.__response = null;
} | [
"function",
"Handler",
"(",
")",
"{",
"if",
"(",
"this",
".",
"constructor",
"===",
"Handler",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Can't instantiate abstract class!\"",
")",
";",
"}",
"this",
".",
"__inspector",
";",
"this",
".",
"__run",
";",
"this",
".",
"__request",
"=",
"null",
";",
"this",
".",
"__response",
"=",
"null",
";",
"}"
] | Abstract implementation of a error handler.
@class
@abstract
@author: Harish Anchu <[email protected]>
@copyright 2015, Harish Anchu. All rights reserved.
@license Licensed under MIT (https://github.com/quorrajs/Ouch/blob/master/LICENSE) | [
"Abstract",
"implementation",
"of",
"a",
"error",
"handler",
"."
] | cbadf54eaa78633761e295c8566a36bb1567d130 | https://github.com/quorrajs/Ouch/blob/cbadf54eaa78633761e295c8566a36bb1567d130/handler/Handler.js#L11-L39 | train |
Planeshifter/node-wordnet-magic | lib/morphy.js | morphyPromise | function morphyPromise( str, pos ) {
/* jshint: -WO40 */
var substitutions;
var query;
var i;
if ( !pos ) {
var resArray = [];
for ( i = 0; i < POS_TAGS.length; i++ ){
resArray.push( morphyPromise( str, POS_TAGS[i] ) );
}
return Promise.all( resArray ).then( function onDone( data ) {
var reducedArray = [];
var j;
for ( j = 0; j < data.length; j++ ) {
reducedArray.push( data[ j ] );
}
return _.flatten( reducedArray );
});
}
substitutions = getSubstitutions( pos );
if ( !this.DICTIONARY ) {
query = 'SELECT DISTINCT ws.lemma AS lemma, syn.pos AS pos FROM words AS ws LEFT JOIN senses AS sen ON ws.wordid = sen.wordid LEFT JOIN ';
query += 'synsets AS syn ON sen.synsetid = syn.synsetid';
this.DICTIONARY = this.db.allAsync( query ).map( function mapper( elem ) {
var obj = {
lemma: elem.lemma,
pos: elem.pos
};
return obj;
});
}
if ( !this.EXCEPTIONS ) {
query = 'SELECT lemma, morph, pos FROM morphology';
this.EXCEPTIONS = db.allAsync( query );
}
var wordsPromise = Promise.join( this.DICTIONARY, this.EXCEPTIONS, function( dictionary, exceptions ) {
var foundExceptions = [];
var exceptionMorphs = exceptions.map( function( elem ) {
return elem.morph;
});
var baseWord;
var suffix;
var index = exceptionMorphs.indexOf( str );
while ( index !== -1 ) {
if ( exceptions[index].pos === pos ) {
baseWord = new this.Word( exceptions[index].lemma );
baseWord.part_of_speech = pos;
foundExceptions.push( baseWord );
}
index = exceptionMorphs.indexOf( str, index + 1 );
}
if ( foundExceptions.length > 0 ) {
return foundExceptions;
} else {
if ( pos === 'n' && str.endsWith( 'ful' ) ) {
suffix = 'ful';
str = str.slice( 0, str.length - suffix.length );
} else {
suffix = '';
}
return rulesOfDetachment( str, substitutions );
}
});
return wordsPromise;
} | javascript | function morphyPromise( str, pos ) {
/* jshint: -WO40 */
var substitutions;
var query;
var i;
if ( !pos ) {
var resArray = [];
for ( i = 0; i < POS_TAGS.length; i++ ){
resArray.push( morphyPromise( str, POS_TAGS[i] ) );
}
return Promise.all( resArray ).then( function onDone( data ) {
var reducedArray = [];
var j;
for ( j = 0; j < data.length; j++ ) {
reducedArray.push( data[ j ] );
}
return _.flatten( reducedArray );
});
}
substitutions = getSubstitutions( pos );
if ( !this.DICTIONARY ) {
query = 'SELECT DISTINCT ws.lemma AS lemma, syn.pos AS pos FROM words AS ws LEFT JOIN senses AS sen ON ws.wordid = sen.wordid LEFT JOIN ';
query += 'synsets AS syn ON sen.synsetid = syn.synsetid';
this.DICTIONARY = this.db.allAsync( query ).map( function mapper( elem ) {
var obj = {
lemma: elem.lemma,
pos: elem.pos
};
return obj;
});
}
if ( !this.EXCEPTIONS ) {
query = 'SELECT lemma, morph, pos FROM morphology';
this.EXCEPTIONS = db.allAsync( query );
}
var wordsPromise = Promise.join( this.DICTIONARY, this.EXCEPTIONS, function( dictionary, exceptions ) {
var foundExceptions = [];
var exceptionMorphs = exceptions.map( function( elem ) {
return elem.morph;
});
var baseWord;
var suffix;
var index = exceptionMorphs.indexOf( str );
while ( index !== -1 ) {
if ( exceptions[index].pos === pos ) {
baseWord = new this.Word( exceptions[index].lemma );
baseWord.part_of_speech = pos;
foundExceptions.push( baseWord );
}
index = exceptionMorphs.indexOf( str, index + 1 );
}
if ( foundExceptions.length > 0 ) {
return foundExceptions;
} else {
if ( pos === 'n' && str.endsWith( 'ful' ) ) {
suffix = 'ful';
str = str.slice( 0, str.length - suffix.length );
} else {
suffix = '';
}
return rulesOfDetachment( str, substitutions );
}
});
return wordsPromise;
} | [
"function",
"morphyPromise",
"(",
"str",
",",
"pos",
")",
"{",
"var",
"substitutions",
";",
"var",
"query",
";",
"var",
"i",
";",
"if",
"(",
"!",
"pos",
")",
"{",
"var",
"resArray",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"POS_TAGS",
".",
"length",
";",
"i",
"++",
")",
"{",
"resArray",
".",
"push",
"(",
"morphyPromise",
"(",
"str",
",",
"POS_TAGS",
"[",
"i",
"]",
")",
")",
";",
"}",
"return",
"Promise",
".",
"all",
"(",
"resArray",
")",
".",
"then",
"(",
"function",
"onDone",
"(",
"data",
")",
"{",
"var",
"reducedArray",
"=",
"[",
"]",
";",
"var",
"j",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"data",
".",
"length",
";",
"j",
"++",
")",
"{",
"reducedArray",
".",
"push",
"(",
"data",
"[",
"j",
"]",
")",
";",
"}",
"return",
"_",
".",
"flatten",
"(",
"reducedArray",
")",
";",
"}",
")",
";",
"}",
"substitutions",
"=",
"getSubstitutions",
"(",
"pos",
")",
";",
"if",
"(",
"!",
"this",
".",
"DICTIONARY",
")",
"{",
"query",
"=",
"'SELECT DISTINCT ws.lemma AS lemma, syn.pos AS pos FROM words AS ws LEFT JOIN senses AS sen ON ws.wordid = sen.wordid LEFT JOIN '",
";",
"query",
"+=",
"'synsets AS syn ON sen.synsetid = syn.synsetid'",
";",
"this",
".",
"DICTIONARY",
"=",
"this",
".",
"db",
".",
"allAsync",
"(",
"query",
")",
".",
"map",
"(",
"function",
"mapper",
"(",
"elem",
")",
"{",
"var",
"obj",
"=",
"{",
"lemma",
":",
"elem",
".",
"lemma",
",",
"pos",
":",
"elem",
".",
"pos",
"}",
";",
"return",
"obj",
";",
"}",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"EXCEPTIONS",
")",
"{",
"query",
"=",
"'SELECT lemma, morph, pos FROM morphology'",
";",
"this",
".",
"EXCEPTIONS",
"=",
"db",
".",
"allAsync",
"(",
"query",
")",
";",
"}",
"var",
"wordsPromise",
"=",
"Promise",
".",
"join",
"(",
"this",
".",
"DICTIONARY",
",",
"this",
".",
"EXCEPTIONS",
",",
"function",
"(",
"dictionary",
",",
"exceptions",
")",
"{",
"var",
"foundExceptions",
"=",
"[",
"]",
";",
"var",
"exceptionMorphs",
"=",
"exceptions",
".",
"map",
"(",
"function",
"(",
"elem",
")",
"{",
"return",
"elem",
".",
"morph",
";",
"}",
")",
";",
"var",
"baseWord",
";",
"var",
"suffix",
";",
"var",
"index",
"=",
"exceptionMorphs",
".",
"indexOf",
"(",
"str",
")",
";",
"while",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"if",
"(",
"exceptions",
"[",
"index",
"]",
".",
"pos",
"===",
"pos",
")",
"{",
"baseWord",
"=",
"new",
"this",
".",
"Word",
"(",
"exceptions",
"[",
"index",
"]",
".",
"lemma",
")",
";",
"baseWord",
".",
"part_of_speech",
"=",
"pos",
";",
"foundExceptions",
".",
"push",
"(",
"baseWord",
")",
";",
"}",
"index",
"=",
"exceptionMorphs",
".",
"indexOf",
"(",
"str",
",",
"index",
"+",
"1",
")",
";",
"}",
"if",
"(",
"foundExceptions",
".",
"length",
">",
"0",
")",
"{",
"return",
"foundExceptions",
";",
"}",
"else",
"{",
"if",
"(",
"pos",
"===",
"'n'",
"&&",
"str",
".",
"endsWith",
"(",
"'ful'",
")",
")",
"{",
"suffix",
"=",
"'ful'",
";",
"str",
"=",
"str",
".",
"slice",
"(",
"0",
",",
"str",
".",
"length",
"-",
"suffix",
".",
"length",
")",
";",
"}",
"else",
"{",
"suffix",
"=",
"''",
";",
"}",
"return",
"rulesOfDetachment",
"(",
"str",
",",
"substitutions",
")",
";",
"}",
"}",
")",
";",
"return",
"wordsPromise",
";",
"}"
] | Extract base form of supplied word using Morphy algorithm.
@param {string} str - input string
@param {string} pos - part of speech
@returns {Promise} results promise | [
"Extract",
"base",
"form",
"of",
"supplied",
"word",
"using",
"Morphy",
"algorithm",
"."
] | a7c6000bd63c79562ebb1e9a85820809a9a17058 | https://github.com/Planeshifter/node-wordnet-magic/blob/a7c6000bd63c79562ebb1e9a85820809a9a17058/lib/morphy.js#L23-L94 | train |
Streampunk/kelvinadon | util/meta.js | function (type, name) {
if (metaDictByName[type][name]) {
return metaDictByName[type][name];
} else if (name.endsWith('Type')) {
return metaDictByName[type][name.slice(0, -4)];
}
return undefined;
} | javascript | function (type, name) {
if (metaDictByName[type][name]) {
return metaDictByName[type][name];
} else if (name.endsWith('Type')) {
return metaDictByName[type][name.slice(0, -4)];
}
return undefined;
} | [
"function",
"(",
"type",
",",
"name",
")",
"{",
"if",
"(",
"metaDictByName",
"[",
"type",
"]",
"[",
"name",
"]",
")",
"{",
"return",
"metaDictByName",
"[",
"type",
"]",
"[",
"name",
"]",
";",
"}",
"else",
"if",
"(",
"name",
".",
"endsWith",
"(",
"'Type'",
")",
")",
"{",
"return",
"metaDictByName",
"[",
"type",
"]",
"[",
"name",
".",
"slice",
"(",
"0",
",",
"-",
"4",
")",
"]",
";",
"}",
"return",
"undefined",
";",
"}"
] | For use when already inside a promise | [
"For",
"use",
"when",
"already",
"inside",
"a",
"promise"
] | 75dc0a22428fd57073806e7de0bf1364883958e4 | https://github.com/Streampunk/kelvinadon/blob/75dc0a22428fd57073806e7de0bf1364883958e4/util/meta.js#L649-L656 | train |
|
richardeoin/nodejs-fft-windowing | windowing.js | window | function window(data_array, windowing_function, alpha) {
var datapoints = data_array.length;
/* For each item in the array */
for (var n=0; n<datapoints; ++n) {
/* Apply the windowing function */
data_array[n] *= windowing_function(n, datapoints, alpha);
}
return data_array;
} | javascript | function window(data_array, windowing_function, alpha) {
var datapoints = data_array.length;
/* For each item in the array */
for (var n=0; n<datapoints; ++n) {
/* Apply the windowing function */
data_array[n] *= windowing_function(n, datapoints, alpha);
}
return data_array;
} | [
"function",
"window",
"(",
"data_array",
",",
"windowing_function",
",",
"alpha",
")",
"{",
"var",
"datapoints",
"=",
"data_array",
".",
"length",
";",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"datapoints",
";",
"++",
"n",
")",
"{",
"data_array",
"[",
"n",
"]",
"*=",
"windowing_function",
"(",
"n",
",",
"datapoints",
",",
"alpha",
")",
";",
"}",
"return",
"data_array",
";",
"}"
] | Applies a Windowing Function to an array. | [
"Applies",
"a",
"Windowing",
"Function",
"to",
"an",
"array",
"."
] | 9762d07570046b7f2d255791cee5772ce1865a22 | https://github.com/richardeoin/nodejs-fft-windowing/blob/9762d07570046b7f2d255791cee5772ce1865a22/windowing.js#L81-L91 | train |
marchah/node-countries | index.js | getCountryByName | function getCountryByName(name, useAlias) {
if (!_.isString(name)) return undefined;
return _.find(countries, (country) => {
if (useAlias) {
return country.name.toUpperCase() === name.toUpperCase()
|| _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return country.name.toUpperCase() === name.toUpperCase();
});
} | javascript | function getCountryByName(name, useAlias) {
if (!_.isString(name)) return undefined;
return _.find(countries, (country) => {
if (useAlias) {
return country.name.toUpperCase() === name.toUpperCase()
|| _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return country.name.toUpperCase() === name.toUpperCase();
});
} | [
"function",
"getCountryByName",
"(",
"name",
",",
"useAlias",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"name",
")",
")",
"return",
"undefined",
";",
"return",
"_",
".",
"find",
"(",
"countries",
",",
"(",
"country",
")",
"=>",
"{",
"if",
"(",
"useAlias",
")",
"{",
"return",
"country",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"_",
".",
"find",
"(",
"country",
".",
"alias",
",",
"(",
"alias",
")",
"=>",
"(",
"alias",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
")",
")",
";",
"}",
"return",
"country",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
";",
"}",
")",
";",
"}"
] | Find the country object of the given country name
@param {String} name country name
@param {Boolean} [useAlias] use alias flag, default `false`
@return {Object} country country object | [
"Find",
"the",
"country",
"object",
"of",
"the",
"given",
"country",
"name"
] | 4ec36f37adbf8293c9a9d4872136750b78291e8d | https://github.com/marchah/node-countries/blob/4ec36f37adbf8293c9a9d4872136750b78291e8d/index.js#L19-L29 | train |
marchah/node-countries | index.js | getCountryByNameOrShortName | function getCountryByNameOrShortName(name, useAlias) {
if (!_.isString(name)) return undefined;
return _.find(countries, (country) => {
if (useAlias) {
return country.name.toUpperCase() === name.toUpperCase()
|| country.alpha2.toUpperCase() === name.toUpperCase()
|| _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return country.name.toUpperCase() === name.toUpperCase() || country.alpha2.toUpperCase() === name.toUpperCase();
});
} | javascript | function getCountryByNameOrShortName(name, useAlias) {
if (!_.isString(name)) return undefined;
return _.find(countries, (country) => {
if (useAlias) {
return country.name.toUpperCase() === name.toUpperCase()
|| country.alpha2.toUpperCase() === name.toUpperCase()
|| _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return country.name.toUpperCase() === name.toUpperCase() || country.alpha2.toUpperCase() === name.toUpperCase();
});
} | [
"function",
"getCountryByNameOrShortName",
"(",
"name",
",",
"useAlias",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"name",
")",
")",
"return",
"undefined",
";",
"return",
"_",
".",
"find",
"(",
"countries",
",",
"(",
"country",
")",
"=>",
"{",
"if",
"(",
"useAlias",
")",
"{",
"return",
"country",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"country",
".",
"alpha2",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"_",
".",
"find",
"(",
"country",
".",
"alias",
",",
"(",
"alias",
")",
"=>",
"(",
"alias",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
")",
")",
";",
"}",
"return",
"country",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"country",
".",
"alpha2",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
";",
"}",
")",
";",
"}"
] | Find the country object of the given country name or short name
@param {String} name country name or short name (alpha2)
@param {Boolean} [useAlias] use alias flag, default `false`
@return {Object} country country object | [
"Find",
"the",
"country",
"object",
"of",
"the",
"given",
"country",
"name",
"or",
"short",
"name"
] | 4ec36f37adbf8293c9a9d4872136750b78291e8d | https://github.com/marchah/node-countries/blob/4ec36f37adbf8293c9a9d4872136750b78291e8d/index.js#L38-L49 | train |
marchah/node-countries | index.js | getProvinceByName | function getProvinceByName(name, useAlias) {
if (!_.isString(name) || !_.isArray(this.provinces)) return undefined;
return _.find(this.provinces, (province) => {
if (useAlias) {
return province.name.toUpperCase() === name.toUpperCase()
|| _.find(province.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return province.name.toUpperCase() === name.toUpperCase();
});
} | javascript | function getProvinceByName(name, useAlias) {
if (!_.isString(name) || !_.isArray(this.provinces)) return undefined;
return _.find(this.provinces, (province) => {
if (useAlias) {
return province.name.toUpperCase() === name.toUpperCase()
|| _.find(province.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return province.name.toUpperCase() === name.toUpperCase();
});
} | [
"function",
"getProvinceByName",
"(",
"name",
",",
"useAlias",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"name",
")",
"||",
"!",
"_",
".",
"isArray",
"(",
"this",
".",
"provinces",
")",
")",
"return",
"undefined",
";",
"return",
"_",
".",
"find",
"(",
"this",
".",
"provinces",
",",
"(",
"province",
")",
"=>",
"{",
"if",
"(",
"useAlias",
")",
"{",
"return",
"province",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"_",
".",
"find",
"(",
"province",
".",
"alias",
",",
"(",
"alias",
")",
"=>",
"(",
"alias",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
")",
")",
";",
"}",
"return",
"province",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
";",
"}",
")",
";",
"}"
] | Find the province object of the given province name
@param {String} name english province name
@param {Boolean} [useAlias] use alias flag, default `false`
@return {Object} province province object | [
"Find",
"the",
"province",
"object",
"of",
"the",
"given",
"province",
"name"
] | 4ec36f37adbf8293c9a9d4872136750b78291e8d | https://github.com/marchah/node-countries/blob/4ec36f37adbf8293c9a9d4872136750b78291e8d/index.js#L64-L74 | train |
marchah/node-countries | index.js | getProvinceByNameOrShortName | function getProvinceByNameOrShortName(name, useAlias) {
if (!_.isString(name) || !_.isArray(this.provinces)) return undefined;
return _.find(this.provinces, (province) => {
if (useAlias) {
return province.name.toUpperCase() === name.toUpperCase()
|| (province.short && province.short.toUpperCase() === name.toUpperCase())
|| _.find(province.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return province.name.toUpperCase() === name.toUpperCase() || (province.short && province.short.toUpperCase() === name.toUpperCase());
});
} | javascript | function getProvinceByNameOrShortName(name, useAlias) {
if (!_.isString(name) || !_.isArray(this.provinces)) return undefined;
return _.find(this.provinces, (province) => {
if (useAlias) {
return province.name.toUpperCase() === name.toUpperCase()
|| (province.short && province.short.toUpperCase() === name.toUpperCase())
|| _.find(province.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
}
return province.name.toUpperCase() === name.toUpperCase() || (province.short && province.short.toUpperCase() === name.toUpperCase());
});
} | [
"function",
"getProvinceByNameOrShortName",
"(",
"name",
",",
"useAlias",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"name",
")",
"||",
"!",
"_",
".",
"isArray",
"(",
"this",
".",
"provinces",
")",
")",
"return",
"undefined",
";",
"return",
"_",
".",
"find",
"(",
"this",
".",
"provinces",
",",
"(",
"province",
")",
"=>",
"{",
"if",
"(",
"useAlias",
")",
"{",
"return",
"province",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"(",
"province",
".",
"short",
"&&",
"province",
".",
"short",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
")",
"||",
"_",
".",
"find",
"(",
"province",
".",
"alias",
",",
"(",
"alias",
")",
"=>",
"(",
"alias",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
")",
")",
";",
"}",
"return",
"province",
".",
"name",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
"||",
"(",
"province",
".",
"short",
"&&",
"province",
".",
"short",
".",
"toUpperCase",
"(",
")",
"===",
"name",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] | Find the province object of the given province name or short name
@param {String} name english province name or short name
@param {Boolean} [useAlias] use alias flag, default `false`
@return {Object} province province object | [
"Find",
"the",
"province",
"object",
"of",
"the",
"given",
"province",
"name",
"or",
"short",
"name"
] | 4ec36f37adbf8293c9a9d4872136750b78291e8d | https://github.com/marchah/node-countries/blob/4ec36f37adbf8293c9a9d4872136750b78291e8d/index.js#L83-L94 | train |
doggan/diablo-file-formats | lib/sol.js | SolFile | function SolFile(data, path) {
this.data = data;
this.path = path;
// levels/towndata/town.sol -> town
this.name = pathLib.basename(path, '.sol');
} | javascript | function SolFile(data, path) {
this.data = data;
this.path = path;
// levels/towndata/town.sol -> town
this.name = pathLib.basename(path, '.sol');
} | [
"function",
"SolFile",
"(",
"data",
",",
"path",
")",
"{",
"this",
".",
"data",
"=",
"data",
";",
"this",
".",
"path",
"=",
"path",
";",
"this",
".",
"name",
"=",
"pathLib",
".",
"basename",
"(",
"path",
",",
"'.sol'",
")",
";",
"}"
] | SOL files contain meta information about pillars, such as
collision and transparency properties.
The usage of some of the bits are currently unknown. | [
"SOL",
"files",
"contain",
"meta",
"information",
"about",
"pillars",
"such",
"as",
"collision",
"and",
"transparency",
"properties",
"."
] | 1c468868361752b01a1164d6135939621e18dab5 | https://github.com/doggan/diablo-file-formats/blob/1c468868361752b01a1164d6135939621e18dab5/lib/sol.js#L11-L17 | train |
neyric/aws-swf | lib/workflow-execution.js | function (config, cb) {
var o = {}, k;
for (k in this.baseConfig) {
if (this.baseConfig.hasOwnProperty(k)) {
o[k] = this.baseConfig[k];
}
}
for (k in config) {
if (config.hasOwnProperty(k)) {
o[k] = config[k];
}
}
if (!o.workflowId) {
o.workflowId = String(Math.random()).substr(2);
}
this.workflowId = o.workflowId;
this.swfClient.startWorkflowExecution(o, function (err, result) {
cb(err, result ? result.runId : null);
});
} | javascript | function (config, cb) {
var o = {}, k;
for (k in this.baseConfig) {
if (this.baseConfig.hasOwnProperty(k)) {
o[k] = this.baseConfig[k];
}
}
for (k in config) {
if (config.hasOwnProperty(k)) {
o[k] = config[k];
}
}
if (!o.workflowId) {
o.workflowId = String(Math.random()).substr(2);
}
this.workflowId = o.workflowId;
this.swfClient.startWorkflowExecution(o, function (err, result) {
cb(err, result ? result.runId : null);
});
} | [
"function",
"(",
"config",
",",
"cb",
")",
"{",
"var",
"o",
"=",
"{",
"}",
",",
"k",
";",
"for",
"(",
"k",
"in",
"this",
".",
"baseConfig",
")",
"{",
"if",
"(",
"this",
".",
"baseConfig",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"o",
"[",
"k",
"]",
"=",
"this",
".",
"baseConfig",
"[",
"k",
"]",
";",
"}",
"}",
"for",
"(",
"k",
"in",
"config",
")",
"{",
"if",
"(",
"config",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"o",
"[",
"k",
"]",
"=",
"config",
"[",
"k",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"o",
".",
"workflowId",
")",
"{",
"o",
".",
"workflowId",
"=",
"String",
"(",
"Math",
".",
"random",
"(",
")",
")",
".",
"substr",
"(",
"2",
")",
";",
"}",
"this",
".",
"workflowId",
"=",
"o",
".",
"workflowId",
";",
"this",
".",
"swfClient",
".",
"startWorkflowExecution",
"(",
"o",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"cb",
"(",
"err",
",",
"result",
"?",
"result",
".",
"runId",
":",
"null",
")",
";",
"}",
")",
";",
"}"
] | Start a worfklow
@param {Object} config
@param {Function} cb | [
"Start",
"a",
"worfklow"
] | 31b96c9eef313199465b40204a92909996a85c3d | https://github.com/neyric/aws-swf/blob/31b96c9eef313199465b40204a92909996a85c3d/lib/workflow-execution.js#L20-L45 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.