_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q52200
train
function(startPoint, endPoint) { startPoint = vector.create(startPoint).to3D(); endPoint = vector.create(endPoint).to3D(); if (startPoint === null || endPoint === null) { return null; } this.line = line.create(startPoint, endPoint.subtract(startPoint)); ...
javascript
{ "resource": "" }
q52201
createCentroids
train
function createCentroids(k) { var Centroid = []; var maxes = this.Observations.maxColumns(); //console.log(maxes); for(var i = 1; i <= k; i++) { var centroid = []; for(var j = 1; j <= this.Observations.cols(); j++) ...
javascript
{ "resource": "" }
q52202
distanceFrom
train
function distanceFrom(Centroids) { var distances = []; for(var i = 1; i <= this.Observations.rows(); i++) { var distance = []; for(var j = 1; j <= Centroids.rows(); j++) { distance.push(this.Observations.row(i).distanceFro...
javascript
{ "resource": "" }
q52203
cluster
train
function cluster(k) { var Centroids = this.createCentroids(k); var LastDistances = Matrix$d.Zero(this.Observations.rows(), this.Observations.cols()); var Distances = this.distanceFrom(Centroids); var Groups; while(!(LastDistances.eql(Dista...
javascript
{ "resource": "" }
q52204
train
function (str) { var allPairs = [], pairs; var words = str.split(/\s+/); for (var i = 0; i < words.length; i++) { pairs = letterPairs(words[i]); allPairs.push.apply(allPairs, pairs); } return allPairs; }
javascript
{ "resource": "" }
q52205
train
function (str1, str2) { var sanitized_str1 = sanitize(str1); var sanitized_str2 = sanitize(str2); var pairs1 = wordLetterPairs(sanitized_str1); var pairs2 = wordLetterPairs(sanitized_str2); var intersection = 0, union = pairs1.length + pairs2.length;...
javascript
{ "resource": "" }
q52206
train
function(tokens) { if(typeof tokens === "string") { tokens = [tokens]; } var results = []; var rule_count = rules$3.length; var num_tokens = tokens.length; var i, token, r, rule; ...
javascript
{ "resource": "" }
q52207
StandardScalerTransforms
train
function StandardScalerTransforms(vector = [], nan_value = -1, return_nan=false) { const average = avg(vector); const standard_dev = sd(vector); const maximum = max(vector); const minimum = min(vector); const scale = (z) => { const scaledValue = (z - average) / standard_dev; if (isNaN(scaledVal...
javascript
{ "resource": "" }
q52208
assocationRuleLearning
train
function assocationRuleLearning(transactions =[], options) { return new Promise((resolve, reject) => { try { const config = Object.assign({}, { support: 0.4, minLength: 2, summary: true, valuesMap: new Map(), }, options); const fpgrowth = new FPGrowth(con...
javascript
{ "resource": "" }
q52209
cross_validate_score
train
function cross_validate_score(options = {}) { const config = Object.assign({}, { // classifier, // regression, // dataset, // testingset, dependentFeatures: [['X', ], ], independentFeatures: [['Y', ], ], // random_state, folds: 10, accuracy: 'standardError', use_trai...
javascript
{ "resource": "" }
q52210
grid_search
train
function grid_search(options = {}) { const config = Object.assign({}, { return_parameters: false, compare_score:'mean', sortAccuracyScore:'desc', parameters: {}, }, options); const regressor = config.regression; const classification = config.classifier; const sortAccuracyScore = (!opt...
javascript
{ "resource": "" }
q52211
epipeError
train
function epipeError(err) { if (err.code === 'EPIPE' || err.errno === 32) return process.exit; if (process.stdout.listeners('error').length <= 1) { process.stdout.removeAllListeners(); process.stdout.emit('error', err); process.stdout.on('error', epipeError); } }
javascript
{ "resource": "" }
q52212
train
function (source, target, isExternal) { // Clone source var pkg = JSON.parse(JSON.stringify(source)); // Validation of source package. ["name", "description"].forEach(function (name) { if (!pkg[name]) { throw new Error("Source object missing field: " + name); } }); var nameRe = new RegExp("(...
javascript
{ "resource": "" }
q52213
train
function (value) { var o = this.options, min = o.min, max = o.max; this.bar.children().attr({ "aria-valuenow": value }); if (o.sliderType == "range") { var handles = this._handles(); handles.eq(0).attr({ "aria-valuemin": min }); h...
javascript
{ "resource": "" }
q52214
train
function () { var _data = this._dataElement().data("bind"); if (typeof _data == "string" && typeof ko == "object") { var _vm = ko.dataFor(this._dataElement()[0]); if (typeof _vm == "undefined") return true; var _all = _data.split(","), _handle...
javascript
{ "resource": "" }
q52215
train
function () { if (typeof angular == "object" && typeof angular.element == "function") { this._ngName = this._dataElement().attr("ng-model"); if (typeof this._ngName == "string") { this._isAngular = true; var that = this; this._scop...
javascript
{ "resource": "" }
q52216
CreateRoundSlider
train
function CreateRoundSlider(options, args) { for (var i = 0; i < this.length; i++) { var that = this[i], instance = $.data(that, pluginName); if (!instance) { var _this = new RoundSlider(that, options); _this._saveInstanceOnElement(); ...
javascript
{ "resource": "" }
q52217
filter
train
function filter(rows = [], filters = [], filterText, columns) { let filteredRows = rows.slice(0); if (filters.length === 0 && !filterText) { return filteredRows; } const textFilters = [ ...(filterText ? [filterText.toLowerCase()] : []), ...filters.filter(f => f.textFilter).map(f => f.value), ]; ...
javascript
{ "resource": "" }
q52218
train
function (el) { if (isMSIE8) { // Fallback for MSIE8, will most probably fail on edge cases return [ 0, 0, el.offsetWidth, el.offsetHeight]; } var styles = window.getComputedStyle(el); // getComputedStyle() should return values already in pixels, so using parseInt() // is not as much as a hack as i...
javascript
{ "resource": "" }
q52219
loadUid
train
function loadUid (cb) { // if we're not in unsafe-perm mode, then figure out who // to run stuff as. Do this first, to support `npm update npm -g` if (!this.get("unsafe-perm")) { getUid(this.get("user"), this.get("group"), cb) } else { process.nextTick(cb) } }
javascript
{ "resource": "" }
q52220
computeExpires
train
function computeExpires(str) { const lastCh = str.charAt(str.length - 1); const value = parseInt(str, 10); let expires = new Date(); switch (lastCh) { case 'Y': expires.setFullYear(expires.getFullYear() + value); break; case 'M': expires.setMonth(expires.getMonth() + value); break; case 'D': expire...
javascript
{ "resource": "" }
q52221
convert
train
function convert(opts) { let res = ''; // eslint-disable-next-line for (const key in opts) { if (hasOwn(opts, key)) { if (/^expires$/i.test(key)) { let expires = opts[key]; if (typeof expires !== 'object') { expires += typeof expires === 'number' ? 'D' : ''; expires...
javascript
{ "resource": "" }
q52222
isEnabled
train
function isEnabled() { const key = '@key@'; const value = '1'; const re = new RegExp(`(?:^|; )${key}=${value}(?:;|$)`); document.cookie = `${key}=${value}`; const enabled = re.test(document.cookie); if (enabled) { // eslint-disable-next-line remove(key); } return enabled; }
javascript
{ "resource": "" }
q52223
get
train
function get(key, decoder = decodeURIComponent) { if ((typeof key !== 'string') || !key) { return null; } const reKey = new RegExp(`(?:^|; )${escapeRe(key)}(?:=([^;]*))?(?:;|$)`); const match = reKey.exec(document.cookie); if (match === null) { return null; } return typeof decoder === 'function...
javascript
{ "resource": "" }
q52224
getAll
train
function getAll(decoder = decodeURIComponent) { const reKey = /(?:^|; )([^=]+?)(?:=([^;]*))?(?:;|$)/g; const cookies = {}; let match; /* eslint-disable no-cond-assign */ while ((match = reKey.exec(document.cookie))) { reKey.lastIndex = (match.index + match.length) - 1; cookies[match[1]] = typeof deco...
javascript
{ "resource": "" }
q52225
remove
train
function remove(key, options) { let opts = { expires: -1 }; if (options) { opts = { ...options, ...opts }; } return set(key, 'a', opts); }
javascript
{ "resource": "" }
q52226
train
function(subject) { if (this.isScalar() && this.hasSearch()) { var search = this.getSearch(); return this.highlightChildren(subject, search); } return this.props.children; }
javascript
{ "resource": "" }
q52227
train
function() { if (this.props.search instanceof RegExp) { return this.props.search; } var flags = ''; if (!this.props.caseSensitive) { flags +='i'; } var search = this.props.search; if (typeof this.props.search === 'string') { search = escapeStringRegexp(search); } ...
javascript
{ "resource": "" }
q52228
train
function(subject, search) { var matches = search.exec(subject); if (matches) { return { first: matches.index, last: matches.index + matches[0].length }; } }
javascript
{ "resource": "" }
q52229
train
function(subject, search) { var children = []; var remaining = subject; while (remaining) { var remainingCleaned = (this.props.ignoreDiacritics ? removeDiacritics(remaining, this.props.diacriticsBlacklist) : remaining ); if (!search.test(remainingCleaned)) { child...
javascript
{ "resource": "" }
q52230
train
function(string) { this.count++; return React.createElement(this.props.matchElement, { key: this.count, className: this.props.matchClass, style: this.props.matchStyle, children: string }); }
javascript
{ "resource": "" }
q52231
train
function(node, e){ if (node){ var currMousePos = e.position || e.cyPosition; var topLeft = { x: (node.position("x") - node.width() / 2 - parseFloat(node.css('padding-left'))), y: (node.position("y") - node.height() / 2 - parseFloat(node.css('padding-top')))}; var bottomRight = { x: (node.p...
javascript
{ "resource": "" }
q52232
evalOptions
train
function evalOptions(options) { var animate = typeof options.animate === 'function' ? options.animate.call() : options.animate; var fisheye = typeof options.fisheye === 'function' ? options.fisheye.call() : options.fisheye; options.animate = animate; options.fisheye = fisheye; }
javascript
{ "resource": "" }
q52233
train
function (nodes, options) { // If there is just one node to expand we need to animate for fisheye view, but if there are more then one node we do not if (nodes.length === 1) { var node = nodes[0]; if (node._private.data.collapsedChildren != null) { // Expand the given node the third p...
javascript
{ "resource": "" }
q52234
train
function (nodes, options) { /* * In collapse operation there is no fisheye view to be applied so there is no animation to be destroyed here. We can do this * in a batch. */ cy.startBatch(); this.simpleCollapseGivenNodes(nodes, options); cy.endBatch(); nodes.trigger("position"); // ...
javascript
{ "resource": "" }
q52235
train
function (root) { var children = root.children(); for (var i = 0; i < children.length; i++) { var node = children[i]; this.collapseBottomUp(node); } //If the root is a compound node to be collapsed then collapse it if (root.data("collapse") && root.children().length > 0) { this.col...
javascript
{ "resource": "" }
q52236
train
function (root, applyFishEyeViewToEachNode) { if (root.data("expand") && root._private.data.collapsedChildren != null) { // Expand the root and unmark its expand data to specify that it is no more to be expanded this.expandNode(root, applyFishEyeViewToEachNode); root.removeData("expand"); } ...
javascript
{ "resource": "" }
q52237
train
function (renderedPosition) { var pan = cy.pan(); var zoom = cy.zoom(); var x = (renderedPosition.x - pan.x) / zoom; var y = (renderedPosition.y - pan.y) / zoom; return { x: x, y: y }; }
javascript
{ "resource": "" }
q52238
train
function (node) { if (node._private.data.collapsedChildren == null) { node.data('position-before-collapse', { x: node.position().x, y: node.position().y }); node.data('size-before-collapse', { w: node.outerWidth(), h: node.outerHeight() }); var childre...
javascript
{ "resource": "" }
q52239
train
function(node, collapsedChildren){ var children = node.data('collapsedChildren'); var i; for (i=0; i < children.length; i++){ if (children[i].data('collapsedChildren')){ collapsedChildren = collapsedChildren.union(this.getCollapsedChildrenRecursively(children[i], collapsedChildren)); } ...
javascript
{ "resource": "" }
q52240
train
function(moduleName, moduleClosure) { var wm = this; // GLOBAL.WebModule // https://github.com/uupaa/WebModule/wiki/SwitchModulePattern var alias = wm[moduleName] ? (moduleName + "_") : moduleName; if (!wm[alias]) { // secondary module already exported -> skip wm[alias] = m...
javascript
{ "resource": "" }
q52241
train
function(moduleName, // @arg ModuleNameString moduleClosure) { // @arg JavaScriptCodeString // @ret ModuleObject var wm = this; // GLOBAL.WebModule // https://github.com/uupaa/WebModule/wiki/SwitchModulePattern var alias = wm[mod...
javascript
{ "resource": "" }
q52242
buffer2ArrayBuffer
train
function buffer2ArrayBuffer(buffer) { var buf = new ArrayBuffer(buffer.length); var bufView = new Uint8Array(buf); for (var i = 0; i < buffer.length; i++) { bufView[i] = buffer[i]; } return buf; }
javascript
{ "resource": "" }
q52243
batchLoaderFunc
train
function batchLoaderFunc(graphqlType, serializeRecordKey, getRecords) { return keys => getRecords(keys) .then(resultArray => getResultsByKey( keys, extractAllItems(resultArray), serializeRecordKey, graphqlType, { onError: logger } ) ); }
javascript
{ "resource": "" }
q52244
extend
train
function extend(target, source, modify) { var result = target ? modify ? target : extend({}, target, true) : {}; if (!source) return result; for (var key in source) { if (source.hasOwnProperty(key) && source[key] !== undefined) { result[key] = source[key]; } } return resu...
javascript
{ "resource": "" }
q52245
extractAllItems
train
function extractAllItems (result) { if (!result) return null; if (!Array.isArray(result)) result = ('data' in result) ? result.data : result; if (!result) return null; if (!Array.isArray(result)) result = [result]; return result; }
javascript
{ "resource": "" }
q52246
extractFirstItem
train
function extractFirstItem (result) { const data = extractAllItems(result); if (!data) return null; if (data.length > 1) throw new Error(`service.find expected 0 or 1 objects, not ${data.length}. (extractFirstItem)`); return data.length ? data[0] : null; }
javascript
{ "resource": "" }
q52247
checkDisplay
train
function checkDisplay () { var myPermissions = self.allProperties[resizeListenerId] // JSON.parse(el.dataset.responsives) var curWidth = window.innerWidth var initial = el.dataset.initialDisplay ? el.dataset.initialDisplay : '' var parameters = self._rPermissions[binding.arg] for (let i in...
javascript
{ "resource": "" }
q52248
train
function (el, binding, vnode) { let resizeListenerId = el.dataset.responsives delete self.resizeListeners[resizeListenerId] }
javascript
{ "resource": "" }
q52249
htmlDecode
train
function htmlDecode(input) { if (input === " ") return input; const doc = new DOMParser().parseFromString(input.replace(/<[^>]+>/g, ""), "text/html"); return doc.documentElement.textContent; }
javascript
{ "resource": "" }
q52250
train
function() { this.id = 'jq-signature-canvas-' + (++idCounter); // Set up the canvas this.$canvas = $(canvasFixture).appendTo(this.$element); this.$canvas.attr({ width: this.settings.width, height: this.settings.height }); this.$canvas.css({ boxSizing: 'border-bo...
javascript
{ "resource": "" }
q52251
train
function (e) { this.drawing = true; this.lastPos = this.currentPos = this._getPosition(e); // Prevent scrolling, etc $('body').css('overflow', 'hidden'); e.preventDefault(); }
javascript
{ "resource": "" }
q52252
train
function (e) { this.drawing = false; // Trigger a change event var changedEvent = $.Event('jq.signature.changed'); this.$element.trigger(changedEvent); // Allow scrolling again $('body').css('overflow', 'auto'); e.preventDefault(); }
javascript
{ "resource": "" }
q52253
train
function() { if (this.drawing) { this.ctx.beginPath(); this.ctx.moveTo(this.lastPos.x, this.lastPos.y); this.ctx.lineTo(this.currentPos.x, this.currentPos.y); this.ctx.stroke(); this.lastPos = this.currentPos; } }
javascript
{ "resource": "" }
q52254
train
function() { this.ctx = this.canvas.getContext("2d"); this.ctx.strokeStyle = this.settings.lineColor; this.ctx.lineWidth = this.settings.lineWidth; }
javascript
{ "resource": "" }
q52255
read
train
function read (path, options) { return parse(fs.createReadStream(path, options), Object.assign({}, options, { ndjson: false })) }
javascript
{ "resource": "" }
q52256
write
train
function write (path, data, options) { const Promise = promise(options) return new Promise((resolve, reject) => { streamify(data, options) .pipe(fs.createWriteStream(path, options)) .on('finish', () => { resolve() }) .on('error', reject) .on('dataError', reject) }) }
javascript
{ "resource": "" }
q52257
stringify
train
function stringify (data, options) { const json = [] const Promise = promise(options) const stream = streamify(data, options) let resolve, reject stream.on('data', read) stream.on('end', end) stream.on('error', error) stream.on('dataError', error) return new Promise((res, rej) => { resolve = re...
javascript
{ "resource": "" }
q52258
unpipe
train
function unpipe (callback, options) { check.assert.function(callback, 'Invalid callback argument') const jsonstream = new stream.PassThrough() parse(jsonstream, Object.assign({}, options, { ndjson: false })) .then(data => callback(null, data)) .catch(error => callback(error)) return jsonstream }
javascript
{ "resource": "" }
q52259
loadImplementation
train
function loadImplementation(implementation){ var impl = null if(shouldPreferGlobalPromise(implementation)){ // if no implementation or env specified use global.Promise impl = { Promise: global.Promise, implementation: 'global.Promise' } } else if(implementation){ // if implementation ...
javascript
{ "resource": "" }
q52260
shouldPreferGlobalPromise
train
function shouldPreferGlobalPromise(implementation){ if(implementation){ return implementation === 'global.Promise' } else if(typeof global.Promise !== 'undefined'){ // Load global promise if implementation not specified // Versions < 0.11 did not have global Promise // Do not use for version < 0.12 ...
javascript
{ "resource": "" }
q52261
tryAutoDetect
train
function tryAutoDetect(){ var libs = [ "es6-promise", "promise", "native-promise-only", "bluebird", "rsvp", "when", "q", "pinkie", "lie", "vow"] var i = 0, len = libs.length for(; i < len; i++){ try { return loadImplementation(libs[i]) } ca...
javascript
{ "resource": "" }
q52262
Request
train
function Request(url, options) { if (!url) { throw new Error('URL must in mandatory to initialize Request object'); } if (!options.method) { throw new Error('Cannot execute HTTP request without specifying method'); } this.url = url; this.method = options.method; this.body =...
javascript
{ "resource": "" }
q52263
Response
train
function Response(code, headers, body) { this.code = code; this.headers = headers; this.body = body || ''; }
javascript
{ "resource": "" }
q52264
compileBundle
train
function compileBundle(_ref) { var customWebConfig = _ref.customWebConfig, architecture = _ref.architecture; var workingDir = _tmp.default.dirSync().name; _winston.default.info('Compiling application bundle'); // Generate Meteor build _winston.default.debug('generate meteor build'); _shelljs.defaul...
javascript
{ "resource": "" }
q52265
loadFile
train
function loadFile(fullFilePath, callback) { fs.readFile(fullFilePath, "utf-8", function(err, data) { if (err) { return callback(err); } return callback(null, data); }); }
javascript
{ "resource": "" }
q52266
handleFile
train
function handleFile(name, file, options, cache, callback) { var cachedData; if(!options || !options.settings || options.settings['view cache'] !== false) { cachedData = cache && cache.get(file); } if (!cachedData) { loadFile(file, function(err, fileData) { if (err) { return callback(err); } var pa...
javascript
{ "resource": "" }
q52267
consolidatePartials
train
function consolidatePartials(arr) { var partialsSet = {}; arr.forEach(function(item) { item.partials.forEach(function(partial) { partialsSet[partial] = true; }); }); return Object.keys(partialsSet); }
javascript
{ "resource": "" }
q52268
loadAllPartials
train
function loadAllPartials(unparsedPartials, partialsDirectory, partialsExtension, options, cache, partials, callback) { if (!partials) { partials = {}; } // This function is called recursively. This is our base case: the point where we // don't call recursively anymore. // That point is when there are no partial...
javascript
{ "resource": "" }
q52269
loadTemplateAndPartials
train
function loadTemplateAndPartials(templateFile, partialsDirectory, partialsExtension, options, cache, callback) { handleFile(null, templateFile, options, cache, function(err, partialData) { if (err) { return callback(err); } return loadAllPartials(partialData.partials, partialsDirectory, partialsExtension, op...
javascript
{ "resource": "" }
q52270
train
function(consumerKey, done) { db.clients.findByConsumerKey(consumerKey, function(err, client) { if (err) { return done(err); } if (!client) { return done(null, false); } return done(null, client, client.consumerSecret); }); }
javascript
{ "resource": "" }
q52271
train
function(requestToken, done) { db.requestTokens.find(requestToken, function(err, token) { if (err) { return done(err); } var info = { verifier: token.verifier, clientID: token.clientID, userID: token.userID, approved: token.approved } done(null, token.secret, i...
javascript
{ "resource": "" }
q52272
train
function(config) { if (!config) { return []; } var files = grunt.file.expand(config); if (files.length) { return files; } return [config]; }
javascript
{ "resource": "" }
q52273
train
function(data, dontParse) { // grunt.file chokes on objects, so we check for it immiedietly if (typeof data === 'object') { return data; } // `data` isn't an object, so its probably a file try { // alce allows us to parse single-quote JSON (which is tehcnically invalid, and thereby chok...
javascript
{ "resource": "" }
q52274
train
function(filename) { if (!filename || typeof filename === 'object') { return; } var match = filename.match(/[^\*]*/); if (match[0] !== filename) { return match.pop(); } }
javascript
{ "resource": "" }
q52275
train
function(filename, template, outputInInput) { var basename; var glob; template = Array.isArray(template) ? filename : template; glob = isGlob(template); if (outputInInput) { basename = _toArray(filename.split('.').pop()) ; } else if (glob) { basename = filename.slice(glob.length, fi...
javascript
{ "resource": "" }
q52276
calculateXAlign
train
function calculateXAlign (windowBounds, trayBounds, align) { const display = getDisplay() let x switch (align) { case 'right': x = trayBounds.x break case 'left': x = trayBounds.x + trayBounds.width - windowBounds.width break case 'center': default: x = Math.round(tr...
javascript
{ "resource": "" }
q52277
calculateYAlign
train
function calculateYAlign (windowBounds, trayBounds, align) { const display = getDisplay() let y switch (align) { case 'up': y = trayBounds.y + trayBounds.height - windowBounds.height break case 'down': y = trayBounds.y break case 'center': default: y = Math.round((tr...
javascript
{ "resource": "" }
q52278
calculateByCursorPosition
train
function calculateByCursorPosition (windowBounds, display, cursor) { let x = cursor.x let y = cursor.y if (x + windowBounds.width > display.bounds.width) { // if window would overlap on right side of screen, align it to the left of the cursor x -= windowBounds.width } if (y + windowBounds.height > d...
javascript
{ "resource": "" }
q52279
detectBrowser
train
function detectBrowser (browsers, browserQuery) { var b = false; browserQuery = browserslist(browserQuery); for (var i = 0; i < browsers.length; i++) { for (var j = 0; j < browserQuery.length; j++) { if (browsers[i] === browserQuery[j]) { b = true; break; } } if (b) { break...
javascript
{ "resource": "" }
q52280
toPx
train
function toPx (value, decl, result) { value = (typeof value === 'string' && value.indexOf('calc(') !== -1) ? calc(value) : value; var parts = /^(\d*\.?\d+)([a-zA-Z%]*)$/.exec(value); if (parts !== null) { var number = parts[1]; var unit = parts[2]; if (unit === 'px' || unit === '') { return p...
javascript
{ "resource": "" }
q52281
iterInit
train
function iterInit(d, count) { var levels = (8 * bits.log2(count+1) * (d+1))|0 var maxInts = bits.nextPow2(IFRAME_SIZE*levels) if(BOX_ISTACK.length < maxInts) { pool.free(BOX_ISTACK) BOX_ISTACK = pool.mallocInt32(maxInts) } var maxDoubles = bits.nextPow2(DFRAME_SIZE*levels) if(BOX_DSTACK.length < max...
javascript
{ "resource": "" }
q52282
iterPush
train
function iterPush(ptr, axis, redStart, redEnd, blueStart, blueEnd, state, lo, hi) { var iptr = IFRAME_SIZE * ptr BOX_ISTACK[iptr] = axis BOX_ISTACK[iptr+1] = redStart BOX_ISTACK[iptr+2] = redEnd BOX_ISTACK[iptr+3] = blueStart BOX_ISTACK[iptr+4] = blueEnd BOX_ISTACK[iptr+5] = state var ...
javascript
{ "resource": "" }
q52283
convertBoxes
train
function convertBoxes(boxes, d, data, ids) { var ptr = 0 var count = 0 for(var i=0, n=boxes.length; i<n; ++i) { var b = boxes[i] if(boxEmpty(d, b)) { continue } for(var j=0; j<2*d; ++j) { data[ptr++] = b[j] } ids[count++] = i } return count }
javascript
{ "resource": "" }
q52284
boxIntersect
train
function boxIntersect(red, blue, visit, full) { var n = red.length var m = blue.length //If either array is empty, then we can skip this whole thing if(n <= 0 || m <= 0) { return } //Compute dimension, if it is 0 then we skip var d = (red[0].length)>>>1 if(d <= 0) { return } var retval ...
javascript
{ "resource": "" }
q52285
boxIntersectWrapper
train
function boxIntersectWrapper(arg0, arg1, arg2) { var result switch(arguments.length) { case 1: return intersectFullArray(arg0) case 2: if(typeof arg1 === 'function') { return boxIntersect(arg0, arg0, arg1, true) } else { return intersectBipartiteArray(arg0, arg1) } ...
javascript
{ "resource": "" }
q52286
sqInit
train
function sqInit(count) { var rcount = bits.nextPow2(count) if(RED_SWEEP_QUEUE.length < rcount) { pool.free(RED_SWEEP_QUEUE) RED_SWEEP_QUEUE = pool.mallocInt32(rcount) } if(RED_SWEEP_INDEX.length < rcount) { pool.free(RED_SWEEP_INDEX) RED_SWEEP_INDEX = pool.mallocInt32(rcount) } if(BLUE_SWEEP...
javascript
{ "resource": "" }
q52287
train
function (delta) { var currentPose; var currentEvent var playingPoses = this.playingPoses; var playingEvents = this.playingEvents; currentPose = playingPoses && playingPoses[this.currentPoseIndex] currentEvent = playingEvents && playingEvents[this.currentEventIndex]; this.currentPoseTime += ...
javascript
{ "resource": "" }
q52288
train
function () { var data = this.data; var sceneEl = this.el; if (data.cameraOverride) { // Specify which camera is the original camera (e.g., used by Inspector). this.cameraEl = data.cameraOverride; } else { // Default camera. this.cameraEl = sceneEl.camera.el; // Make sure ...
javascript
{ "resource": "" }
q52289
train
function () { var spectatorCameraEl = this.spectatorCameraEl; if (!spectatorCameraEl) { this.el.addEventListener('spectatorcameracreated', bind(this.activateSpectatorCamera, this)); return; } if (!spectatorCameraEl.hasLoaded) { spectatorCameraEl.addEven...
javascript
{ "resource": "" }
q52290
train
function () { var data = this.data; var sceneEl = this.el; var spectatorCameraEl; var spectatorCameraRigEl; // Developer-defined spectator rig. if (this.el.querySelector('#spectatorCameraRig')) { this.spectatorCameraEl = sceneEl.querySelector('#spectatorCameraRig'); return; } ...
javascript
{ "resource": "" }
q52291
train
function () { var data = this.data; var recordingdb = this.el.systems.recordingdb;; var recordingNames; var src; var self = this; // Allow override to display replayer from query param. if (new URLSearchParams(window.location.search).get('avatar-replayer-disabled') !== null) { return;...
javascript
{ "resource": "" }
q52292
train
function () { var cameraEl = this.cameraEl; var headMesh; var leftEyeMesh; var rightEyeMesh; var leftEyeBallMesh; var rightEyeBallMesh; if (cameraEl.getObject3D('mesh') || cameraEl.getObject3D('replayerMesh')) { return; } // Head. headMesh = new THREE.Mesh(); headMesh.geometry ...
javascript
{ "resource": "" }
q52293
train
function () { var self = this; if (!this.isReplaying || !this.replayData) { return; } this.isReplaying = false; Object.keys(this.replayData).forEach(function removeReplayer (key) { if (key === 'camera') { self.cameraEl.removeComponent('motion-capture-replayer'); } else { el...
javascript
{ "resource": "" }
q52294
train
function (url, binary, callback) { var data; var self = this; fileLoader.crossOrigin = 'anonymous'; if (binary === true) { fileLoader.setResponseType('arraybuffer'); } fileLoader.load(url, function (buffer) { if (binary === true) { data = self.loadStrokeBinary(buffer); ...
javascript
{ "resource": "" }
q52295
train
function () { var self = this; var trackedControllerEls = this.el.querySelectorAll('[tracked-controls]'); this.trackedControllerEls = {}; trackedControllerEls.forEach(function setupController (trackedControllerEl) { if (!trackedControllerEl.id) { warn('Found a tracked controller entity wit...
javascript
{ "resource": "" }
q52296
train
function (evt) { var key = evt.keyCode; var KEYS = {space: 32}; switch (key) { // <space>: Toggle recording. case KEYS.space: { this.toggleRecording(); break; } } }
javascript
{ "resource": "" }
q52297
train
function (doneCb) { var el = this.el; var self = this; if (this.data.cameraOverride) { prepareCamera(this.data.cameraOverride); return; } // Grab camera. if (el.camera && el.camera.el) { prepareCamera(el.camera.el); return; } el.addEventListener('camera-set-act...
javascript
{ "resource": "" }
q52298
train
function () { var trackedControllerEls = this.trackedControllerEls; var self = this; if (this.isRecording) { return; } log('Starting recording!'); if (this.el.components['avatar-replayer']) { this.el.components['avatar-replayer'].stopReplaying(); } // Get camera. this.setupCame...
javascript
{ "resource": "" }
q52299
train
function () { var trackedControllerEls = this.trackedControllerEls; if (!this.isRecording) { return; } log('Stopped recording.'); this.isRecording = false; this.cameraEl.components['motion-capture-recorder'].stopRecording(); Object.keys(trackedControllerEls).forEach(function (id) { track...
javascript
{ "resource": "" }