_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q21100
start
train
function start() { const node = process.execPath const daemonFile = path.join(__dirname, '../daemon') const startupFile = startup.getFile('hotel') startup.create('hotel', node, [daemonFile], common.logFile) // Save startup file path in ~/.hotel // Will be used later by uninstall script mkdirp.sync(commo...
javascript
{ "resource": "" }
q21101
queueQuery
train
function queueQuery(selector, mode, property, value) { if (typeof(allQueries[selector]) === 'undefined') { allQueries[selector] = []; // add animation to trigger animationstart event, so we know exactly when a element appears in the DOM var id = idToSelectorM...
javascript
{ "resource": "" }
q21102
findElementQueriesElements
train
function findElementQueriesElements(container) { var query = getQuery(container); for (var selector in allQueries) if (allQueries.hasOwnProperty(selector)) { // find all elements based on the extract query selector from the element query rule var elements = query...
javascript
{ "resource": "" }
q21103
getFiles
train
function getFiles(base, dir = '', results = []) { const files = fs.readdirSync(path.join(base, dir)); for (const file of files) { const relativeToBase = path.join(dir, file); if (fs.statSync(path.join(base, relativeToBase)).isDirectory()) { get...
javascript
{ "resource": "" }
q21104
train
function(font){ var me = this; if(me.font !== font){ me.font = font; me._fontHeight = Text.measureFontHeight(font); } return me; }
javascript
{ "resource": "" }
q21105
rotateX
train
function rotateX(x, y, z, ca, sa) {//rotate x return { x: x, y: y * ca - z * sa, z: y * sa + z * ca }; }
javascript
{ "resource": "" }
q21106
train
function(p1, p2, r1, r2) { var mindist = r1 + r2; var delta = vsub(p2, p1); var distsq = vlengthsq(delta); if(distsq >= mindist*mindist) return; var dist = Math.sqrt(distsq); // Allocate and initialize the contact. return new Contact( vadd(p1, vmult(delta, 0.5 + (r1 - 0.5*mindi...
javascript
{ "resource": "" }
q21107
train
function(circ1, circ2) { var contact = circle2circleQuery(circ1.tc, circ2.tc, circ1.r, circ2.r); return contact ? [contact] : NONE; }
javascript
{ "resource": "" }
q21108
train
function(poly1, poly2, n, dist) { var arr = []; var verts1 = poly1.tVerts; for(var i=0; i<verts1.length; i+=2){ var vx = verts1[i]; var vy = verts1[i+1]; if(poly2.containsVert(vx, vy)){ arr.push(new Contact(new Vect(vx, vy), n, dist, hashPair(poly1.hashid, i>>1))); ...
javascript
{ "resource": "" }
q21109
train
function(poly1, poly2) { var mini1 = findMSA(poly2, poly1.tPlanes); if(mini1 == -1) return NONE; var min1 = last_MSA_min; var mini2 = findMSA(poly1, poly2.tPlanes); if(mini2 == -1) return NONE; var min2 = last_MSA_min; // There is overlap, find the penetrating verts if(min1 > m...
javascript
{ "resource": "" }
q21110
train
function(arr, seg, poly, pDist, coef) { var dta = vcross(seg.tn, seg.ta); var dtb = vcross(seg.tn, seg.tb); var n = vmult(seg.tn, coef); var verts = poly.tVerts; for(var i=0; i<verts.length; i+=2){ var vx = verts[i]; var vy = verts[i+1]; if(vdot2(vx, vy, n.x, n.y) < vdo...
javascript
{ "resource": "" }
q21111
train
function(a, b, r1, r2, k1, k2) { // calculate mass matrix // If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross... var k11, k12, k21, k22; var m_sum = a.m_inv + b.m_inv; // start with I*m_sum k11 = m_sum; k12 = 0; k21 = 0; k22 = m_sum; // add the in...
javascript
{ "resource": "" }
q21112
train
function(args, optNames) { var opt = {"_": []}; // the unnamed option allows multiple values for (var i = 0; i < args.length; i++) { var arg = new String(args[i]); var name; var value; if (arg.charAt(0) == "-") { if (arg.charAt(1) == "-") { // it's a longname like --foo arg = arg.substring(2); ...
javascript
{ "resource": "" }
q21113
train
function(/**Array*/ path) { if (path.constructor != Array) path = path.split(/[\\\/]/); var make = ""; for (var i = 0, l = path.length; i < l; i++) { make += path[i] + SYS.slash; if (! IO.exists(make)) { IO.makeDir(make); } } }
javascript
{ "resource": "" }
q21114
train
function(path) { if (!path) return; for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++) if (/\.js$/i.test(lib[i])) load(lib[i]); }
javascript
{ "resource": "" }
q21115
Link
train
function Link() { this.alias = ""; this.src = ""; this.file = ""; this.text = ""; this.innerName = ""; this.classLink = false; this.targetName = ""; this.target = function(targetName) { if (defined(targetName)) this.targetName = targetName; return this; } this.inner = function(inner) { if (defined(inn...
javascript
{ "resource": "" }
q21116
prepare
train
function prepare(props) { const { translate, scale, rotation, skewX, skewY, originX, originY, fontFamily, fontSize, fontWeight, fontStyle, style, ...clean } = props; const transform = []; if (originX != null || originY != null) { transform.push(`translat...
javascript
{ "resource": "" }
q21117
translateUrl
train
function translateUrl (url) { const RE = new RegExp('^[./]'); if (RE.test(url)) { const fileUrl = 'file://' + path.join(process.cwd(), url); console.log('Relative filename detected -- translating to ' + fileUrl); return fileUrl; } else { return url; } }
javascript
{ "resource": "" }
q21118
processCmpData
train
function processCmpData(consentObject, hookConfig) { let gdprApplies = consentObject && consentObject.getConsentData && consentObject.getConsentData.gdprApplies; if ( (typeof gdprApplies !== 'boolean') || (gdprApplies === true && !(utils.isStr(consentObject.getConsentData.consentData) && utils...
javascript
{ "resource": "" }
q21119
cmpFailed
train
function cmpFailed(errMsg, hookConfig, extraArgs) { clearTimeout(hookConfig.timer); // still set the consentData to undefined when there is a problem as per config options if (allowAuction) { storeConsentData(undefined); } exitModule(errMsg, hookConfig, extraArgs); }
javascript
{ "resource": "" }
q21120
exitModule
train
function exitModule(errMsg, hookConfig, extraArgs) { if (hookConfig.haveExited === false) { hookConfig.haveExited = true; let context = hookConfig.context; let args = hookConfig.args; let nextFn = hookConfig.nextFn; if (errMsg) { if (allowAuction) { utils.logWarn(errMsg + ' Resumin...
javascript
{ "resource": "" }
q21121
train
function (bidRequests, bidderRequest) { return { data: bidToTag(bidRequests, bidderRequest), bidderRequest, method: 'GET', url: URL }; }
javascript
{ "resource": "" }
q21122
train
function (serverResponse, {bidderRequest}) { serverResponse = serverResponse.body; let bids = []; if (!utils.isArray(serverResponse)) { return parseRTBResponse(serverResponse, bidderRequest); } serverResponse.forEach(serverBidResponse => { bids = utils.flatten(bids, parseRTBResponse(se...
javascript
{ "resource": "" }
q21123
getMediaType
train
function getMediaType(bidderRequest) { const videoMediaType = utils.deepAccess(bidderRequest, 'mediaTypes.video'); const context = utils.deepAccess(bidderRequest, 'mediaTypes.video.context'); return !videoMediaType ? DISPLAY : context === OUTSTREAM ? OUTSTREAM : VIDEO; }
javascript
{ "resource": "" }
q21124
createBid
train
function createBid(bidResponse, mediaType) { let bid = { requestId: bidResponse.requestId, creativeId: bidResponse.cmpId, height: bidResponse.height, currency: bidResponse.cur, width: bidResponse.width, cpm: bidResponse.cpm, netRevenue: true, mediaType, ttl: 3600 }; if (mediaT...
javascript
{ "resource": "" }
q21125
newRenderer
train
function newRenderer(requestId) { const renderer = Renderer.install({ id: requestId, url: OUTSTREAM_SRC, loaded: false }); renderer.setRender(outstreamRender); return renderer; }
javascript
{ "resource": "" }
q21126
outstreamRender
train
function outstreamRender(bid) { bid.renderer.push(() => { window.VOutstreamAPI.initOutstreams([{ width: bid.width, height: bid.height, vastUrl: bid.vastUrl, elId: bid.adUnitCode }]); }); }
javascript
{ "resource": "" }
q21127
formatBidRequest
train
function formatBidRequest(bid, bidderRequest) { let url = urlTemplate({ adapter: 'prebid', slot: bid.params.slot, adkey: bid.params.adkey, ad_size: bid.params.ad_size, location: encodeURIComponent(utils.getTopWindowLocation()), referrer: encodeURIComponent(utils.getTopWindowReferrer()), wn...
javascript
{ "resource": "" }
q21128
template
train
function template(strings, ...keys) { return function(...values) { let dict = values[values.length - 1] || {}; let result = [strings[0]]; keys.forEach(function(key, i) { let value = isInteger(key) ? values[key] : dict[key]; result.push(value, strings[i + 1]); }); return result.join('')...
javascript
{ "resource": "" }
q21129
isResponseValid
train
function isResponseValid(response) { return !/^\s*\{\s*"advertisementAvailable"\s*:\s*false/i.test(response.content) && response.content.indexOf('<VAST version="2.0"></VAST>') === -1 && (typeof response.cpm !== 'undefined') && response.status === 1; }
javascript
{ "resource": "" }
q21130
train
function(bid) { return !!(bid.params.slot && bid.params.adkey && bid.params.ad_size); }
javascript
{ "resource": "" }
q21131
train
function (bid) { return !!(bid && bid.params && bid.params.adCode && bid.params.supplyCode); }
javascript
{ "resource": "" }
q21132
train
function (syncOptions, serverResponses) { const syncs = []; if (syncOptions.pixelEnabled && serverResponses.length) { try { serverResponses[0].body.ext.telaria.userSync.forEach(url => syncs.push({type: 'image', url: url})); } catch (e) {} } return syncs; }
javascript
{ "resource": "" }
q21133
createBid
train
function createBid(status, reqBid, response, width, height, bidderCode) { let bid = createBidFactory(status, reqBid); // TTL 5 mins by default, future support for extended imp wait time if (response) { Object.assign(bid, { requestId: reqBid.bidId, cpm: response.price, creativeId: response.c...
javascript
{ "resource": "" }
q21134
stringifySlotSizes
train
function stringifySlotSizes(sizes) { let result = ''; if (utils.isArray(sizes)) { result = sizes.reduce((acc, size) => { acc.push(size.join('.')); return acc; }, []); result = '[' + result.join(',') + ']'; } return result; }
javascript
{ "resource": "" }
q21135
attachPriceIndustryDurationKeyToBid
train
function attachPriceIndustryDurationKeyToBid(bid, brandCategoryExclusion) { let initialCacheKey = bidCacheRegistry.getInitialCacheKey(bid); let duration = utils.deepAccess(bid, 'video.durationBucket'); let cpmFixed = bid.cpm.toFixed(2); let pcd; if (brandCategoryExclusion) { let category = utils.deepAcce...
javascript
{ "resource": "" }
q21136
updateBidQueue
train
function updateBidQueue(auctionInstance, bidResponse, afterBidAdded) { let bidListIter = bidCacheRegistry.getBids(bidResponse); if (bidListIter) { let bidListArr = from(bidListIter); let callDispatcher = bidCacheRegistry.getQueueDispatcher(bidResponse); let killQueue = !!(auctionInstance.getAuctionStat...
javascript
{ "resource": "" }
q21137
firePrebidCacheCall
train
function firePrebidCacheCall(auctionInstance, bidList, afterBidAdded) { // remove entries now so other incoming bids won't accidentally have a stale version of the list while PBC is processing the current submitted list removeBidsFromStorage(bidList); store(bidList, function (error, cacheIds) { if (error) { ...
javascript
{ "resource": "" }
q21138
train
function(serverResponse) { let responseBody = serverResponse.body; const bids = []; if (responseBody && responseBody.no_bid !== 1) { let size = parseSize(responseBody.size); let bid = { requestId: responseBody.bid_id, ttl: BID_RESPONSE_TTL_SEC, netRevenue: IS_NET_REVENUE,...
javascript
{ "resource": "" }
q21139
buildGiBidRequest
train
function buildGiBidRequest(bidRequest) { let giBidRequest = { bid_id: bidRequest.bidId, pid: bidRequest.params.pid, // required tid: bidRequest.params.tid, // required known: bidRequest.params.known || 1, is_video: bidRequest.mediaType === 'video', resp_type: 'JSON', provider: 'direct.preb...
javascript
{ "resource": "" }
q21140
train
function(bid) { const siteId = bid.params.siteId || ''; if (!siteId) { utils.logError(LOG_MSG.noSite); } return !!(bid.adUnitCode && siteId); }
javascript
{ "resource": "" }
q21141
defaultSlots
train
function defaultSlots(slots) { return Array.isArray(slots) ? slots.slice() : googletag.pubads().getSlots().slice(); }
javascript
{ "resource": "" }
q21142
pickAdUnits
train
function pickAdUnits(gptSlots) { var adUnits = []; // traverse backwards (since gptSlots is mutated) to find adUnits in cache and remove non-mapped slots for (var i = gptSlots.length - 1; i > -1; i--) { const gptSlot = gptSlots[i]; const elemId = gptSlot.getSlotElementId(); con...
javascript
{ "resource": "" }
q21143
tryConvertType
train
function tryConvertType(typeToConvert, value) { if (typeToConvert === 'string') { return value && value.toString(); } else if (typeToConvert === 'number') { return Number(value); } else { return value; } }
javascript
{ "resource": "" }
q21144
getAdPodAdUnits
train
function getAdPodAdUnits(codes) { return auctionManager.getAdUnits() .filter((adUnit) => deepAccess(adUnit, 'mediaTypes.video.context') === ADPOD) .filter((adUnit) => (codes.length > 0) ? codes.indexOf(adUnit.code) != -1 : true); }
javascript
{ "resource": "" }
q21145
getExclusiveBids
train
function getExclusiveBids(bidsReceived) { let bids = bidsReceived .map((bid) => Object.assign({}, bid, {[TARGETING_KEY_PB_CAT_DUR]: bid.adserverTargeting[TARGETING_KEY_PB_CAT_DUR]})); bids = groupBy(bids, TARGETING_KEY_PB_CAT_DUR); let filteredBids = []; Object.keys(bids).forEach((targetingKey) => { bid...
javascript
{ "resource": "" }
q21146
getBidsForAdpod
train
function getBidsForAdpod(bidsReceived, adPodAdUnits) { let adUnitCodes = adPodAdUnits.map((adUnit) => adUnit.code); return bidsReceived .filter((bid) => adUnitCodes.indexOf(bid.adUnitCode) != -1 && (bid.video && bid.video.context === ADPOD)) }
javascript
{ "resource": "" }
q21147
Bid
train
function Bid(statusCode, bidRequest) { var _bidSrc = (bidRequest && bidRequest.src) || 'client'; var _statusCode = statusCode || 0; this.bidderCode = (bidRequest && bidRequest.bidder) || ''; this.width = 0; this.height = 0; this.statusMessage = _getStatus(); this.adId = utils.getUniqueIdentifierStr(); ...
javascript
{ "resource": "" }
q21148
dispatchImps
train
function dispatchImps(bidRequests, refererInfo) { let secure = (refererInfo && refererInfo.referer.indexOf('https:') === 0); return bidRequests.map(bidRequest => buildImp(bidRequest, secure)) .reduce((acc, curr, index) => { let bidRequest = bidRequests[index]; let zoneId = bidRequest.params.zoneId; ...
javascript
{ "resource": "" }
q21149
createSite
train
function createSite(refInfo) { let url = parseUrl(refInfo.referer); let result = { 'domain': url.hostname, 'page': url.protocol + '://' + url.hostname + url.pathname }; if (self === top && document.referrer) { result.ref = document.referrer; } let keywords = document.getElementsByTagName('meta')...
javascript
{ "resource": "" }
q21150
formatAdMarkup
train
function formatAdMarkup(bid) { let adm = bid.adm; if ('nurl' in bid) { adm += utils.createTrackPixelHtml(`${bid.nurl}&px=1`); } return adm; }
javascript
{ "resource": "" }
q21151
generateSizeParam
train
function generateSizeParam(sizes) { return sizes.map(size => size.join(DIMENSION_SEPARATOR)).join(SIZE_SEPARATOR); }
javascript
{ "resource": "" }
q21152
train
function(slot) { const hbAdIdTargeting = slot.getTargeting('hb_adid'); if (hbAdIdTargeting.length > 0) { const hbAdId = hbAdIdTargeting[0]; return typeof this.prebidWinnersCache[hbAdId] !== 'undefined'; } return false; }
javascript
{ "resource": "" }
q21153
train
function(instanceConfig, slot, version) { const bid = getHighestPrebidBidResponseBySlotTargeting( instanceConfig, slot, version ); // this is bid response event has `bidder` while bid won has bidderCode property return bid ? bid.bidderCode || bid.bidder : null; }
javascript
{ "resource": "" }
q21154
train
function(instanceConfig, slot, version) { const bid = getHighestPrebidBidResponseBySlotTargeting( instanceConfig, slot, version ); return bid ? bid.cpm : null; }
javascript
{ "resource": "" }
q21155
train
function(serverResponse) { let bids = []; let data = serverResponse.body; if (data.length > 0) { data.forEach((response) => { if (response.cpm && response.cpm > 0) { bids.push(createNewBid(response)); } }); } return bids; }
javascript
{ "resource": "" }
q21156
createNewBid
train
function createNewBid(response) { return { requestId: response['callback_id'], cpm: response.cpm, width: response.width, height: response.height, creativeId: response.creative_id, currency: CURRENCY, netRevenue: NET_REVENUE, ttl: TIME_TO_LIVE, ad: response.ad }; }
javascript
{ "resource": "" }
q21157
viewCoverage
train
function viewCoverage(done) { var coveragePort = 1999; var mylocalhost = (argv.host) ? argv.host : 'localhost'; connect.server({ port: coveragePort, root: 'build/coverage/karma_html', livereload: false }); opens('http://' + mylocalhost + ':' + coveragePort); done(); }
javascript
{ "resource": "" }
q21158
watch
train
function watch(done) { var mainWatcher = gulp.watch([ 'src/**/*.js', 'modules/**/*.js', 'test/spec/**/*.js', '!test/spec/loaders/**/*.js' ]); var loaderWatcher = gulp.watch([ 'loaders/**/*.js', 'test/spec/loaders/**/*.js' ]); connect.server({ https: argv.https, port: port, ...
javascript
{ "resource": "" }
q21159
incrementCounter
train
function incrementCounter(adunit) { adUnits[adunit] = adUnits[adunit] || {}; adUnits[adunit].counter = (deepAccess(adUnits, `${adunit}.counter`) + 1) || 1; return adUnits[adunit].counter; }
javascript
{ "resource": "" }
q21160
_getFlash
train
function _getFlash() { try { var _mac = (navigator.userAgent.indexOf('Mac') != -1); if (document.all) { if (_mac) { if (window['sample']) { return ((window['sample'].FlashVersion() & 0xffff0000) >> 16); } } else { var _axo = new ActiveXObject('ShockwaveFlash.Shock...
javascript
{ "resource": "" }
q21161
train
function(bid) { return !!(bid && bid.params && bid.params.accountID && bid.params.slotID); }
javascript
{ "resource": "" }
q21162
train
function(validBidRequests) { var bidRequests = []; for (var i = 0, len = validBidRequests.length; i < len; i++) { var bid = validBidRequests[i]; var accountID = utils.getBidIdParameter('accountID', bid.params); var slotID = utils.getBidIdParameter('slotID', bid.params); var url = utils.g...
javascript
{ "resource": "" }
q21163
train
function (brainyResponseObj, request) { var bidResponses = []; var bidRequest = request.bidRequest; var responseBody = brainyResponseObj ? brainyResponseObj.body : {}; bidResponses.push({ requestId: bidRequest.bidId, cpm: responseBody.cpm || 0, width: responseBody.width, height:...
javascript
{ "resource": "" }
q21164
getPageInfo
train
function getPageInfo() { var w, d, l, r, m, p, e, t, s; for (w = window, d = w.document, l = d.location.href, r = d.referrer, m = 0, e = encodeURIComponent, t = new Date(), s = screen; w !== w.parent;) { try { p = w.parent; l = p.location.href; r = p.document.referrer; w = p; } catch (e) { m = t...
javascript
{ "resource": "" }
q21165
bidResponseAvailable
train
function bidResponseAvailable(bidRequest, bidResponse) { const idToImpMap = {}; const idToBidMap = {}; bidResponse = bidResponse.body // extract the request bids and the response bids, keyed by impr-id const ortbRequest = parse(bidRequest.data); ortbRequest.imp.forEach(imp => { idToImpMap[imp.id] = imp;...
javascript
{ "resource": "" }
q21166
impression
train
function impression(slot) { return { id: slot.bidId, banner: banner(slot), 'native': nativeImpression(slot), tagid: slot.params.ct.toString(), }; }
javascript
{ "resource": "" }
q21167
banner
train
function banner(slot) { const size = adSize(slot); return slot.nativeParams ? null : { w: size[0], h: size[1], }; }
javascript
{ "resource": "" }
q21168
site
train
function site(bidderRequest) { const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0'; const appParams = bidderRequest[0].params.app; if (!appParams) { return { publisher: { id: pubId.toString(), }, ref: referrer(), page: utils.getTopWindowLo...
javascript
{ "resource": "" }
q21169
app
train
function app(bidderRequest) { const pubId = bidderRequest && bidderRequest.length > 0 ? bidderRequest[0].params.cp : '0'; const appParams = bidderRequest[0].params.app; if (appParams) { return { publisher: { id: pubId.toString(), }, bundle: appParams.bundle, storeurl: appParams...
javascript
{ "resource": "" }
q21170
device
train
function device() { return { ua: navigator.userAgent, language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage), }; }
javascript
{ "resource": "" }
q21171
parse
train
function parse(rawResponse) { try { if (rawResponse) { return JSON.parse(rawResponse); } } catch (ex) { utils.logError('pulsepointLite.safeParse', 'ERROR', ex); } return null; }
javascript
{ "resource": "" }
q21172
adSize
train
function adSize(slot) { if (slot.params.cf) { const size = slot.params.cf.toUpperCase().split('X'); const width = parseInt(slot.params.cw || size[0], 10); const height = parseInt(slot.params.ch || size[1], 10); return [width, height]; } return [1, 1]; }
javascript
{ "resource": "" }
q21173
applyGdpr
train
function applyGdpr(bidderRequest, ortbRequest) { if (bidderRequest && bidderRequest.gdprConsent) { ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; } }
javascript
{ "resource": "" }
q21174
nativeResponse
train
function nativeResponse(imp, bid) { if (imp['native']) { const nativeAd = parse(bid.adm); const keys = {}; if (nativeAd && nativeAd['native'] && nativeAd['native'].assets) { nativeAd['native'].assets.forEach(asset => { keys.title = asset.title ? asset.title.text : keys.title; keys.bo...
javascript
{ "resource": "" }
q21175
_createBidResponse
train
function _createBidResponse(response) { return { requestId: response.id, bidderCode: BIDDER_CODE, cpm: response.seatbid[0].bid[0].price, width: response.seatbid[0].bid[0].w, height: response.seatbid[0].bid[0].h, ad: response.seatbid[0].bid[0].adm, ttl: response.seatbid[0].bid[0].ttl || 60,...
javascript
{ "resource": "" }
q21176
_createSync
train
function _createSync(siteId) { const ttxSettings = config.getConfig('ttxSettings'); const syncUrl = (ttxSettings && ttxSettings.syncUrl) || SYNC_ENDPOINT; return { type: 'iframe', url: `${syncUrl}&id=${siteId}` } }
javascript
{ "resource": "" }
q21177
ViewabilityContributor
train
function ViewabilityContributor(viewabilityAmount) { function contributeViewability(ttxRequest) { const req = Object.assign({}, ttxRequest); const imp = req.imp = req.imp.map(impItem => Object.assign({}, impItem)); const banner = imp[0].banner = Object.assign({}, imp[0].banner); const ext = banner.ext...
javascript
{ "resource": "" }
q21178
tryAddVideoBid
train
function tryAddVideoBid(auctionInstance, bidResponse, bidRequests, afterBidAdded) { let addBid = true; const bidderRequest = getBidRequest(bidResponse.requestId, [bidRequests]); const videoMediaType = bidderRequest && deepAccess(bidderRequest, 'mediaTypes.video'); const context = videoMediaType && deepAccess...
javascript
{ "resource": "" }
q21179
createKeyVal
train
function createKeyVal(key, value) { return { key, val: (typeof value === 'function') ? function (bidResponse) { return value(bidResponse); } : function (bidResponse) { return getValue(bidResponse, value); } }; }
javascript
{ "resource": "" }
q21180
groupByPlacement
train
function groupByPlacement(bidsByPlacement, bid) { if (!bidsByPlacement[bid.adUnitCode]) { bidsByPlacement[bid.adUnitCode] = { bids: [] }; } bidsByPlacement[bid.adUnitCode].bids.push(bid); return bidsByPlacement; }
javascript
{ "resource": "" }
q21181
bidToBannerImp
train
function bidToBannerImp(bid) { const imp = {}; imp.id = bid.bidId; imp.banner = {}; imp.banner.w = bid.params.size[0]; imp.banner.h = bid.params.size[1]; imp.banner.topframe = utils.inIframe() ? 0 : 1; imp.ext = {}; imp.ext.siteID = bid.params.siteId; if (bid.params.hasOwnProperty('id') && (ty...
javascript
{ "resource": "" }
q21182
parseBid
train
function parseBid(rawBid, currency) { const bid = {}; if (PRICE_TO_DOLLAR_FACTOR.hasOwnProperty(currency)) { bid.cpm = rawBid.price / PRICE_TO_DOLLAR_FACTOR[currency]; } else { bid.cpm = rawBid.price / CENT_TO_DOLLAR_FACTOR; } bid.requestId = rawBid.impid; bid.width = rawBid.w; bid.height = rawB...
javascript
{ "resource": "" }
q21183
isValidSize
train
function isValidSize(size) { return isArray(size) && size.length === 2 && isInteger(size[0]) && isInteger(size[1]); }
javascript
{ "resource": "" }
q21184
includesSize
train
function includesSize(sizeArray, size) { if (isValidSize(sizeArray)) { return sizeArray[0] === size[0] && sizeArray[1] === size[1]; } for (let i = 0; i < sizeArray.length; i++) { if (sizeArray[i][0] === size[0] && sizeArray[i][1] === size[1]) { return true; } } return false; }
javascript
{ "resource": "" }
q21185
isValidBidFloorParams
train
function isValidBidFloorParams(bidFloor, bidFloorCur) { const curRegex = /^[A-Z]{3}$/; return Boolean(typeof bidFloor === 'number' && typeof bidFloorCur === 'string' && bidFloorCur.match(curRegex)); }
javascript
{ "resource": "" }
q21186
bidType
train
function bidType(bid, log = false) { // Is it considered video ad unit by rubicon if (hasVideoMediaType(bid)) { // Removed legacy mediaType support. new way using mediaTypes.video object is now required // We require either context as instream or outstream if (['outstream', 'instream'].indexOf(utils.dee...
javascript
{ "resource": "" }
q21187
partitionArray
train
function partitionArray(array, size) { return array.map((e, i) => (i % size === 0) ? array.slice(i, i + size) : null).filter((e) => e) }
javascript
{ "resource": "" }
q21188
checkAnalytics
train
function checkAnalytics() { if (_enableCheck && typeof window[_gaGlobal] === 'function') { for (var i = 0; i < _analyticsQueue.length; i++) { _analyticsQueue[i].call(); } // override push to execute the command immediately from now on _analyticsQueue.push = function (fn) { fn.call(); ...
javascript
{ "resource": "" }
q21189
typeIsSupported
train
function typeIsSupported(type) { if (!(type && includes(Object.keys(SUPPORTED_TYPES), type))) { logError(`${type} nativeParam is not supported`); return false; } return true; }
javascript
{ "resource": "" }
q21190
toStorageRequest
train
function toStorageRequest(bid) { const vastValue = bid.vastXml ? bid.vastXml : wrapURI(bid.vastUrl, bid.vastImpUrl); let payload = { type: 'xml', value: vastValue, ttlseconds: Number(bid.ttl) }; if (typeof bid.customCacheKey === 'string' && bid.customCacheKey !== '') { payload.key = bid.customC...
javascript
{ "resource": "" }
q21191
shimStorageCallback
train
function shimStorageCallback(done) { return { success: function(responseBody) { let ids; try { ids = JSON.parse(responseBody).responses } catch (e) { done(e, []); return; } if (ids) { done(null, ids); } else { done(new Error("The cache s...
javascript
{ "resource": "" }
q21192
getOverlapArea
train
function getOverlapArea(topLeft1, bottomRight1, topLeft2, bottomRight2) { // If no overlap, return 0 if ((topLeft1.x > bottomRight2.x || bottomRight1.x < topLeft2.x) || (topLeft1.y > bottomRight2.y || bottomRight1.y < topLeft2.y)) { return 0; } // return overlapping area : [ min of rightmost/bottommost co-o...
javascript
{ "resource": "" }
q21193
train
function(bid) { const isVideoMediaType = utils.deepAccess(bid, 'mediaTypes.video'); const videoContext = utils.deepAccess(bid, 'mediaTypes.video.context'); if (typeof bid.params !== 'object' || typeof bid.params.adid != 'string') { return false; } if (isVideoMediaType && videoContext === 'ou...
javascript
{ "resource": "" }
q21194
train
function (ucfunnelResponseObj, request) { const bidRequest = request.bidRequest; const ad = ucfunnelResponseObj ? ucfunnelResponseObj.body : {}; const videoPlayerSize = parseSizes(bidRequest); let bid = { requestId: bidRequest.bidId, cpm: ad.cpm || 0, creativeId: ad.ad_id, dealI...
javascript
{ "resource": "" }
q21195
getDevice
train
function getDevice() { const language = navigator.language ? 'language' : 'userLanguage'; return { h: screen.height, w: screen.width, dnt: getDNT() ? 1 : 0, language: navigator[language].split('-')[0], make: navigator.vendor ? navigator.vendor : '', ua: navigator.userAgent }; }
javascript
{ "resource": "" }
q21196
convertSizes
train
function convertSizes(bidSizes) { let format; if (Array.isArray(bidSizes)) { if (bidSizes.length === 2 && typeof bidSizes[0] === 'number' && typeof bidSizes[1] === 'number') { format = [{w: bidSizes[0], h: bidSizes[1]}]; } else { format = utils._map(bidSizes, d => { return {w: d[0], h: d[1]}; })...
javascript
{ "resource": "" }
q21197
validBidSize
train
function validBidSize(adUnitCode, bid, bidRequests) { if ((bid.width || parseInt(bid.width, 10) === 0) && (bid.height || parseInt(bid.height, 10) === 0)) { bid.width = parseInt(bid.width, 10); bid.height = parseInt(bid.height, 10); return true; } const adUnit = getBidderRequest(bidRequests, bid.bidde...
javascript
{ "resource": "" }
q21198
setS2sConfig
train
function setS2sConfig(options) { if (options.defaultVendor) { let vendor = options.defaultVendor; let optionKeys = Object.keys(options); if (S2S_VENDORS[vendor]) { // vendor keys will be set if either: the key was not specified by user // or if the user did not set their own distinct value (ie...
javascript
{ "resource": "" }
q21199
doPreBidderSync
train
function doPreBidderSync(type, url, bidder, done) { if (_s2sConfig.syncUrlModifier && typeof _s2sConfig.syncUrlModifier[bidder] === 'function') { const newSyncUrl = _s2sConfig.syncUrlModifier[bidder](type, url, bidder); doBidderSync(type, newSyncUrl, bidder, done) } else { doBidderSync(type, url, bidder...
javascript
{ "resource": "" }