_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... | 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 element... | 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(it... | 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.... | 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,... | 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.g... | 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 === tru... | 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.domUti... | 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.getAttrValFrom... | 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.setAttri... | 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... | 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'));
... | 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];... | 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 && ... | 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 s... | 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;
... | 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'));
... | 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.parseF... | 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
... | 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.tzZ... | 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;
... | 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];
... | 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 ... | 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( / /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.r... | 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... | 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;
}
}
}
... | 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(... | 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... | 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")) {
co... | 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]);
}... | 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.hasOwnPropert... | 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.s... | 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 = [ ... parsedE... | 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;
}
retur... | 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 s... | 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')];
} els... | 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 ... | 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 maskin... | 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 = ... | 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 ... | 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 fileSuffi... | 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 = {
c... | 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.parsePrim... | 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(allowI... | 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();
al... | 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[aliasTarge... | 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) {
... | 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 (addr... | 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 ... | 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 en... | 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].lengt... | 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 -= (... | 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 {boole... | 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}
* @pro... | 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... | 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()));
}
retur... | 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,... | 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() ==... | 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()... | 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];
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.