_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q27200
train
function() { if ($(this).treegrid('isNode')) { var parentNode = $(this).treegrid('getParentNode'); if (parentNode === null) { if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').last().treegrid('getNodeId')) { ...
javascript
{ "resource": "" }
q27201
train
function() { if ($(this).treegrid('isNode')) { var parentNode = $(this).treegrid('getParentNode'); if (parentNode === null) { if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').first().treegrid('getNodeId')) { ...
javascript
{ "resource": "" }
q27202
train
function() { return $(this).each(function() { var $this = $(this); var expander = $this.treegrid('getSetting', 'getExpander').apply(this); if (expander) { if (!$this.treegrid('isCollapsed')) { expander.remove...
javascript
{ "resource": "" }
q27203
formatMatchingConstraints
train
function formatMatchingConstraints(matchingConstraints) { let ret = {}; if (typeof matchingConstraints === 'undefined' || matchingConstraints === null) { throw new TypeError('Constraints cannot be undefined or null'); } if (!isPlainObject(matchingConstraints)) { ret.callbackId = matchingConstraints; }...
javascript
{ "resource": "" }
q27204
validateConstraints
train
function validateConstraints(matchingConstraints) { if (matchingConstraints.callbackId && !(isString(matchingConstraints.callbackId) || isRegExp(matchingConstraints.callbackId))) { return new TypeError('Callback ID must be a string or RegExp'); } if (matchingConstraints.blockId && !(isString(matchi...
javascript
{ "resource": "" }
q27205
validateOptionsConstraints
train
function validateOptionsConstraints(optionsConstraints) { if (optionsConstraints.within && !(optionsConstraints.within === 'interactive_message' || optionsConstraints.within === 'block_actions' || optionsConstraints.within === 'dialog') ) { return new TypeError('Within must be \'block_actions\',...
javascript
{ "resource": "" }
q27206
slackSlashCommand
train
function slackSlashCommand(req, res, next) { if (req.body.command === '/interactive-example') { const type = req.body.text.split(' ')[0]; if (type === 'button') { res.json(interactiveButtons); } else if (type === 'menu') { res.json(interactiveMenu); } else if (type === 'dialog') { re...
javascript
{ "resource": "" }
q27207
train
function(settings) { this.addSettings(settings); // register the service worker _serviceWorker.register(_settings['service-worker-url'], _settings['registration-options']).then(function(registration) { // Registration was successful if (_debugState) { console.log('Service wo...
javascript
{ "resource": "" }
q27208
train
function(settings) { settings = settings || {}; // if we got a string, instead of a settings object, use that string as the content if (typeof settings === 'string') { settings = { content: settings }; } // add new settings to our settings object [ 'content', ...
javascript
{ "resource": "" }
q27209
train
function(input) { input = input.toString(); var hash = 0, i, chr, len = input.length; if (len === 0) { return hash; } for (i = 0; i < len; i++) { chr = input.charCodeAt(i); hash = (hash << 5) - hash + chr; hash |= 0; } return hash; }
javascript
{ "resource": "" }
q27210
train
function(useCached) { var rect = this._cachedViewportRect; if (useCached) return rect; // total transform is viewport transform combined with this layer's transform var viewport = Crafty.viewport; var options = this.options; var scale = Math.pow(...
javascript
{ "resource": "" }
q27211
train
function(rect, outRect, useCached) { var view = this._viewportRect(useCached), scale = view._scale; outRect = outRect || {}; outRect._x = rect._x * scale + Math.round(-view._x * scale); outRect._y = rect._y * scale + Math.round(-view._y * scale); ...
javascript
{ "resource": "" }
q27212
train
function(drad) { var cos = Math.cos(drad); cos = -1e-10 < cos && cos < 1e-10 ? 0 : cos; return cos; }
javascript
{ "resource": "" }
q27213
train
function(v) { //var theta = -1 * (v % 360); //angle always between 0 and 359 var difference = this._rotation - v; // skip if there's no rotation! if (difference === 0) return; else this._rotation = v; this._calculateMBR(); this.trigger("Rotate", difference); ...
javascript
{ "resource": "" }
q27214
train
function(x, y) { if (x === this._x && y === this._y) return; var old = Crafty.rectManager._pool.copy(this); var mbr = this._mbr; if (mbr) { mbr._x -= this._x - x; mbr._y -= this._y - y; // cbr is a non-minimal bounding rectangle that contains both hitb...
javascript
{ "resource": "" }
q27215
train
function(name, value) { // Return if there is no change if (this[name] === value) { return; } //keep a reference of the old positions var old = Crafty.rectManager._pool.copy(this); var mbr; //if rotation, use the rotate method if (name === "_r...
javascript
{ "resource": "" }
q27216
train
function(eventName, e) { // trigger event on MouseSystem itself this.trigger(eventName, e); // special case: MouseOver & MouseOut var over = this.over, closest = e.target; if (eventName === "MouseMove" && over !== close...
javascript
{ "resource": "" }
q27217
train
function(key, context) { var first, keys, subkey; if (typeof context === "undefined" || context === null) { context = this; } if (key.indexOf(".") > -1) { keys = key.split("."); first = keys.shift(); subkey = keys.join("."); ret...
javascript
{ "resource": "" }
q27218
train
function() { var data, silent, recursive; if (typeof arguments[0] === "string") { data = this._set_create_object(arguments[0], arguments[1]); silent = !!arguments[2]; recursive = arguments[3] || arguments[0].indexOf(".") > -1; } else { data = argum...
javascript
{ "resource": "" }
q27219
train
function(key, value) { var data = {}, keys, first, subkey; if (key.indexOf(".") > -1) { keys = key.split("."); first = keys.shift(); subkey = keys.join("."); data[first] = this._set_create_object(subkey, value); ...
javascript
{ "resource": "" }
q27220
train
function(new_data, original_data) { var key; for (key in new_data) { if (new_data[key].constructor === Object) { original_data[key] = this._recursive_extend( new_data[key], original_data[key] ); } else { ...
javascript
{ "resource": "" }
q27221
train
function(event, fn) { // Get handle to event, creating it if necessary var callbacks = this._callbacks[event]; if (!callbacks) { callbacks = this._callbacks[event] = (handlers[event] || (handlers[event] = {}))[this[0]] = []; callbacks.context = this; ...
javascript
{ "resource": "" }
q27222
train
function(event, data) { if (!this._callbacks[event] || this.__callbacksFrozen) { return; } var callbacks = this._callbacks[event]; // Callback loop; deletes dead callbacks, but only when it is safe to do so var i, l = callbacks.length; // callback...
javascript
{ "resource": "" }
q27223
train
function(event, fn) { if (!this._callbacks[event]) { return; } var callbacks = this._callbacks[event]; // Iterate through and delete the callback functions that match // They are spliced out when _runCallbacks is invoked, not here // (This function might be ca...
javascript
{ "resource": "" }
q27224
train
function() { if (!this._callbacks) return; this.__callbacksFrozen = false; for (var event in this._callbacks) { if (this._callbacks[event]) { // Remove the normal way, in case we've got a nested loop this._unbindCallbacks(event); // Als...
javascript
{ "resource": "" }
q27225
train
function(enabled) { var style = this._div.style; var camelize = Crafty.domHelper.camelize; if (enabled) { style[camelize("image-rendering")] = "optimizeSpeed"; /* legacy */ style[camelize("image-rendering")] = "-moz-crisp-edges"; /* Firefox */ ...
javascript
{ "resource": "" }
q27226
train
function() { var style = this._div.style, view = this._viewportRect(); var scale = view._scale; var dx = -view._x * scale; var dy = -view._y * scale; style.transform = style[Crafty.support.prefix + "Transform"] = "scale(" + scale + ", " + scale + ")"; ...
javascript
{ "resource": "" }
q27227
train
function() { var t; for (var i = 0; i < this.bound_textures.length; i++) { t = this.bound_textures[i]; t.unbind(); } this.bound_textures = []; this.active = null; }
javascript
{ "resource": "" }
q27228
train
function(url, image, repeating) { // gl is the context, webgl is the Crafty object containing prefs/etc // var gl = this.gl; var webgl = this.webgl; // Check whether a texture that matches the one requested already exists var id = "texture-(r:" + repeating + ")-" + url; ...
javascript
{ "resource": "" }
q27229
train
function() { var min_size = Infinity; var index = null; for (var i = 0; i < this.bound_textures.length; i++) { var t = this.bound_textures[i]; if (t.size < min_size) { min_size = t.size; index = i; } } return ind...
javascript
{ "resource": "" }
q27230
train
function(t) { // return if the texture is already bound if (t.unit !== null) return; var i = this.getAvailableUnit(); if (this.bound_textures[i]) { this.unbindTexture(this.bound_textures[i]); } this.bound_textures[i] = t; t.bind(i); }
javascript
{ "resource": "" }
q27231
train
function(unit) { var gl = this.gl; this.unit = unit; this.name = "TEXTURE" + unit; this.manager.setActiveTexture(this); gl.bindTexture(gl.TEXTURE_2D, this.glTexture); }
javascript
{ "resource": "" }
q27232
train
function(image) { if (!this.isActive()) throw "Trying to set image of texture that isn't active"; this.width = image.width; this.height = image.height; this.size = image.width * image.height; this.powerOfTwo = !( Math.log(image.width) / Math.LN2 !== ...
javascript
{ "resource": "" }
q27233
train
function(repeat) { if (!this.isActive()) throw "Trying to set repeat property of texture that isn't active"; if (repeat && !this.powerOfTwo) { throw "Can't create a repeating image whose dimensions aren't a power of 2 in WebGL contexts"; } var gl = this.gl; ...
javascript
{ "resource": "" }
q27234
train
function(shader, sampler_name, dimension_name) { if (this.unit === null) throw "Trying to use texture not set to a texture unit."; var gl = this.gl; gl.useProgram(shader); // Set the texture buffer to use gl.uniform1i(gl.getUniformLocation(shader, sampler_name), this....
javascript
{ "resource": "" }
q27235
train
function(dpad, normalize) { var x = 0, y = 0; // Sum up all active directions for (var d in dpad.directions) { var dir = dpad.directions[d]; if (!dir.active) continue; x += dir.n.x; y += dir.n.y; } // Mitigate rounding...
javascript
{ "resource": "" }
q27236
RenderProgramWrapper
train
function RenderProgramWrapper(layer, shader) { this.shader = shader; this.layer = layer; this.context = layer.context; this.draw = function() {}; this.array_size = 16; this.max_size = 1024; this._indexArray = new Uint16Array(6 * this.array_size); this._indexBuffer = layer.context.create...
javascript
{ "resource": "" }
q27237
train
function(attributes) { this.attributes = attributes; this._attribute_table = {}; var offset = 0; for (var i = 0; i < attributes.length; i++) { var a = attributes[i]; this._attribute_table[a.name] = a; a.bytes = a.bytes || Float32Array.BYTES_PER_ELEMEN...
javascript
{ "resource": "" }
q27238
train
function(size) { if (this.array_size >= this.max_size) return; var newsize = Math.min(size, this.max_size); var newAttributeArray = new Float32Array(newsize * 4 * this.stride); var newIndexArray = new Uint16Array(6 * newsize); newAttributeArray.set(this._attributeArray); ...
javascript
{ "resource": "" }
q27239
train
function(e) { if (this._registryHoles.length === 0) { if (this._registrySize >= this.max_size) { throw "Number of entities exceeds maximum limit."; } else if (this._registrySize >= this.array_size) { this.growArrays(2 * this.array_size); } ...
javascript
{ "resource": "" }
q27240
train
function(e) { if (typeof e._glBufferIndex === "number") this._registryHoles.push(e._glBufferIndex); e._glBufferIndex = null; }
javascript
{ "resource": "" }
q27241
train
function() { var gl = this.context; gl.useProgram(this.shader); gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer); var a, attributes = this.attributes; // Process every attribute for (var i = 0; i < attributes.length; i++) { a = attributes[i]; ...
javascript
{ "resource": "" }
q27242
train
function(offset) { var index = this._indexArray, l = this.index_pointer; index[0 + l] = 0 + offset; index[1 + l] = 1 + offset; index[2 + l] = 2 + offset; index[3 + l] = 1 + offset; index[4 + l] = 2 + offset; index[5 + l] = 3 + offset; this.inde...
javascript
{ "resource": "" }
q27243
train
function() { var gl = this.context; gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer); gl.bufferData(gl.ARRAY_BUFFER, this._attributeArray, gl.STATIC_DRAW); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); gl.bufferData( gl.ELEMENT_ARRAY_BUFFER, ...
javascript
{ "resource": "" }
q27244
train
function(src, type) { var gl = this.context; var shader = gl.createShader(type); gl.shaderSource(shader, src); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { throw gl.getShaderInfoLog(shader); } return shader; }
javascript
{ "resource": "" }
q27245
train
function(shader) { var gl = this.context; var fragmentShader = this._compileShader( shader.fragmentCode, gl.FRAGMENT_SHADER ); var vertexShader = this._compileShader( shader.vertexCode, gl.VERTEX_SHADER ); var shaderProgram...
javascript
{ "resource": "" }
q27246
train
function() { var c = this._canvas; c.width = Crafty.viewport.width; c.height = Crafty.viewport.height; var gl = this.context; gl.viewportWidth = c.width; gl.viewportHeight = c.height; }
javascript
{ "resource": "" }
q27247
train
function(rect) { rect = rect || this._viewportRect(); var gl = this.context; // Set viewport and clear it gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); //Set the viewport uniform variables used by each regis...
javascript
{ "resource": "" }
q27248
train
function(propertyName) { // could check for DOM component, but this event should only be fired by such an entity! // Rather than triggering Invalidate on each of these, we rely on css() triggering that event switch (propertyName) { case "textAlign": ...
javascript
{ "resource": "" }
q27249
train
function() { return ( this._textFont.type + " " + this._textFont.variant + " " + this._textFont.weight + " " + this._textFont.size + " / " + this._textFont.lineHeight + " " + this....
javascript
{ "resource": "" }
q27250
train
function(compName, shader) { this.program = this._drawLayer.getProgramWrapper(compName, shader); // Needs to know where in the big array we are! this.program.registerEntity(this); // Shader program means ready this.ready = true; }
javascript
{ "resource": "" }
q27251
train
function() { this.supported = {}; // Without support, no formats are supported if (!Crafty.support.audio) return; var audio = this.audioElement(), canplay; for (var i in this.codecs) { canplay = audio.canPlayType(this.codecs[i])...
javascript
{ "resource": "" }
q27252
train
function() { for (var i = 0; i < this.channels.length; i++) { var chan = this.channels[i]; /* * Second test looks for stuff that's out of use, * but fallen foul of Chromium bug 280417 */ if ( ...
javascript
{ "resource": "" }
q27253
train
function(layer) { if (!this.img || !layer) return; if (layer.type === "Canvas") { this._pattern = this._drawContext.createPattern( this.img, this._repeat ); } else if (layer.type === "WebGL") { this._establishShader( ...
javascript
{ "resource": "" }
q27254
train
function() { var comp, c = this.__c, str = ""; for (comp in c) { str += " " + comp; } str = str.substr(1); this._element.className = str; }
javascript
{ "resource": "" }
q27255
train
function() { if ( Crafty.loggingEnabled && (typeof window !== "undefined" ? window.console : console) && console.log ) { console.log.apply(console, arguments); } }
javascript
{ "resource": "" }
q27256
train
function(e) { var dx, dy, rot = this.rotation * DEG_TO_RAD, points = this.map.points; // Depending on the change of axis, move the corners of the rectangle appropriately if (e.axis === "w") { if (rot) { dx = e.amount * Math.cos(rot...
javascript
{ "resource": "" }
q27257
train
function(component, collisionData) { return function() { var hitData = this.hit(component); if (collisionData.occurring === true) { if (hitData !== null) { // The collision is still in progress return; } ...
javascript
{ "resource": "" }
q27258
train
function(e) { if (!this._color) { return; } if (e.type === "DOM") { e.style.backgroundColor = this._color; e.style.lineHeight = 0; } else if (e.type === "canvas") { e.ctx.fillStyle = this._color; e.ctx.fillRect(e.pos._x, e.pos._...
javascript
{ "resource": "" }
q27259
train
function(eventName, e) { // trigger event on TouchSystem itself this.trigger(eventName, e); var identifier = e.identifier, closest = e.target, over = this.overs[identifier]; if (over) { // if ol...
javascript
{ "resource": "" }
q27260
env
train
function env(envName, configSetters) { assertConfigSetters(configSetters) const currentEnv = process.env.NODE_ENV || 'development' if (currentEnv !== envName) { return () => config => config } else { return group(configSetters) } }
javascript
{ "resource": "" }
q27261
when
train
function when(condition, configSetters) { assertConfigSetters(configSetters) if (condition) { return group(configSetters) } else { return () => config => config } }
javascript
{ "resource": "" }
q27262
parseVersion
train
function parseVersion(versionString) { const [release, prerelease] = versionString.split('-') const splitRelease = release.split('.').map(number => parseInt(number, 10)) return { major: splitRelease[0], minor: splitRelease[1], patch: splitRelease[2], prerelease: prerelease || '', raw: version...
javascript
{ "resource": "" }
q27263
setEnv
train
function setEnv(constants) { const setter = context => prevConfig => { context.setEnv = Object.assign({}, context.setEnv, toObject(constants)) return prevConfig } return Object.assign(setter, { post: addEnvironmentPlugin }) }
javascript
{ "resource": "" }
q27264
group
train
function group(configSetters) { assertConfigSetters(configSetters) const pre = getHooks(configSetters, 'pre') const post = getHooks(configSetters, 'post') const groupBlock = context => config => invokeConfigSetters(configSetters, context, config) return Object.assign(groupBlock, { pre, post }) }
javascript
{ "resource": "" }
q27265
assertConfigSetters
train
function assertConfigSetters(configSetters) { if (!Array.isArray(configSetters)) { throw new Error( `Expected parameter 'configSetters' to be an array of functions. Instead got ${configSetters}.` ) } if (!configSetters.every(_.isFunction)) { const invalidElementIndex = configSetters.findIndex(se...
javascript
{ "resource": "" }
q27266
createConfig
train
function createConfig(initialContext, configSetters) { if (!initialContext) { throw new Error(`No initial context passed.`) } assertConfigSetters(configSetters) const baseConfig = { resolve: { // Explicitly define default extensions, otherwise blocks will overwrite them instead of extending ...
javascript
{ "resource": "" }
q27267
ngSwaggerGen
train
function ngSwaggerGen(options) { if (typeof options.swagger != 'string') { console.error("Swagger file not specified in the 'swagger' option"); process.exit(1); } var globalTunnel = require('global-tunnel-ng'); globalTunnel.initialize(); $RefParser.bundle(options.swagger, { dereference: { circular...
javascript
{ "resource": "" }
q27268
train
function(template, model, file) { var code = Mustache.render(template, model, templates) .replace(/[^\S\r\n]+$/gm, ''); fs.writeFileSync(file, code, 'UTF-8'); console.info('Wrote ' + file); }
javascript
{ "resource": "" }
q27269
applyTagFilter
train
function applyTagFilter(models, services, options) { var i; // Normalize the included tag names const includeTags = options.includeTags; var included = null; if (includeTags && includeTags.length > 0) { included = []; for (i = 0; i < includeTags.length; i++) { included.push(tagName(includeTags[i...
javascript
{ "resource": "" }
q27270
collectDependencies
train
function collectDependencies(dependencies, model, models) { if (!model || dependencies.has(model.modelClass)) { return; } dependencies.add(model.modelClass); if (model.modelDependencies) { model.modelDependencies.forEach((dep) => collectDependencies(dependencies, dep, models) ); } }
javascript
{ "resource": "" }
q27271
toFileName
train
function toFileName(typeName) { var result = ''; var wasLower = false; for (var i = 0; i < typeName.length; i++) { var c = typeName.charAt(i); var isLower = /[a-z]/.test(c); if (!isLower && wasLower) { result += '-'; } result += c.toLowerCase(); wasLower = isLower; } return resul...
javascript
{ "resource": "" }
q27272
toClassName
train
function toClassName(name) { var result = ''; var upNext = false; for (var i = 0; i < name.length; i++) { var c = name.charAt(i); var valid = /[\w]/.test(c); if (!valid) { upNext = true; } else if (upNext) { result += c.toUpperCase(); upNext = false; } else if (result === '')...
javascript
{ "resource": "" }
q27273
simpleRef
train
function simpleRef(ref) { if (!ref) { return null; } var index = ref.lastIndexOf('/'); if (index >= 0) { ref = ref.substr(index + 1); } return toClassName(ref); }
javascript
{ "resource": "" }
q27274
toEnumName
train
function toEnumName(value) { var result = ''; var wasLower = false; for (var i = 0; i < value.length; i++) { var c = value.charAt(i); var isLower = /[a-z]/.test(c); if (!isLower && wasLower) { result += '_'; } result += c.toUpperCase(); wasLower = isLower; } if (!isNaN(value[0]))...
javascript
{ "resource": "" }
q27275
toComments
train
function toComments(text, level) { var indent = ''; var i; for (i = 0; i < level; i++) { indent += ' '; } if (text == null || text.length === 0) { return indent; } const lines = text.trim().split('\n'); var result = '\n' + indent + '/**\n'; lines.forEach(line => { result += indent + ' *' ...
javascript
{ "resource": "" }
q27276
mergeTypes
train
function mergeTypes(...types) { let allTypes = []; types.forEach(type => { (type.allTypes || [type]).forEach(type => { if (allTypes.indexOf(type) < 0) allTypes.push(type); }); }); return allTypes; }
javascript
{ "resource": "" }
q27277
processProperties
train
function processProperties(swagger, properties, requiredProperties) { var result = {}; for (var name in properties) { var property = properties[name]; var descriptor = { propertyName: name.indexOf('-') === -1 ? name : `"${name}"`, propertyComments: toComments(property.description, 1), prop...
javascript
{ "resource": "" }
q27278
resolveRef
train
function resolveRef(swagger, ref) { if (ref.indexOf('#/') != 0) { console.error('Resolved references must start with #/. Current: ' + ref); process.exit(1); } var parts = ref.substr(2).split('/'); var result = swagger; for (var i = 0; i < parts.length; i++) { var part = parts[i]; result = resu...
javascript
{ "resource": "" }
q27279
toIdentifier
train
function toIdentifier(string) { var result = ''; var wasSep = false; for (var i = 0; i < string.length; i++) { var c = string.charAt(i); if (/[a-zA-Z0-9]/.test(c)) { if (wasSep) { c = c.toUpperCase(); wasSep = false; } result += c; } else { wasSep = true; } ...
javascript
{ "resource": "" }
q27280
tagName
train
function tagName(tag, options) { if (tag == null || tag === '') { tag = options.defaultTag || 'Api'; } tag = toIdentifier(tag); return tag.charAt(0).toUpperCase() + (tag.length == 1 ? '' : tag.substr(1)); }
javascript
{ "resource": "" }
q27281
operationId
train
function operationId(given, method, url, allKnown) { var id; var generate = given == null; if (generate) { id = toIdentifier(method + url); } else { id = toIdentifier(given); } var duplicated = allKnown.has(id); if (duplicated) { var i = 1; while (allKnown.has(id + '_' + i)) { i++; ...
javascript
{ "resource": "" }
q27282
train
function (image) { for (var i = 0; i < cache.length; i++) { if (cache[i].src === image.src) { return cache[i]; } } cache.push(image); return image; }
javascript
{ "resource": "" }
q27283
train
function () { if (oldVideoWrapper) { oldVideoWrapper.stop(); oldVideoWrapper.destroy(); } $oldItemWrapper.remove(); // Resume the slideshow if (!that.paused && that.images.length > 1) { that.cycle(); } // Now w...
javascript
{ "resource": "" }
q27284
train
function(options) { // Number of Tracks per output segment // If greater than 1, we combine multiple // tracks into a single segment this.numberOfTracks = 0; this.metadataStream = options.metadataStream; this.videoTags = []; this.audioTags = []; this.videoTrack = null; this.audioTrack = null; this....
javascript
{ "resource": "" }
q27285
webworkifyDebug
train
function webworkifyDebug (worker) { var targetA = new EventTarget(), targetB = new EventTarget(); targetA.setTarget(targetB); targetB.setTarget(targetA); worker(targetA); return targetB; }
javascript
{ "resource": "" }
q27286
train
function () { var data = this.data; // If true, show wireframes around physics bodies. this.debug = data.debug; this.callbacks = {beforeStep: [], step: [], afterStep: []}; this.listeners = {}; this.driver = null; switch (data.driver) { case 'local': this.driver = new LocalD...
javascript
{ "resource": "" }
q27287
train
function (body) { var driver = this.driver; body.__applyImpulse = body.applyImpulse; body.applyImpulse = function () { driver.applyBodyMethod(body, 'applyImpulse', arguments); }; body.__applyForce = body.applyForce; body.applyForce = function () { driver.applyBodyMethod(body, 'appl...
javascript
{ "resource": "" }
q27288
train
function (body) { this.driver.removeBody(body); body.removeEventListener('collide', this.listeners[body.id]); delete this.listeners[body.id]; body.applyImpulse = body.__applyImpulse; delete body.__applyImpulse; body.applyForce = body.__applyForce; delete body.__applyForce; delete bod...
javascript
{ "resource": "" }
q27289
train
function (component) { var callbacks = this.callbacks; if (component.beforeStep) callbacks.beforeStep.push(component); if (component.step) callbacks.step.push(component); if (component.afterStep) callbacks.afterStep.push(component); }
javascript
{ "resource": "" }
q27290
train
function (component) { var callbacks = this.callbacks; if (component.beforeStep) { callbacks.beforeStep.splice(callbacks.beforeStep.indexOf(component), 1); } if (component.step) { callbacks.step.splice(callbacks.step.indexOf(component), 1); } if (component.afterStep) { callback...
javascript
{ "resource": "" }
q27291
filter
train
function filter() { var ret = []; var labels = Array.prototype.slice.call(arguments); labels.forEach(function(label) { browsers.forEach(function(browser) { if (label === 'bs_all') { ret.push(browser); } else if (browser._alias.match(new RegExp(label.slice(2) + '$'))) { ret.push(br...
javascript
{ "resource": "" }
q27292
guessFunctionName
train
function guessFunctionName(url, lineNo) { var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/, reGuessFunction = /['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/, line = '', maxLines = 10, source = getSource(url), m; if (!...
javascript
{ "resource": "" }
q27293
gatherContext
train
function gatherContext(url, line) { var source = getSource(url); if (!source.length) { return null; } var context = [], // linesBefore & linesAfter are inclusive with the offending line. // if linesOfContext is even, there will be one extra line ...
javascript
{ "resource": "" }
q27294
escapeCodeAsRegExpForMatchingInsideHTML
train
function escapeCodeAsRegExpForMatchingInsideHTML(body) { return escapeRegExp(body).replace('<', '(?:<|&lt;)').replace('>', '(?:>|&gt;)').replace('&', '(?:&|&amp;)').replace('"', '(?:"|&quot;)').replace(/\s+/g, '\\s+'); }
javascript
{ "resource": "" }
q27295
findSourceInLine
train
function findSourceInLine(fragment, url, line) { var source = getSource(url), re = new RegExp('\\b' + escapeRegExp(fragment) + '\\b'), m; line -= 1; if (source && source.length > line && (m = re.exec(source[line]))) { return m.index; } retur...
javascript
{ "resource": "" }
q27296
computeStackTraceFromStacktraceProp
train
function computeStackTraceFromStacktraceProp(ex) { // Access and store the stacktrace property before doing ANYTHING // else to it because Opera is not very good at providing it // reliably in other circumstances. var stacktrace = ex.stacktrace; var testRE = / line (\d+), column...
javascript
{ "resource": "" }
q27297
augmentStackTraceWithInitialElement
train
function augmentStackTraceWithInitialElement(stackInfo, url, lineNo, message) { var initial = { 'url': url, 'line': lineNo }; if (initial.url && initial.line) { stackInfo.incomplete = false; if (!initial.func) { initial.func = gue...
javascript
{ "resource": "" }
q27298
computeStackTrace
train
function computeStackTrace(ex, depth) { var stack = null; depth = (depth == null ? 0 : +depth); try { // This must be tried first because Opera 10 *destroys* // its stacktrace property if you try to access the stack // property first!! stack = com...
javascript
{ "resource": "" }
q27299
computeStackTraceOfCaller
train
function computeStackTraceOfCaller(depth) { depth = (depth == null ? 0 : +depth) + 1; // "+ 1" because "ofCaller" should drop one frame try { throw new Error(); } catch (ex) { return computeStackTrace(ex, depth + 1); } }
javascript
{ "resource": "" }