_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q53300
ProcessBase
train
function ProcessBase(model) { if (!model) throw new Error('Must provide a model'); tr.model.EventContainer.call(this); this.model = model; this.threads = {}; this.counters = {}; this.objects = new tr.model.ObjectCollection(this); this.sortIndex = 0; }
javascript
{ "resource": "" }
q53301
train
function() { var threadsToKeep = {}; for (var tid in this.threads) { var thread = this.threads[tid]; if (!thread.isEmpty) threadsToKeep[tid] = thread; } this.threads = threadsToKeep; }
javascript
{ "resource": "" }
q53302
Thread
train
function Thread(parent, tid) { if (!parent) throw new Error('Parent must be provided.'); tr.model.EventContainer.call(this); this.parent = parent; this.sortIndex = 0; this.tid = tid; this.name = undefined; this.samples_ = undefined; // Set during createSubSlices var that = this; this.sliceGroup = new SliceGroup(this, ThreadSlice, 'slices'); this.timeSlices = undefined; this.kernelSliceGroup = new SliceGroup( this, ThreadSlice, 'kernel-slices'); this.asyncSliceGroup = new AsyncSliceGroup(this, 'async-slices'); }
javascript
{ "resource": "" }
q53303
train
function(amount) { this.sliceGroup.shiftTimestampsForward(amount); if (this.timeSlices) { for (var i = 0; i < this.timeSlices.length; i++) { var slice = this.timeSlices[i]; slice.start += amount; } } this.kernelSliceGroup.shiftTimestampsForward(amount); this.asyncSliceGroup.shiftTimestampsForward(amount); }
javascript
{ "resource": "" }
q53304
train
function() { this.bounds.reset(); this.sliceGroup.updateBounds(); this.bounds.addRange(this.sliceGroup.bounds); this.kernelSliceGroup.updateBounds(); this.bounds.addRange(this.kernelSliceGroup.bounds); this.asyncSliceGroup.updateBounds(); this.bounds.addRange(this.asyncSliceGroup.bounds); if (this.timeSlices && this.timeSlices.length) { this.bounds.addValue(this.timeSlices[0].start); this.bounds.addValue( this.timeSlices[this.timeSlices.length - 1].end); } if (this.samples_ && this.samples_.length) { this.bounds.addValue(this.samples_[0].start); this.bounds.addValue( this.samples_[this.samples_.length - 1].end); } }
javascript
{ "resource": "" }
q53305
CodeMap
train
function CodeMap() { /** * Dynamic code entries. Used for JIT compiled code. */ this.dynamics_ = new tr.e.importer.v8.SplayTree(); /** * Name generator for entries having duplicate names. */ this.dynamicsNameGen_ = new tr.e.importer.v8.CodeMap.NameGenerator(); /** * Static code entries. Used for statically compiled code. */ this.statics_ = new tr.e.importer.v8.SplayTree(); /** * Libraries entries. Used for the whole static code libraries. */ this.libraries_ = new tr.e.importer.v8.SplayTree(); /** * Map of memory pages occupied with static code. */ this.pages_ = []; }
javascript
{ "resource": "" }
q53306
CounterSample
train
function CounterSample(series, timestamp, value) { tr.model.Event.call(this); this.series_ = series; this.timestamp_ = timestamp; this.value_ = value; }
javascript
{ "resource": "" }
q53307
findIndexInSortedIntervals
train
function findIndexInSortedIntervals(ary, mapLoFn, mapWidthFn, loVal) { var first = findLowIndexInSortedArray(ary, mapLoFn, loVal); if (first == 0) { if (loVal >= mapLoFn(ary[0]) && loVal < mapLoFn(ary[0]) + mapWidthFn(ary[0], 0)) { return 0; } else { return -1; } } else if (first < ary.length) { if (loVal >= mapLoFn(ary[first]) && loVal < mapLoFn(ary[first]) + mapWidthFn(ary[first], first)) { return first; } else if (loVal >= mapLoFn(ary[first - 1]) && loVal < mapLoFn(ary[first - 1]) + mapWidthFn(ary[first - 1], first - 1)) { return first - 1; } else { return ary.length; } } else if (first == ary.length) { if (loVal >= mapLoFn(ary[first - 1]) && loVal < mapLoFn(ary[first - 1]) + mapWidthFn(ary[first - 1], first - 1)) { return first - 1; } else { return ary.length; } } else { return ary.length; } }
javascript
{ "resource": "" }
q53308
findIndexInSortedClosedIntervals
train
function findIndexInSortedClosedIntervals(ary, mapLoFn, mapHiFn, val) { var i = findLowIndexInSortedArray(ary, mapLoFn, val); if (i === 0) { if (val >= mapLoFn(ary[0], 0) && val <= mapHiFn(ary[0], 0)) { return 0; } else { return -1; } } else if (i < ary.length) { if (val >= mapLoFn(ary[i - 1], i - 1) && val <= mapHiFn(ary[i - 1], i - 1)) { return i - 1; } else if (val >= mapLoFn(ary[i], i) && val <= mapHiFn(ary[i], i)) { return i; } else { return ary.length; } } else if (i == ary.length) { if (val >= mapLoFn(ary[i - 1], i - 1) && val <= mapHiFn(ary[i - 1], i - 1)) { return i - 1; } else { return ary.length; } } else { return ary.length; } }
javascript
{ "resource": "" }
q53309
iterateOverIntersectingIntervals
train
function iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal, cb) { if (ary.length == 0) return; if (loVal > hiVal) return; var i = findLowIndexInSortedArray(ary, mapLoFn, loVal); if (i == -1) { return; } if (i > 0) { var hi = mapLoFn(ary[i - 1]) + mapWidthFn(ary[i - 1], i - 1); if (hi >= loVal) { cb(ary[i - 1], i - 1); } } if (i == ary.length) { return; } for (var n = ary.length; i < n; i++) { var lo = mapLoFn(ary[i]); if (lo >= hiVal) break; cb(ary[i], i); } }
javascript
{ "resource": "" }
q53310
getIntersectingIntervals
train
function getIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal) { var tmp = []; iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal, function(d) { tmp.push(d); }); return tmp; }
javascript
{ "resource": "" }
q53311
findClosestElementInSortedArray
train
function findClosestElementInSortedArray(ary, mapFn, val, maxDiff) { if (ary.length === 0) return null; var aftIdx = findLowIndexInSortedArray(ary, mapFn, val); var befIdx = aftIdx > 0 ? aftIdx - 1 : 0; if (aftIdx === ary.length) aftIdx -= 1; var befDiff = Math.abs(val - mapFn(ary[befIdx])); var aftDiff = Math.abs(val - mapFn(ary[aftIdx])); if (befDiff > maxDiff && aftDiff > maxDiff) return null; var idx = befDiff < aftDiff ? befIdx : aftIdx; return ary[idx]; }
javascript
{ "resource": "" }
q53312
findClosestIntervalInSortedIntervals
train
function findClosestIntervalInSortedIntervals(ary, mapLoFn, mapHiFn, val, maxDiff) { if (ary.length === 0) return null; var idx = findLowIndexInSortedArray(ary, mapLoFn, val); if (idx > 0) idx -= 1; var hiInt = ary[idx]; var loInt = hiInt; if (val > mapHiFn(hiInt) && idx + 1 < ary.length) loInt = ary[idx + 1]; var loDiff = Math.abs(val - mapLoFn(loInt)); var hiDiff = Math.abs(val - mapHiFn(hiInt)); if (loDiff > maxDiff && hiDiff > maxDiff) return null; if (loDiff < hiDiff) return loInt; else return hiInt; }
javascript
{ "resource": "" }
q53313
train
function(rirs) { var vacuumIRs = []; rirs.forEach(function(ir) { if (ir instanceof tr.e.rail.LoadInteractionRecord || ir instanceof tr.e.rail.IdleInteractionRecord) vacuumIRs.push(ir); }); if (vacuumIRs.length === 0) return; var allAssociatedEvents = tr.model.getAssociatedEvents(rirs); var unassociatedEvents = tr.model.getUnassociatedEvents( this.model, allAssociatedEvents); unassociatedEvents.forEach(function(event) { if (!(event instanceof tr.model.ThreadSlice)) return; if (!event.isTopLevel) return; for (var iri = 0; iri < vacuumIRs.length; ++iri) { var ir = vacuumIRs[iri]; if ((event.start >= ir.start) && (event.start < ir.end)) { ir.associatedEvents.addEventSet(event.entireHierarchy); return; } } }); }
javascript
{ "resource": "" }
q53314
train
function(otherIRs) { if (this.model.bounds.isEmpty) return; var emptyRanges = tr.b.findEmptyRangesBetweenRanges( tr.b.convertEventsToRanges(otherIRs), this.model.bounds); var irs = []; var model = this.model; emptyRanges.forEach(function(range) { // Ignore insignificantly tiny idle ranges. if (range.max < (range.min + INSIGNIFICANT_MS)) return; irs.push(new tr.e.rail.IdleInteractionRecord( model, range.min, range.max - range.min)); }); return irs; }
javascript
{ "resource": "" }
q53315
train
function() { function isStartupSlice(slice) { return slice.title === 'BrowserMainLoop::CreateThreads'; } var events = this.modelHelper.browserHelper.getAllAsyncSlicesMatching( isStartupSlice); var deduper = new tr.model.EventSet(); events.forEach(function(event) { var sliceGroup = event.parentContainer.sliceGroup; var slice = sliceGroup && sliceGroup.findFirstSlice(); if (slice) deduper.push(slice); }); return deduper.toArray(); }
javascript
{ "resource": "" }
q53316
train
function(lir) { var createChildEvent = undefined; lir.renderMainThread.iterateAllEvents(function(event) { if (event.title !== CREATE_CHILD_TITLE) return; if (event.args.child !== lir.routingId) return; createChildEvent = event; }); if (!createChildEvent) return undefined; return createChildEvent.args.id; }
javascript
{ "resource": "" }
q53317
train
function() { var startupEvents = this.getStartupEvents(); var commitLoadEvents = this.modelHelper.browserHelper.getCommitProvisionalLoadEventsInRange( this.model.bounds); var frameEvents = this.getAllFrameEvents(); var startLoadEvents = this.getStartLoadEvents(); var failLoadEvents = this.getFailLoadEvents(); var lirs = []; // Attach frame events to every startup events. var startupLIRs = this.findLoadInteractionRecords_(startupEvents, frameEvents); this.setIRNames_(LOAD_STARTUP_IR_NAME, startupLIRs); lirs.push.apply(lirs, startupLIRs); // Attach frame events to every commit load events. var successfulLIRs = this.findLoadInteractionRecords_(commitLoadEvents, frameEvents); this.setIRNames_(LOAD_SUCCEEDED_IR_NAME, successfulLIRs); successfulLIRs.forEach(function(lir) { // If a successful Load IR has a loadFinishedEvent, then it is a main // frame. // Drop sub-frame Loads for now. if (lir.loadFinishedEvent) lirs.push(lir); }); // Attach fail load events to every start load events. var failedLIRs = this.findLoadInteractionRecords_(startLoadEvents, failLoadEvents); this.setIRNames_(LOAD_FAILED_IR_NAME, failedLIRs); failedLIRs.forEach(function(lir) { // If a failed Load IR has a parentRoutingId, then it is a sub-frame. // Drop sub-frame Loads for now. if (lir.parentRoutingId === undefined) lirs.push(lir); }); return lirs; }
javascript
{ "resource": "" }
q53318
train
function() { var sortedInputEvents = this.getSortedInputEvents(); var protoIRs = this.findProtoIRs(sortedInputEvents); protoIRs = this.postProcessProtoIRs(protoIRs); this.checkAllInputEventsHandled(sortedInputEvents, protoIRs); var irs = []; var model = this.model; protoIRs.forEach(function(protoIR) { var ir = protoIR.createInteractionRecord(model); if (ir) irs.push(ir); }); return irs; }
javascript
{ "resource": "" }
q53319
train
function(sortedInputEvents) { var protoIRs = []; forEventTypesIn(sortedInputEvents, KEYBOARD_TYPE_NAMES, function(event) { var pir = new ProtoIR(ProtoIR.RESPONSE_TYPE, KEYBOARD_IR_NAME); pir.pushEvent(event); protoIRs.push(pir); }); return protoIRs; }
javascript
{ "resource": "" }
q53320
train
function(sortedInputEvents) { var protoIRs = []; forEventTypesIn( sortedInputEvents, MOUSE_RESPONSE_TYPE_NAMES, function(event) { var pir = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSE_IR_NAME); pir.pushEvent(event); protoIRs.push(pir); }); return protoIRs; }
javascript
{ "resource": "" }
q53321
train
function(sortedInputEvents) { var protoIRs = []; var currentPIR = undefined; var prevEvent_ = undefined; forEventTypesIn( sortedInputEvents, MOUSE_WHEEL_TYPE_NAMES, function(event) { // Switch prevEvent in one place so that we can early-return later. var prevEvent = prevEvent_; prevEvent_ = event; if (currentPIR && (prevEvent.start + MOUSE_WHEEL_THRESHOLD_MS) >= event.start) { if (currentPIR.irType === ProtoIR.ANIMATION_TYPE) { currentPIR.pushEvent(event); } else { currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, MOUSEWHEEL_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); } return; } currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSEWHEEL_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); }); return protoIRs; }
javascript
{ "resource": "" }
q53322
train
function(sortedInputEvents) { var protoIRs = []; var currentPIR = undefined; var sawFirstUpdate = false; var modelBounds = this.model.bounds; forEventTypesIn(sortedInputEvents, PINCH_TYPE_NAMES, function(event) { switch (event.typeName) { case INPUT_TYPE.PINCH_BEGIN: if (currentPIR && currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) { currentPIR.pushEvent(event); break; } currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, PINCH_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); sawFirstUpdate = false; break; case INPUT_TYPE.PINCH_UPDATE: // Like ScrollUpdates, the Begin and the first Update constitute a // Response, then the rest of the Updates constitute an Animation // that begins when the Response ends. If the user pauses in the // middle of an extended pinch gesture, then multiple Animations // will be created. if (!currentPIR || ((currentPIR.irType === ProtoIR.RESPONSE_TYPE) && sawFirstUpdate) || !currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) { currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, PINCH_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); } else { currentPIR.pushEvent(event); sawFirstUpdate = true; } break; case INPUT_TYPE.PINCH_END: if (currentPIR) { currentPIR.pushEvent(event); } else { var pir = new ProtoIR(ProtoIR.IGNORED_TYPE); pir.pushEvent(event); protoIRs.push(pir); } currentPIR = undefined; break; } }); return protoIRs; }
javascript
{ "resource": "" }
q53323
train
function(sortedInputEvents) { var protoIRs = []; var currentPIR = undefined; var sawFirstMove = false; forEventTypesIn(sortedInputEvents, TOUCH_TYPE_NAMES, function(event) { switch (event.typeName) { case INPUT_TYPE.TOUCH_START: if (currentPIR) { // NB: currentPIR will probably be merged with something from // handlePinchEvents(). Multiple TouchStart events without an // intervening TouchEnd logically implies that multiple fingers // are on the screen, so this is probably a pinch gesture. currentPIR.pushEvent(event); } else { currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, TOUCH_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); sawFirstMove = false; } break; case INPUT_TYPE.TOUCH_MOVE: if (!currentPIR) { currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, TOUCH_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); break; } // Like Scrolls and Pinches, the Response is defined to be the // TouchStart plus the first TouchMove, then the rest of the // TouchMoves constitute an Animation. if ((sawFirstMove && (currentPIR.irType === ProtoIR.RESPONSE_TYPE)) || !currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) { // If there's already a touchmove in the currentPIR or it's not // near event, then finish it and start a new animation. var prevEnd = currentPIR.end; currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, TOUCH_IR_NAME); currentPIR.pushEvent(event); // It's possible for there to be a gap between TouchMoves, but // that doesn't mean that there should be an Idle IR there. currentPIR.start = prevEnd; protoIRs.push(currentPIR); } else { currentPIR.pushEvent(event); sawFirstMove = true; } break; case INPUT_TYPE.TOUCH_END: if (!currentPIR) { var pir = new ProtoIR(ProtoIR.IGNORED_TYPE); pir.pushEvent(event); protoIRs.push(pir); break; } if (currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) { currentPIR.pushEvent(event); } else { var pir = new ProtoIR(ProtoIR.IGNORED_TYPE); pir.pushEvent(event); protoIRs.push(pir); } currentPIR = undefined; break; } }); return protoIRs; }
javascript
{ "resource": "" }
q53324
train
function(sortedInputEvents) { var protoIRs = []; var currentPIR = undefined; var sawFirstUpdate = false; forEventTypesIn(sortedInputEvents, SCROLL_TYPE_NAMES, function(event) { switch (event.typeName) { case INPUT_TYPE.SCROLL_BEGIN: // Always begin a new PIR even if there already is one, unlike // PinchBegin. currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, SCROLL_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); sawFirstUpdate = false; break; case INPUT_TYPE.SCROLL_UPDATE: if (currentPIR) { if (currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS) && ((currentPIR.irType === ProtoIR.ANIMATION_TYPE) || !sawFirstUpdate)) { currentPIR.pushEvent(event); sawFirstUpdate = true; } else { currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, SCROLL_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); } } else { // ScrollUpdate without ScrollBegin. currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, SCROLL_IR_NAME); currentPIR.pushEvent(event); protoIRs.push(currentPIR); } break; case INPUT_TYPE.SCROLL_END: if (!currentPIR) { console.error('ScrollEnd without ScrollUpdate? ' + 'File a bug with this trace!'); var pir = new ProtoIR(ProtoIR.IGNORED_TYPE); pir.pushEvent(event); protoIRs.push(pir); break; } currentPIR.pushEvent(event); break; } }); return protoIRs; }
javascript
{ "resource": "" }
q53325
train
function(sortedInputEvents) { var animationEvents = this.modelHelper.browserHelper. getAllAsyncSlicesMatching(function(event) { return ((event.title === CSS_ANIMATION_TITLE) && (event.duration > 0)); }); var animationRanges = []; animationEvents.forEach(function(event) { animationRanges.push({ min: event.start, max: event.end, event: event }); }); function merge(ranges) { var protoIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, CSS_IR_NAME); ranges.forEach(function(range) { protoIR.pushEvent(range.event); }); return protoIR; } return tr.b.mergeRanges(animationRanges, ANIMATION_MERGE_THRESHOLD_MS, merge); }
javascript
{ "resource": "" }
q53326
train
function(sortedInputEvents, protoIRs) { var handledEvents = []; protoIRs.forEach(function(protoIR) { protoIR.associatedEvents.forEach(function(event) { if (handledEvents.indexOf(event) >= 0) { console.error('double-handled event', event.typeName, parseInt(event.start), parseInt(event.end), protoIR); return; } handledEvents.push(event); }); }); sortedInputEvents.forEach(function(event) { if (handledEvents.indexOf(event) < 0) { console.error('UNHANDLED INPUT EVENT!', event.typeName, parseInt(event.start), parseInt(event.end)); } }); }
javascript
{ "resource": "" }
q53327
MemReclaimParser
train
function MemReclaimParser(importer) { Parser.call(this, importer); importer.registerEventHandler('mm_vmscan_kswapd_wake', MemReclaimParser.prototype.kswapdWake.bind(this)); importer.registerEventHandler('mm_vmscan_kswapd_sleep', MemReclaimParser.prototype.kswapdSleep.bind(this)); importer.registerEventHandler('mm_vmscan_direct_reclaim_begin', MemReclaimParser.prototype.reclaimBegin.bind(this)); importer.registerEventHandler('mm_vmscan_direct_reclaim_end', MemReclaimParser.prototype.reclaimEnd.bind(this)); }
javascript
{ "resource": "" }
q53328
train
function(eventName, cpuNumber, pid, ts, eventBase) { var event = kswapdWakeRE.exec(eventBase.details); if (!event) return false; var tgid = parseInt(eventBase.tgid); var nid = parseInt(event[1]); var order = parseInt(event[2]); var kthread = this.importer.getOrCreateKernelThread( eventBase.threadName, tgid, pid); if (kthread.openSliceTS) { if (order > kthread.order) { kthread.order = order; } } else { kthread.openSliceTS = ts; kthread.order = order; } return true; }
javascript
{ "resource": "" }
q53329
SyncParser
train
function SyncParser(importer) { Parser.call(this, importer); importer.registerEventHandler( 'sync_timeline', SyncParser.prototype.timelineEvent.bind(this)); importer.registerEventHandler( 'sync_wait', SyncParser.prototype.syncWaitEvent.bind(this)); importer.registerEventHandler( 'sync_pt', SyncParser.prototype.syncPtEvent.bind(this)); this.model_ = importer.model_; }
javascript
{ "resource": "" }
q53330
train
function(eventName, cpuNumber, pid, ts, eventBase) { var event = syncTimelineRE.exec(eventBase.details); if (!event) return false; var thread = this.importer.getOrCreatePseudoThread(event[1]); if (thread.lastActiveTs !== undefined) { var duration = ts - thread.lastActiveTs; var value = thread.lastActiveValue; if (value == undefined) value = ' '; var slice = new tr.model.Slice( '', value, ColorScheme.getColorIdForGeneralPurposeString(value), thread.lastActiveTs, {}, duration); thread.thread.sliceGroup.pushSlice(slice); } thread.lastActiveTs = ts; thread.lastActiveValue = event[2]; return true; }
javascript
{ "resource": "" }
q53331
I915Parser
train
function I915Parser(importer) { Parser.call(this, importer); importer.registerEventHandler('i915_gem_object_create', I915Parser.prototype.gemObjectCreateEvent.bind(this)); importer.registerEventHandler('i915_gem_object_bind', I915Parser.prototype.gemObjectBindEvent.bind(this)); importer.registerEventHandler('i915_gem_object_unbind', I915Parser.prototype.gemObjectBindEvent.bind(this)); importer.registerEventHandler('i915_gem_object_change_domain', I915Parser.prototype.gemObjectChangeDomainEvent.bind(this)); importer.registerEventHandler('i915_gem_object_pread', I915Parser.prototype.gemObjectPreadWriteEvent.bind(this)); importer.registerEventHandler('i915_gem_object_pwrite', I915Parser.prototype.gemObjectPreadWriteEvent.bind(this)); importer.registerEventHandler('i915_gem_object_fault', I915Parser.prototype.gemObjectFaultEvent.bind(this)); importer.registerEventHandler('i915_gem_object_clflush', // NB: reuse destroy handler I915Parser.prototype.gemObjectDestroyEvent.bind(this)); importer.registerEventHandler('i915_gem_object_destroy', I915Parser.prototype.gemObjectDestroyEvent.bind(this)); importer.registerEventHandler('i915_gem_ring_dispatch', I915Parser.prototype.gemRingDispatchEvent.bind(this)); importer.registerEventHandler('i915_gem_ring_flush', I915Parser.prototype.gemRingFlushEvent.bind(this)); importer.registerEventHandler('i915_gem_request', I915Parser.prototype.gemRequestEvent.bind(this)); importer.registerEventHandler('i915_gem_request_add', I915Parser.prototype.gemRequestEvent.bind(this)); importer.registerEventHandler('i915_gem_request_complete', I915Parser.prototype.gemRequestEvent.bind(this)); importer.registerEventHandler('i915_gem_request_retire', I915Parser.prototype.gemRequestEvent.bind(this)); importer.registerEventHandler('i915_gem_request_wait_begin', I915Parser.prototype.gemRequestEvent.bind(this)); importer.registerEventHandler('i915_gem_request_wait_end', I915Parser.prototype.gemRequestEvent.bind(this)); importer.registerEventHandler('i915_gem_ring_wait_begin', I915Parser.prototype.gemRingWaitEvent.bind(this)); importer.registerEventHandler('i915_gem_ring_wait_end', I915Parser.prototype.gemRingWaitEvent.bind(this)); importer.registerEventHandler('i915_reg_rw', I915Parser.prototype.regRWEvent.bind(this)); importer.registerEventHandler('i915_flip_request', I915Parser.prototype.flipEvent.bind(this)); importer.registerEventHandler('i915_flip_complete', I915Parser.prototype.flipEvent.bind(this)); importer.registerEventHandler('intel_gpu_freq_change', I915Parser.prototype.gpuFrequency.bind(this)); }
javascript
{ "resource": "" }
q53332
train
function(eventName, cpuNumber, pid, ts, eventBase) { var event = /obj=(\w+), size=(\d+)/.exec(eventBase.details); if (!event) return false; var obj = event[1]; var size = parseInt(event[2]); this.i915GemObjectSlice(ts, eventName, obj, { obj: obj, size: size }); return true; }
javascript
{ "resource": "" }
q53333
ExynosParser
train
function ExynosParser(importer) { Parser.call(this, importer); importer.registerEventHandler('exynos_busfreq_target_int', ExynosParser.prototype.busfreqTargetIntEvent.bind(this)); importer.registerEventHandler('exynos_busfreq_target_mif', ExynosParser.prototype.busfreqTargetMifEvent.bind(this)); importer.registerEventHandler('exynos_page_flip_state', ExynosParser.prototype.pageFlipStateEvent.bind(this)); }
javascript
{ "resource": "" }
q53334
train
function(eventName, cpuNumber, pid, ts, eventBase) { var event = /frequency=(\d+)/.exec(eventBase.details); if (!event) return false; this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1])); return true; }
javascript
{ "resource": "" }
q53335
train
function(eventName, cpuNumber, pid, ts, eventBase) { var event = /pipe=(\d+), fb=(\d+), state=(.*)/.exec(eventBase.details); if (!event) return false; var pipe = parseInt(event[1]); var fb = parseInt(event[2]); var state = event[3]; this.exynosPageFlipStateCloseSlice(ts, pipe, fb, { pipe: pipe, fb: fb }); if (state !== 'flipped') this.exynosPageFlipStateOpenSlice(ts, pipe, fb, state); return true; }
javascript
{ "resource": "" }
q53336
IrqParser
train
function IrqParser(importer) { Parser.call(this, importer); importer.registerEventHandler('irq_handler_entry', IrqParser.prototype.irqHandlerEntryEvent.bind(this)); importer.registerEventHandler('irq_handler_exit', IrqParser.prototype.irqHandlerExitEvent.bind(this)); importer.registerEventHandler('softirq_raise', IrqParser.prototype.softirqRaiseEvent.bind(this)); importer.registerEventHandler('softirq_entry', IrqParser.prototype.softirqEntryEvent.bind(this)); importer.registerEventHandler('softirq_exit', IrqParser.prototype.softirqExitEvent.bind(this)); importer.registerEventHandler('ipi_entry', IrqParser.prototype.ipiEntryEvent.bind(this)); importer.registerEventHandler('ipi_exit', IrqParser.prototype.ipiExitEvent.bind(this)); }
javascript
{ "resource": "" }
q53337
train
function(eventName, cpuNumber, pid, ts, eventBase) { var event = irqHandlerEntryRE.exec(eventBase.details); if (!event) return false; var irq = parseInt(event[1]); var name = event[2]; var thread = this.importer.getOrCreatePseudoThread( 'irqs cpu ' + cpuNumber); thread.lastEntryTs = ts; thread.irqName = name; return true; }
javascript
{ "resource": "" }
q53338
train
function(eventName, cpuNumber, pid, ts, eventBase) { var thread = this.importer.getOrCreatePseudoThread( 'irqs cpu ' + cpuNumber); thread.lastEntryTs = ts; return true; }
javascript
{ "resource": "" }
q53339
initialize
train
function initialize() { if (global.isVinn) { tr.isVinn = true; } else if (global.process && global.process.versions.node) { tr.isNode = true; } else { tr.isVinn = false; tr.isNode = false; tr.doc = document; tr.isMac = /Mac/.test(navigator.platform); tr.isWindows = /Win/.test(navigator.platform); tr.isChromeOS = /CrOS/.test(navigator.userAgent); tr.isLinux = /Linux/.test(navigator.userAgent); } tr.isHeadless = tr.isVinn || tr.isNode; }
javascript
{ "resource": "" }
q53340
train
function(type, handler) { if (!this.listeners_) this.listeners_ = Object.create(null); if (!(type in this.listeners_)) { this.listeners_[type] = [handler]; } else { var handlers = this.listeners_[type]; if (handlers.indexOf(handler) < 0) handlers.push(handler); } }
javascript
{ "resource": "" }
q53341
train
function(type, handler) { if (!this.listeners_) return; if (type in this.listeners_) { var handlers = this.listeners_[type]; var index = handlers.indexOf(handler); if (index >= 0) { // Clean up if this was the last listener. if (handlers.length == 1) delete this.listeners_[type]; else handlers.splice(index, 1); } } }
javascript
{ "resource": "" }
q53342
train
function(event) { if (!this.listeners_) return true; // Since we are using DOM Event objects we need to override some of the // properties and methods so that we can emulate this correctly. var self = this; event.__defineGetter__('target', function() { return self; }); var realPreventDefault = event.preventDefault; event.preventDefault = function() { realPreventDefault.call(this); this.rawReturnValue = false; }; var type = event.type; var prevented = 0; if (type in this.listeners_) { // Clone to prevent removal during dispatch var handlers = this.listeners_[type].concat(); for (var i = 0, handler; handler = handlers[i]; i++) { if (handler.handleEvent) prevented |= handler.handleEvent.call(handler, event) === false; else prevented |= handler.call(this, event) === false; } } return !prevented && event.rawReturnValue; }
javascript
{ "resource": "" }
q53343
__verify_client_registration_entries
train
function __verify_client_registration_entries(authorize_request) { return new Promise(async (resolve, reject) => { let error_object = { error: "unauthorized_client", error_description: "" }; try { if (!authorize_request.client_id || !authorize_request.redirect_uri) { error_object.error_description = "Incorrect client_id/redirect_uri values"; return reject(error_object); } let redirect_url = Url.parse(authorize_request.redirect_uri); if (redirect_url.protocol.toLowerCase() !== "https:") { error_object.error_description = "Redirect_uri must use the https protocol."; return reject(error_object); } try { const client_registry = await client_endpoint .client_registrar_module .get_client_registration(authorize_request.client_id); if (!client_registry || (client_registry.redirect_uri_hostname.trim() !== redirect_url.hostname) || (client_registry.redirect_uri_port.trim() !== redirect_url.port)) { error_object.error_description = "Incorrect client_id/redirect_uri values"; return reject(error_object); } else { return resolve(); } } catch (err) { return reject(error_object); } } catch (err) { error_object.error_description = "Incorrect client_id/redirect_uri values"; return reject(error_object); } }); }
javascript
{ "resource": "" }
q53344
__validate_authorization_request
train
function __validate_authorization_request(authorize_request) { return new Promise((resolve, reject) => { let error_object = { error: "invlalid_request", error_description: "" }; if (authorize_request.state) { error_object.state = authorize_request.state; } if (authorize_request.nonce) { error_object.nonce = authorize_request.nonce; } let openid_scope_found = authorize_request .scope .split(" ") .find((element, idx, arr) => { if (element.trim() === "openid") { return true; } }); if (!openid_scope_found) { error_object.error = "invalid_scope"; error_object.error_description = "scope must include openid"; return reject(error_object); } if ((!authorize_request.response_type) || (authorize_request.response_type.trim() !== "code")) { error_object.error = "unsupported_response_type"; error_object.error_description = "Only Authorization Code Flow is supported."; return reject(error_object); } return resolve(authorize_request); }); }
javascript
{ "resource": "" }
q53345
post_token
train
function post_token(oidc_token) { return new Promise((resolve, reject) => { dbMgr .updateOne("oidc_token", { id_token: { $eq: null } }, { $currentDate: { expire_on: true }, $set: oidc_token }, {upsert: true}) .then((result) => { if (result.upsertedCount === 1) { return resolve(result.upsertedId._id); } else { return reject(new Error("No oidc_token recoreds inserted")); } }, (err) => { reject(err); }); }); }
javascript
{ "resource": "" }
q53346
post_authorization_request
train
function post_authorization_request(authorization_request) { return new Promise((resolve, reject) => { dbMgr .updateOne("authorization_request", { client_id: { $eq: null } }, { $set: authorization_request }, {upsert: true}) .then((result) => { if (result.upsertedCount === 1) { return resolve(result.upsertedId._id); } else { return reject(new Error("No authorization recoreds inserted")); } }, (err) => { reject(err); }); }); }
javascript
{ "resource": "" }
q53347
get_authorization_request
train
function get_authorization_request(authorization_request_id) { return new Promise((resolve, reject) => { dbMgr .find("authorization_request", { _id: { $eq: authorization_request_id } }, {limit: 1}) .then((authorize_requests) => { if (authorize_requests.length > 0) { return resolve(authorize_requests[0]); } else { return reject(new Error("No authorization request records found!")); } }, reject); }); }
javascript
{ "resource": "" }
q53348
__send_token_for_authorization_code
train
async function __send_token_for_authorization_code(request_params, request, h) { function __process_authorization_code(request_params) { return authorization_endpoint .authorization_request_registrar_module .get_authorization_request(request_params.code); } try { const authorization_request_record = await promiseSequencer([ __process_authorization_header_for_client, __process_authorization_code ], request_params); if (authorization_request_record.granted) { if ((authorization_request_record.client_id === request_params.client_id) && (authorization_request_record.redirect_uri === request_params.redirect_uri)) { //send token for authorization_code grant_type let oidc_claims = { audience: [authorization_request_record.client_id], subject: authorization_request_record.subject }; if (authorization_request_record.nonce) { oidc_claims.nonce = authorization_request_record.nonce; } return __send_oidc_token(request, h, oidc_claims, token_endpoint.authorization_code_grant_type.token_duration_seconds); } } /** * if we get here, then either the authorization_code has expired, * invalid, or used already */ return h .response({"error": "access_denied", "error_description": "Invalid, denied, or expired authorization code"}) .type("application/json") .code(401); } catch (err) { return h .response({"error": "access_denied", "error_description": "Invalid, denied, expired authorization code, or incorrect Basic authorization header"}) .type("application/json") .code(401); } }
javascript
{ "resource": "" }
q53349
__process_authorization_header_for_client
train
function __process_authorization_header_for_client(request_params) { return new Promise(async (resolve, reject) => { try { const client_account_id = await client_endpoint .client_registrar_module .get_client_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password); return resolve(request_params); } catch (err) { return reject(new Error("Unauthorized request")); } }); }
javascript
{ "resource": "" }
q53350
__process_authorization_header_for_user
train
function __process_authorization_header_for_user(request_params) { return new Promise(async (resolve, reject) => { try { const user_account_id = await user_info_endpoint .user_account_registrar_module .get_user_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password); return resolve(request_params); } catch (err) { return reject(err); } }); }
javascript
{ "resource": "" }
q53351
formatRequestErrors
train
function formatRequestErrors(request, errors) { const CONTEXT_BEFORE = 20; const CONTEXT_LENGTH = 60; const queryLines = request.getQueryString().split('\n'); return errors.map(({locations = [], message}, ii) => { const prefix = (ii + 1) + '. '; const indent = ' '.repeat(prefix.length); return ( prefix + message + '\n' + locations.map(({column, line}) => { const queryLine = queryLines[line - 1]; const offset = Math.min(column - 1, CONTEXT_BEFORE); return [ queryLine.substr(column - 1 - offset, CONTEXT_LENGTH), ' '.repeat(offset) + '^^^', ].map(messageLine => indent + messageLine).join('\n'); }).join('\n') ); }).join('\n'); }
javascript
{ "resource": "" }
q53352
jsonEncoded
train
function jsonEncoded(gw, callback){ var buffer = ''; var readlength = 0; var $error = false; gw.req.on('data', function (chunk) { if (readlength > gw.content.length){$error = true;} if (!$error) { readlength += chunk.length; buffer += chunk.toString('ascii'); } }); gw.req.on('end', function () { if ($error) { gw.error(400); } else { try { var params = JSON.parse(buffer); gw.content.params = params; for(var i=0,k=Object.keys(params),l=k.length;i<l;i++){ gw.params[k[i]]=params[k[i]]; } callback(); } catch (error) { gw.error(400); } } }); }
javascript
{ "resource": "" }
q53353
urlEncoded
train
function urlEncoded(gw, callback){ var buffer = ''; var readlength = 0; var $error = false; gw.req.on('data', function (chunk) { if (readlength > gw.content.length) {$error = true;} if (!$error) { readlength += chunk.length; buffer += chunk.toString('ascii'); } }); gw.req.on('end', function () { if ($error) { gw.error(400); } else { var params = gw.constructor.queryHeap(querystring.parse(buffer, '&', '=')); gw.content.params = params; for(var i=0,k=Object.keys(params),l=k.length;i<l;i++){ gw.params[k[i]]=params[k[i]]; } callback(); } }); }
javascript
{ "resource": "" }
q53354
multipartEncoded
train
function multipartEncoded(gw, callback){ var upload = new formidable.IncomingForm(); var files = {}; var fields = {}; gw.eventium.on('end',cleanTemp); upload.uploadDir = tempDirectory; upload.keepExtensions = true; upload.onPart = function(part) { if (part.filename!="") { upload.handlePart(part); } } upload .on('progress', function(bytesReceived, bytesExpected) { var percent_complete = (bytesReceived / bytesExpected) * 100; }) .on('error', function (error) {gw.error(500,error);}) .on('field', function (field, value) { if (fields[field]) { if (!Array.isArray(fields[field])) {fields[field]=[fields[field]];} fields[field].push(value); } else { fields[field]=value; } }) .on('file', function(field, file) { file.ext = file.name.replace(/^.*\./,''); if (fields[field]) { if(!Array.isArray(fields[field])){fields[field]=[fields[field]];} fields[field].push(file); } else { fields[field]=file; } if (files[field]) { if (!Array.isArray(files[field])) {files[field]=[files[field]];} files[field].push(file); } else { files[field]=file; } }) .on('end', function() { fields = gw.constructor.queryHeap(fields); gw.content.params = fields; for(var i=0,k=Object.keys(fields),l=k.length;i<l;i++){ gw.params[k[i]]=fields[k[i]]; } gw.files = files; callback(); }) ; upload.parse(gw.req); }
javascript
{ "resource": "" }
q53355
dimension
train
function dimension(cells) { var d = 0 , max = Math.max for(var i=0, il=cells.length; i<il; ++i) { d = max(d, cells[i].length) } return d-1 }
javascript
{ "resource": "" }
q53356
countVertices
train
function countVertices(cells) { var vc = -1 , max = Math.max for(var i=0, il=cells.length; i<il; ++i) { var c = cells[i] for(var j=0, jl=c.length; j<jl; ++j) { vc = max(vc, c[j]) } } return vc+1 }
javascript
{ "resource": "" }
q53357
cloneCells
train
function cloneCells(cells) { var ncells = new Array(cells.length) for(var i=0, il=cells.length; i<il; ++i) { ncells[i] = cells[i].slice(0) } return ncells }
javascript
{ "resource": "" }
q53358
compareCells
train
function compareCells(a, b) { var n = a.length , t = a.length - b.length , min = Math.min if(t) { return t } switch(n) { case 0: return 0; case 1: return a[0] - b[0]; case 2: var d = a[0]+a[1]-b[0]-b[1] if(d) { return d } return min(a[0],a[1]) - min(b[0],b[1]) case 3: var l1 = a[0]+a[1] , m1 = b[0]+b[1] d = l1+a[2] - (m1+b[2]) if(d) { return d } var l0 = min(a[0], a[1]) , m0 = min(b[0], b[1]) , d = min(l0, a[2]) - min(m0, b[2]) if(d) { return d } return min(l0+a[2], l1) - min(m0+b[2], m1) //TODO: Maybe optimize n=4 as well? default: var as = a.slice(0) as.sort() var bs = b.slice(0) bs.sort() for(var i=0; i<n; ++i) { t = as[i] - bs[i] if(t) { return t } } return 0 } }
javascript
{ "resource": "" }
q53359
normalize
train
function normalize(cells, attr) { if(attr) { var len = cells.length var zipped = new Array(len) for(var i=0; i<len; ++i) { zipped[i] = [cells[i], attr[i]] } zipped.sort(compareZipped) for(var i=0; i<len; ++i) { cells[i] = zipped[i][0] attr[i] = zipped[i][1] } return cells } else { cells.sort(compareCells) return cells } }
javascript
{ "resource": "" }
q53360
unique
train
function unique(cells) { if(cells.length === 0) { return [] } var ptr = 1 , len = cells.length for(var i=1; i<len; ++i) { var a = cells[i] if(compareCells(a, cells[i-1])) { if(i === ptr) { ptr++ continue } cells[ptr++] = a } } cells.length = ptr return cells }
javascript
{ "resource": "" }
q53361
findCell
train
function findCell(cells, c) { var lo = 0 , hi = cells.length-1 , r = -1 while (lo <= hi) { var mid = (lo + hi) >> 1 , s = compareCells(cells[mid], c) if(s <= 0) { if(s === 0) { r = mid } lo = mid + 1 } else if(s > 0) { hi = mid - 1 } } return r }
javascript
{ "resource": "" }
q53362
incidence
train
function incidence(from_cells, to_cells) { var index = new Array(from_cells.length) for(var i=0, il=index.length; i<il; ++i) { index[i] = [] } var b = [] for(var i=0, n=to_cells.length; i<n; ++i) { var c = to_cells[i] var cl = c.length for(var k=1, kn=(1<<cl); k<kn; ++k) { b.length = bits.popCount(k) var l = 0 for(var j=0; j<cl; ++j) { if(k & (1<<j)) { b[l++] = c[j] } } var idx=findCell(from_cells, b) if(idx < 0) { continue } while(true) { index[idx++].push(i) if(idx >= from_cells.length || compareCells(from_cells[idx], b) !== 0) { break } } } } return index }
javascript
{ "resource": "" }
q53363
dual
train
function dual(cells, vertex_count) { if(!vertex_count) { return incidence(unique(skeleton(cells, 0)), cells, 0) } var res = new Array(vertex_count) for(var i=0; i<vertex_count; ++i) { res[i] = [] } for(var i=0, len=cells.length; i<len; ++i) { var c = cells[i] for(var j=0, cl=c.length; j<cl; ++j) { res[c[j]].push(i) } } return res }
javascript
{ "resource": "" }
q53364
explode
train
function explode(cells) { var result = [] for(var i=0, il=cells.length; i<il; ++i) { var c = cells[i] , cl = c.length|0 for(var j=1, jl=(1<<cl); j<jl; ++j) { var b = [] for(var k=0; k<cl; ++k) { if((j >>> k) & 1) { b.push(c[k]) } } result.push(b) } } return normalize(result) }
javascript
{ "resource": "" }
q53365
skeleton
train
function skeleton(cells, n) { if(n < 0) { return [] } var result = [] , k0 = (1<<(n+1))-1 for(var i=0; i<cells.length; ++i) { var c = cells[i] for(var k=k0; k<(1<<c.length); k=bits.nextCombination(k)) { var b = new Array(n+1) , l = 0 for(var j=0; j<c.length; ++j) { if(k & (1<<j)) { b[l++] = c[j] } } result.push(b) } } return normalize(result) }
javascript
{ "resource": "" }
q53366
boundary
train
function boundary(cells) { var res = [] for(var i=0,il=cells.length; i<il; ++i) { var c = cells[i] for(var j=0,cl=c.length; j<cl; ++j) { var b = new Array(c.length-1) for(var k=0, l=0; k<cl; ++k) { if(k !== j) { b[l++] = c[k] } } res.push(b) } } return normalize(res) }
javascript
{ "resource": "" }
q53367
connectedComponents_dense
train
function connectedComponents_dense(cells, vertex_count) { var labels = new UnionFind(vertex_count) for(var i=0; i<cells.length; ++i) { var c = cells[i] for(var j=0; j<c.length; ++j) { for(var k=j+1; k<c.length; ++k) { labels.link(c[j], c[k]) } } } var components = [] , component_labels = labels.ranks for(var i=0; i<component_labels.length; ++i) { component_labels[i] = -1 } for(var i=0; i<cells.length; ++i) { var l = labels.find(cells[i][0]) if(component_labels[l] < 0) { component_labels[l] = components.length components.push([cells[i].slice(0)]) } else { components[component_labels[l]].push(cells[i].slice(0)) } } return components }
javascript
{ "resource": "" }
q53368
connectedComponents_sparse
train
function connectedComponents_sparse(cells) { var vertices = unique(normalize(skeleton(cells, 0))) , labels = new UnionFind(vertices.length) for(var i=0; i<cells.length; ++i) { var c = cells[i] for(var j=0; j<c.length; ++j) { var vj = findCell(vertices, [c[j]]) for(var k=j+1; k<c.length; ++k) { labels.link(vj, findCell(vertices, [c[k]])) } } } var components = [] , component_labels = labels.ranks for(var i=0; i<component_labels.length; ++i) { component_labels[i] = -1 } for(var i=0; i<cells.length; ++i) { var l = labels.find(findCell(vertices, [cells[i][0]])); if(component_labels[l] < 0) { component_labels[l] = components.length components.push([cells[i].slice(0)]) } else { components[component_labels[l]].push(cells[i].slice(0)) } } return components }
javascript
{ "resource": "" }
q53369
Task
train
function Task(entry) { if (!(this instanceof Task)) { return new Task(entry); } this.called = 0; this.now = this.calledAt = hrTime(); if (resolutionDivisor !== DEFAULT_RESOLUTION) { entry.time = ~~(entry.time * (DEFAULT_RESOLUTION / resolutionDivisor)); } // Side table property definitions this.isRunnable = true; this.later = this.now + entry.time; this.task = entry.task; this.type = entry.type; this.time = entry.time; if (this.later > gLast) { gLast = this.later; } if (!queue[this.later]) { queue[this.later] = []; } // console.log( entry.later, this ); queue[this.later].push(this); }
javascript
{ "resource": "" }
q53370
cloneObj
train
function cloneObj(a,b) { Object.keys(b).forEach(function(k) { a[k] = b[k]; }); return a; }
javascript
{ "resource": "" }
q53371
train
function (element) { var codeStyles = getStyles(element); var whiteSpace = codeStyles['white-space']; if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') { var codeElement = element.querySelector('code'); var lineNumbersWrapper = element.querySelector('.line-numbers-rows'); var lineNumberSizer = element.querySelector('.line-numbers-sizer'); var codeLines = element.textContent.split('\n'); if (!lineNumberSizer) { lineNumberSizer = document.createElement('span'); lineNumberSizer.className = 'line-numbers-sizer'; codeElement.appendChild(lineNumberSizer); } lineNumberSizer.style.display = 'block'; codeLines.forEach(function (line, lineNumber) { lineNumberSizer.textContent = line || '\n'; var lineSize = lineNumberSizer.getBoundingClientRect().height; lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px'; }); lineNumberSizer.textContent = ''; lineNumberSizer.style.display = 'none'; } }
javascript
{ "resource": "" }
q53372
listenForWorkerResults
train
function listenForWorkerResults() { chessWorker.addEventListener('message', (event) => { const gameId = event.data.reqid.gameRootMessage; const { ply } = event.data.reqid; if (event.data.topic === 'dests') { const destsMapKey = getDestsKey(gameId, ply); const awaitingDestsObs = get(awaitingWorkerResponses, destsMapKey); if (awaitingDestsObs) { const validDests = event.data.payload.dests; awaitingDestsObs.set(validDests); delete awaitingWorkerResponses[destsMapKey]; } } else if (event.data.topic === 'threefoldTest') { const canDrawKey = getDrawKey(gameId, ply); const awaitingCanDraw = get(awaitingWorkerResponses, canDrawKey); if (awaitingCanDraw) { const canClaimDraw = event.data.payload.threefoldRepetition; awaitingCanDraw.set(canClaimDraw); delete awaitingWorkerResponses[canDrawKey]; } } }); }
javascript
{ "resource": "" }
q53373
wrap
train
function wrap(set) { return function (fn, time /* , ...args */) { var boundArgs = arguments.length > 2; var args = boundArgs ? slice.call(arguments, 2) : false; return set(boundArgs ? function () { // eslint-disable-next-line no-new-func (typeof fn == 'function' ? fn : Function(fn)).apply(this, args); } : fn, time); }; }
javascript
{ "resource": "" }
q53374
train
function(key_or_new_store, value) { if (arguments.length === 1) { // replace the whole store let new_store = key_or_new_store for (let k in new_store) { store.set(k, new_store[k]) } return } let key = key_or_new_store if (!store._store.hasOwnProperty(key)) { // use hasOwnProperty for better performance (entrie prototype chain is not traversed) throw `cannot create new key after initialization (attempted to create ${key})` } let oldval = store._store[key] checkTypeMatch(key, oldval, value) if (valueHasChanged(oldval, value)) { let update_store = store._runUserMiddleware(key, oldval, value) if (update_store) { store._store[key] = value store._publishChangeToSubscribers(key, oldval, value) } } }
javascript
{ "resource": "" }
q53375
train
function(key, oldval, value) { if (store._changed_keys.indexOf(key) === -1) { store._changed_keys.push(key) } // suppress active timeout (if any) if (store._debounce_timeout) { store._clearDebounceTimeout() } if (store.options.debounce_ms) { // delay event emission and set new timeout id store._debounce_timeout = setTimeout(store._publish, store.options.debounce_ms) } else { // publish immediately store._publish() } }
javascript
{ "resource": "" }
q53376
train
function(key) { if (!store._store_created) { throw 'cannot get store because is has not been created' } if (arguments.length === 0) { // return the whole store if (store.options.immutable) { return Object.assign({}, store._store) // copy entire store by value } else { return store._store // return reference to store } } else if (arguments.length > 1) { console.error('unexpected number of arguments') return } if (!store._store.hasOwnProperty(key)) { throw `attempted to access key that was not set during initialization: ${key}` } let ref = store._store[key] if (store.options.immutable) { return copyByValue(ref) } else { // return the reference return ref } }
javascript
{ "resource": "" }
q53377
train
function() { const changed_keys = store._changed_keys if (changed_keys.length === 0) { console.error('no keys were changed, yet we are trying to publish a store change') return } // make sure _changed_keys is reset before executing callbacks // (if callbacks modify state, the list of keys the callback changed would be wiped out) store._changed_keys = [] store._clearDebounceTimeout() store._callback_objs.forEach(obj => obj.callback(changed_keys)) }
javascript
{ "resource": "" }
q53378
chessAppIsVisible
train
function chessAppIsVisible() { const topLevelElementArr = document.getElementsByClassName('ssb-chess-container'); if (!topLevelElementArr || topLevelElementArr.length <= 0) { return false; } const element = topLevelElementArr[0]; return document.hasFocus() && isVisible(element); }
javascript
{ "resource": "" }
q53379
_callback
train
function _callback(changed_keys) { if (intersection(keys_to_watch_for_changes, changed_keys).length) { // only update the state if a key we care about has changed var state_update_obj = {}; keys_to_watch_for_changes.forEach(function (k) { return state_update_obj[k] = store._store[k]; }); this.setState(state_update_obj); // if some other custom callback is required by the component // call that function as well if (additonal_callback) { additonal_callback(changed_keys); } } }
javascript
{ "resource": "" }
q53380
getUnwatchedKeys
train
function getUnwatchedKeys() { var arr1 = Object.keys(store._store), arr2 = Object.keys(store._key_to_watcher_subscriptions); return arr1.filter(function (i) { return arr2.indexOf(i) === -1; }); }
javascript
{ "resource": "" }
q53381
collectResources
train
function collectResources(a, obj, tagName) { Array.prototype .forEach .call(a.ownerDocument.getElementsByTagName(tagName), function(r) { // Get canonical URL a.href = r.currentSrc || r.src || r.getAttribute("xlink:href") || r.href; // only get external resource if (a.href.match(/^https?:\/\//)) { obj[a.href] = r; } }); }
javascript
{ "resource": "" }
q53382
cssFilesToStyleTag
train
function cssFilesToStyleTag(dom) { const rootDir = `${__dirname}/`; const styles = m('div', {}, cssFiles.map(file => m('link', { rel: 'stylesheet', href: rootDir + file }))); m.render(dom, styles); }
javascript
{ "resource": "" }
q53383
train
function ( type, time ) { if ( type == 'easeInQuad' ) return time * time; // accelerating from zero velocity if ( type == 'easeOutQuad' ) return time * (2 - time); // decelerating to zero velocity if ( type == 'easeInOutQuad' ) return time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration if ( type == 'easeInCubic' ) return time * time * time; // accelerating from zero velocity if ( type == 'easeOutCubic' ) return (--time) * time * time + 1; // decelerating to zero velocity if ( type == 'easeInOutCubic' ) return time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration if ( type == 'easeInQuart' ) return time * time * time * time; // accelerating from zero velocity if ( type == 'easeOutQuart' ) return 1 - (--time) * time * time * time; // decelerating to zero velocity if ( type == 'easeInOutQuart' ) return time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration if ( type == 'easeInQuint' ) return time * time * time * time * time; // accelerating from zero velocity if ( type == 'easeOutQuint' ) return 1 + (--time) * time * time * time * time; // decelerating to zero velocity if ( type == 'easeInOutQuint' ) return time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration return time; // no easing, no acceleration }
javascript
{ "resource": "" }
q53384
train
function ( anchor, headerHeight, offset ) { var location = 0; if (anchor.offsetParent) { do { location += anchor.offsetTop; anchor = anchor.offsetParent; } while (anchor); } location = location - headerHeight - offset; if ( location >= 0 ) { return location; } else { return 0; } }
javascript
{ "resource": "" }
q53385
train
function () { return Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ); }
javascript
{ "resource": "" }
q53386
train
function ( anchor, url ) { if ( (url === true || url === 'true') && history.pushState ) { history.pushState( {pos:anchor.id}, '', anchor ); } }
javascript
{ "resource": "" }
q53387
train
function () { timeLapsed += 16; percentage = ( timeLapsed / speed ); percentage = ( percentage > 1 ) ? 1 : percentage; position = startLocation + ( distance * _easingPattern(easing, percentage) ); window.scrollTo( 0, Math.floor(position) ); _stopAnimateScroll(position, endLocation, animationInterval); }
javascript
{ "resource": "" }
q53388
train
function ( options ) { // Feature test before initializing if ( 'querySelector' in document && 'addEventListener' in window && Array.prototype.forEach ) { // Selectors and variables options = _mergeObjects( _defaults, options || {} ); // Merge user options with defaults var toggles = document.querySelectorAll('[data-scroll]'); // Get smooth scroll toggles // When a toggle is clicked, run the click handler Array.prototype.forEach.call(toggles, function (toggle, index) { toggle.addEventListener('click', animateScroll.bind( null, toggle, toggle.getAttribute('href'), options ), false); }); } }
javascript
{ "resource": "" }
q53389
report
train
function report(node) { const name = node.key context.report({ node, loc: node.loc, messageId: "duplicate", data: { name }, }) }
javascript
{ "resource": "" }
q53390
groupByName
train
function groupByName(attrs) { const attributes = new Map() for (const node of attrs) { const name = node.key const list = attributes.get(name) || (() => { const a = [] attributes.set(name, a) return a })() list.push(node) } return attributes }
javascript
{ "resource": "" }
q53391
equalNode
train
function equalNode(n1, n2) { return ( n1.type === n2.type && n1.range[0] === n2.range[0] && n1.range[1] === n2.range[1] ) }
javascript
{ "resource": "" }
q53392
validateNameGroup
train
function validateNameGroup(nodes, _name) { if (nodes.length <= 1) { return } for (const target of nodes) { const node = microTemplateService.getBranchProcessedHtmlNode( target, sourceCode ) || target const startTag = node.parent const hasDup = startTag.attributes .concat(startTag.ignoredAttributes) .filter(attr => !equalNode(attr, node)) .some(attr => microTemplateService.findToken( nodes, n => n.type === attr.type && n.range[0] === attr.range[0] && n.range[1] === attr.range[1] ) ) if (hasDup) { report(target) } } }
javascript
{ "resource": "" }
q53393
validateAttrs
train
function validateAttrs(attrs) { const attributes = groupByName(attrs) attributes.forEach((nodes, name) => { validateNameGroup(nodes, name) }) }
javascript
{ "resource": "" }
q53394
readConfigs
train
function readConfigs() { const configsRoot = path.resolve(__dirname, "../../lib/configs") const result = fs.readdirSync(configsRoot) const configs = [] for (const name of result) { const configName = name.replace(/\.js$/u, "") const configId = `plugin:lodash-template/${configName}` const configPath = require.resolve(path.join(configsRoot, name)) const config = require(configPath) configs.push({ name: configName, configId, config, path: configPath, }) } return configs }
javascript
{ "resource": "" }
q53395
getActualLineIndentText
train
function getActualLineIndentText(line) { let actualText = actualLineIndentTexts.get(line) if (actualText === undefined) { const lineText = getLineText(line) const index = lineText.search(/\S/u) if (index >= 0) { actualText = lineText.slice(0, index) } else { actualText = lineText } actualLineIndentTexts.set(line, actualText) } return actualText }
javascript
{ "resource": "" }
q53396
getTopLevelIndentByTemplateTag
train
function getTopLevelIndentByTemplateTag(templateTag) { const baseIndentText = getActualLineIndentText( templateTag.loc.start.line ) return new ExpectedIndent( baseIndentText, options.indentSize * options.startIndent ) }
javascript
{ "resource": "" }
q53397
setOffsetToNodeList
train
function setOffsetToNodeList(nodeList, leftToken, offset, baseToken) { for (const t of genCollectNodeList(nodeList, leftToken, null)) { setOffsetToToken(t, offset, baseToken) } }
javascript
{ "resource": "" }
q53398
inTemplateTag
train
function inTemplateTag(line) { if (line <= 1) { return false } const lineStartIndex = sourceCode.getIndexFromLoc({ line, column: 0, }) return microTemplateService.inTemplateTag(lineStartIndex - 1) }
javascript
{ "resource": "" }
q53399
validateBaseIndent
train
function validateBaseIndent(line, actualText, expectedIndent) { const expectedBaseIndentText = expectedIndent.baseIndentText if ( expectedBaseIndentText && (actualText.length < expectedBaseIndentText.length || !actualText.startsWith(expectedBaseIndentText)) ) { context.report({ loc: { start: { line, column: 0 }, end: { line, column: actualText.length, }, }, messageId: actualText ? "unexpectedBaseIndentation" : "missingBaseIndentation", data: { expected: JSON.stringify(expectedBaseIndentText), actual: actualText ? JSON.stringify( actualText.slice( 0, expectedBaseIndentText.length ) ) : "", }, fix: defineFix(line, actualText, expectedIndent), }) return false } return true }
javascript
{ "resource": "" }