_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q6100
train
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
{ "resource": "" }
q6101
train
function(name, count, out){ if(out[name]){ out[name] = out[name] + count; }else{ out[name] = count; } }
javascript
{ "resource": "" }
q6102
train
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
{ "resource": "" }
q6103
train
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
{ "resource": "" }
q6104
train
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
{ "resource": "" }
q6105
train
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
{ "resource": "" }
q6106
train
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
{ "resource": "" }
q6107
train
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
{ "resource": "" }
q6108
train
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
{ "resource": "" }
q6109
train
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
{ "resource": "" }
q6110
train
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
{ "resource": "" }
q6111
train
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
{ "resource": "" }
q6112
train
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
{ "resource": "" }
q6113
train
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
{ "resource": "" }
q6114
train
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
{ "resource": "" }
q6115
train
function(name) { var key; for(key in modules.maps) { if(modules.maps[key].root === name || key === name) { return modules.maps[key]; } } return null; }
javascript
{ "resource": "" }
q6116
train
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
{ "resource": "" }
q6117
train
function( microformat ) { delete microformat.times; delete microformat.dates; delete microformat.typeVersion; delete microformat.altValue; return microformat; }
javascript
{ "resource": "" }
q6118
train
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
{ "resource": "" }
q6119
train
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
{ "resource": "" }
q6120
train
function(options) { var key; for(key in options) { if(options.hasOwnProperty(key)) { this.options[key] = options[key]; } } }
javascript
{ "resource": "" }
q6121
train
function(rootNode){ var arr, i; arr = modules.domUtils.getNodesByAttribute(rootNode, 'rootids'); i = arr.length; while(i--) { modules.domUtils.removeAttribute(arr[i],'rootids'); } }
javascript
{ "resource": "" }
q6122
train
function( text ) { if(text && this.isString(text)){ return (text.trim())? text.trim() : text.replace(/^\s+|\s+$/g, ''); }else{ return ''; } }
javascript
{ "resource": "" }
q6123
train
function( text, index, character ) { if(text && text.length > index){ return text.substr(0, index) + character + text.substr(index+character.length); }else{ return text; } }
javascript
{ "resource": "" }
q6124
train
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
{ "resource": "" }
q6125
train
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
{ "resource": "" }
q6126
train
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
{ "resource": "" }
q6127
train
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
{ "resource": "" }
q6128
train
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
{ "resource": "" }
q6129
train
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
{ "resource": "" }
q6130
train
function(node, tagNames){ var i = tagNames.length; while(i--) { if(node.tagName.toLowerCase() === tagNames[i]) { return true; } } return false; }
javascript
{ "resource": "" }
q6131
train
function(node) { var newNode = node.cloneNode(true); if(this.hasAttribute(node, 'id')){ this.removeAttribute(node, 'id') } return newNode; }
javascript
{ "resource": "" }
q6132
train
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
{ "resource": "" }
q6133
train
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
{ "resource": "" }
q6134
train
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
{ "resource": "" }
q6135
train
function (node) { var parent = node.parentNode, i = -1, child; while (parent && (child = parent.childNodes[++i])){ if (child === node){ return i; } } return -1; }
javascript
{ "resource": "" }
q6136
train
function (document, path) { var node = document.documentElement, i = 0, index; while ((index = path[++i]) > -1){ node = node.childNodes[index]; } return node; }
javascript
{ "resource": "" }
q6137
train
function( tagName, text ){ var node = this.document.createElement(tagName); node.innerHTML = text; return node; }
javascript
{ "resource": "" }
q6138
train
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
{ "resource": "" }
q6139
train
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
{ "resource": "" }
q6140
train
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
{ "resource": "" }
q6141
train
function( text ) { if(modules.utils.isString( text )){ text = text.toLowerCase(); if(modules.utils.startWith(text, 'p') ){ return true; } } return false; }
javascript
{ "resource": "" }
q6142
train
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
{ "resource": "" }
q6143
train
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
{ "resource": "" }
q6144
train
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
{ "resource": "" }
q6145
train
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
{ "resource": "" }
q6146
train
function( doc, text, textFormat ){ var node = modules.domUtils.createNodeWithText( 'div', text ); return this.parse( doc, node, textFormat ); }
javascript
{ "resource": "" }
q6147
train
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
{ "resource": "" }
q6148
train
function( doc, text ){ text = text.replace( /&nbsp;/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
{ "resource": "" }
q6149
train
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
{ "resource": "" }
q6150
train
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
{ "resource": "" }
q6151
train
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
{ "resource": "" }
q6152
validateQuery
train
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
{ "resource": "" }
q6153
CouchbaseStore
train
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
{ "resource": "" }
q6154
getRouteNamespaces
train
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
{ "resource": "" }
q6155
BidProvider
train
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
{ "resource": "" }
q6156
mouseWheel
train
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
{ "resource": "" }
q6157
AuctionMediator
train
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
{ "resource": "" }
q6158
getTabData
train
function getTabData(url){ var key, data; key = urlToKey(url); obj = tabData[key]; return (obj)? obj : {data: {}, url: url}; }
javascript
{ "resource": "" }
q6159
appendTabData
train
function appendTabData(json){ var key; if(!getTabData(json.url).data.items){ key = urlToKey(json.url); tabData[key] = json; } }
javascript
{ "resource": "" }
q6160
buildEmail
train
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
{ "resource": "" }
q6161
prepareFrozenObject
train
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
{ "resource": "" }
q6162
isSchema
train
function isSchema(blob) { // A schema will have one of these return blob.properties !== undefined || blob.enum !== undefined || blob.items !== undefined || blob.type !== undefined; }
javascript
{ "resource": "" }
q6163
ensureTag
train
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
{ "resource": "" }
q6164
traverse
train
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
{ "resource": "" }
q6165
train
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
{ "resource": "" }
q6166
Slot
train
function Slot(name, elementId) { if (this.init_) { this.init_(); } this.name = name; this.elementId = elementId; this.bidProviders = []; this.sizes = []; }
javascript
{ "resource": "" }
q6167
encode
train
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
{ "resource": "" }
q6168
buildSimpleExample
train
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
{ "resource": "" }
q6169
getTypeName
train
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
{ "resource": "" }
q6170
read
train
function read() { const size = memory.readUInt32BE(offset); offset += 4; const codepoints = memory.slice(offset, offset + size); offset += size; return bitfield({ buffer: codepoints }); }
javascript
{ "resource": "" }
q6171
processRetrievedContent
train
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
{ "resource": "" }
q6172
processRetrievedDocument
train
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
{ "resource": "" }
q6173
generateCollectionFiles
train
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
{ "resource": "" }
q6174
_final
train
function _final() { var self = this; cluster.removeListener('fork', self._onFork); cluster.removeListener('disconnect', self._onDisconnect); }
javascript
{ "resource": "" }
q6175
Listings
train
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
{ "resource": "" }
q6176
train
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
{ "resource": "" }
q6177
train
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
{ "resource": "" }
q6178
train
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
{ "resource": "" }
q6179
getNames
train
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
{ "resource": "" }
q6180
createAlias
train
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
{ "resource": "" }
q6181
patchRoute
train
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
{ "resource": "" }
q6182
getAddress
train
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
{ "resource": "" }
q6183
privateToPublic
train
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
{ "resource": "" }
q6184
publicToAddress
train
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
{ "resource": "" }
q6185
privateToAccount
train
function privateToAccount(privateKey) { const publicKey = privateToPublic(privateKey, true); return { privateKey: `0x${stripHexPrefix(privateKey)}`, publicKey: `0x${publicKey.toString('hex')}`, address: publicToAddress(publicKey), }; }
javascript
{ "resource": "" }
q6186
generate
train
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
{ "resource": "" }
q6187
DunFile
train
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
{ "resource": "" }
q6188
train
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
{ "resource": "" }
q6189
JsonResponseHandler
train
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
{ "resource": "" }
q6190
Handler
train
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
{ "resource": "" }
q6191
morphyPromise
train
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
{ "resource": "" }
q6192
train
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
{ "resource": "" }
q6193
window
train
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
{ "resource": "" }
q6194
getCountryByName
train
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
{ "resource": "" }
q6195
getCountryByNameOrShortName
train
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
{ "resource": "" }
q6196
getProvinceByName
train
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
{ "resource": "" }
q6197
getProvinceByNameOrShortName
train
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
{ "resource": "" }
q6198
SolFile
train
function SolFile(data, path) { this.data = data; this.path = path; // levels/towndata/town.sol -> town this.name = pathLib.basename(path, '.sol'); }
javascript
{ "resource": "" }
q6199
train
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
{ "resource": "" }