_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q59700
validation
function (success, fail, args, env) { var result = new PluginResult(args, env); args = JSON.parse(decodeURIComponent(args["input"])); result.ok(mongoose.getInstance().start(args), false); }
javascript
{ "resource": "" }
q59701
validation
function (success, fail, args, env) { var result = new PluginResult(args, env); args = JSON.parse(decodeURIComponent(args["input"])); result.ok(uPnP.getInstance().discover(result.callbackId, args), false); }
javascript
{ "resource": "" }
q59702
mkextract
validation
function mkextract (opts) { var chunk = null var indent = 0 var number = 0 opts = merge({}, { trim: true, dotted_names: false, parsers: [ PARSERS.parse_tag, PARSERS.parse_type, PARSERS.parse_name, PARSERS.parse_description ] }, opts || {}) /** * Read lines until they make a block * Return parsed block once fullfilled or null otherwise */ return function extract (line) { var result = null var startPos = line.indexOf(MARKER_START) var endPos = line.indexOf(MARKER_END) // if open marker detected and it's not skip one if (startPos !== -1 && line.indexOf(MARKER_START_SKIP) !== startPos) { chunk = [] indent = startPos + MARKER_START.length } // if we are on middle of comment block if (chunk) { var lineStart = indent var startWithStar = false // figure out if we slice from opening marker pos // or line start is shifted to the left var nonSpaceChar = line.match(/\S/) // skip for the first line starting with /** (fresh chunk) // it always has the right indentation if (chunk.length > 0 && nonSpaceChar) { if (nonSpaceChar[0] === '*') { lineStart = nonSpaceChar.index + 2 startWithStar = true } else if (nonSpaceChar.index < indent) { lineStart = nonSpaceChar.index } } // slice the line until end or until closing marker start chunk.push({ number: number, startWithStar: startWithStar, source: line.slice(lineStart, endPos === -1 ? line.length : endPos) }) // finalize block if end marker detected if (endPos !== -1) { result = parse_block(chunk, opts) chunk = null indent = 0 } } number += 1 return result } }
javascript
{ "resource": "" }
q59703
tokenize
validation
function tokenize(content) { var tokens = []; var parser = new htmlparser.Parser({ onopentag: function(name, attribs) { }, ontext: function(text) { var start = parser.startIndex; tokens.push({ value: text, index: start, offset: text.length }); }, onclosetag: function(tagname) { } }); parser.write(content); parser.end(); return tokens; }
javascript
{ "resource": "" }
q59704
tokenizeDefine
validation
function tokenizeDefine(infos) { return tokenize.split(function(text, tok) { var _infos = _.isFunction(infos)? infos.apply(null, arguments) : _.clone(infos); if (!_infos) return null; // Defaults for the sugegstion _infos = _.defaults(_infos, { index: 0, message: "", replacements: [] }); _infos = _.extend(tok, _infos); _infos.message = _.template(_infos.message)(_infos); return _infos; }); }
javascript
{ "resource": "" }
q59705
tokenizeCheck
validation
function tokenizeCheck() { var fn = tokenize.serie.apply(tokenize, arguments); return function(text, opts, callback) { try { callback(null, fn(text, opts)); } catch(err) { callback(err); } }; }
javascript
{ "resource": "" }
q59706
parseFile
validation
function parseFile(input) { fileContent = fs.readFileSync(input, { encoding: "utf-8" }); var ext = path.extname(input); if (ext == '.html') return tokenizeHTML(fileContent); return fileContent; }
javascript
{ "resource": "" }
q59707
softReplace
validation
function softReplace(contentBlock, nativeString, localizedString) { var escapedString = ignoreExtraSpaces( ignoreEmptyAttrs( utils.escapeRegExpSpecialChars( nativeString ) ) ); var regex = new RegExp('([>"\']\\s*)(' + escapedString + ')(\\s*[<"\'])', 'g'); return contentBlock.replace(regex, '$1' + localizedString + '$3'); }
javascript
{ "resource": "" }
q59708
generateNonce
validation
function generateNonce(length) { return generateSecureRandom(length).then((nonce) => { const nonceString = base64js.fromByteArray(nonce); return nonceString; }); }
javascript
{ "resource": "" }
q59709
_isEqualArray
validation
function _isEqualArray(a, b) { if (a === b) { return true; } if ((a === undefined) || (b === undefined)) { return false; } var i = a.length; if (i !== b.length){ return false; } while (i--) { if (a[i] !== b[i]) { return false; } } return true; }
javascript
{ "resource": "" }
q59710
_destroyNode
validation
function _destroyNode(node) { // Remove node from linked-list if (node._next) { node._next._prev = node._prev; } if (node._prev) { node._prev._next = node._next; } else { this._first = node._next; } // Destroy the node node.destroy(); // Add node to pool if (this._pool.layoutNodes.size < MAX_POOL_SIZE) { this._pool.layoutNodes.size++; node._prev = undefined; node._next = this._pool.layoutNodes.first; this._pool.layoutNodes.first = node; } }
javascript
{ "resource": "" }
q59711
_contextNext
validation
function _contextNext() { // Get the next node from the sequence if (!this._contextState.nextSequence) { return undefined; } if (this._context.reverse) { this._contextState.nextSequence = this._contextState.nextSequence.getNext(); if (!this._contextState.nextSequence) { return undefined; } } var renderNode = this._contextState.nextSequence.get(); if (!renderNode) { this._contextState.nextSequence = undefined; return undefined; } var nextSequence = this._contextState.nextSequence; if (!this._context.reverse) { this._contextState.nextSequence = this._contextState.nextSequence.getNext(); } if (this._contextState.lastRenderNode === renderNode) { throw 'ViewSequence is corrupted, should never contain the same renderNode twice, index: ' + nextSequence.getIndex(); } this._contextState.lastRenderNode = renderNode; return { renderNode: renderNode, viewSequence: nextSequence, next: true, index: ++this._contextState.nextGetIndex }; }
javascript
{ "resource": "" }
q59712
_contextPrev
validation
function _contextPrev() { // Get the previous node from the sequence if (!this._contextState.prevSequence) { return undefined; } if (!this._context.reverse) { this._contextState.prevSequence = this._contextState.prevSequence.getPrevious(); if (!this._contextState.prevSequence) { return undefined; } } var renderNode = this._contextState.prevSequence.get(); if (!renderNode) { this._contextState.prevSequence = undefined; return undefined; } var prevSequence = this._contextState.prevSequence; if (this._context.reverse) { this._contextState.prevSequence = this._contextState.prevSequence.getPrevious(); } if (this._contextState.lastRenderNode === renderNode) { throw 'ViewSequence is corrupted, should never contain the same renderNode twice, index: ' + prevSequence.getIndex(); } this._contextState.lastRenderNode = renderNode; return { renderNode: renderNode, viewSequence: prevSequence, prev: true, index: --this._contextState.prevGetIndex }; }
javascript
{ "resource": "" }
q59713
_contextGet
validation
function _contextGet(contextNodeOrId) { if (this._nodesById && ((contextNodeOrId instanceof String) || (typeof contextNodeOrId === 'string'))) { var renderNode = this._nodesById[contextNodeOrId]; if (!renderNode) { return undefined; } // Return array if (renderNode instanceof Array) { var result = []; for (var i = 0, j = renderNode.length; i < j; i++) { result.push({ renderNode: renderNode[i], arrayElement: true }); } return result; } // Create context node return { renderNode: renderNode, byId: true }; } else { return contextNodeOrId; } }
javascript
{ "resource": "" }
q59714
_contextSet
validation
function _contextSet(contextNodeOrId, set) { var contextNode = this._nodesById ? _contextGet.call(this, contextNodeOrId) : contextNodeOrId; if (contextNode) { var node = contextNode.node; if (!node) { if (contextNode.next) { if (contextNode.index < this._contextState.nextSetIndex) { LayoutUtility.error('Nodes must be layed out in the same order as they were requested!'); } this._contextState.nextSetIndex = contextNode.index; } else if (contextNode.prev) { if (contextNode.index > this._contextState.prevSetIndex) { LayoutUtility.error('Nodes must be layed out in the same order as they were requested!'); } this._contextState.prevSetIndex = contextNode.index; } node = _contextGetCreateAndOrderNodes.call(this, contextNode.renderNode, contextNode.prev); node._viewSequence = contextNode.viewSequence; node._layoutCount++; if (node._layoutCount === 1) { this._contextState.addCount++; } contextNode.node = node; } node.usesTrueSize = contextNode.usesTrueSize; node.trueSizeRequested = contextNode.trueSizeRequested; node.set(set, this._context.size); contextNode.set = set; } return set; }
javascript
{ "resource": "" }
q59715
_resolveConfigSize
validation
function _resolveConfigSize(renderNode) { if (renderNode instanceof RenderNode) { var result = null; var target = renderNode.get(); if (target) { result = _resolveConfigSize(target); if (result) { return result; } } if (renderNode._child) { return _resolveConfigSize(renderNode._child); } } else if (renderNode instanceof Surface) { return renderNode.size ? { renderNode: renderNode, size: renderNode.size } : undefined; } else if (renderNode.options && renderNode.options.size) { return { renderNode: renderNode, size: renderNode.options.size }; } return undefined; }
javascript
{ "resource": "" }
q59716
_getRoundedValue3D
validation
function _getRoundedValue3D(prop, def, precision, lockValue) { if (!prop || !prop.init) { return def; } return [ prop.enabled[0] ? (Math.round((prop.curState.x + ((prop.endState.x - prop.curState.x) * lockValue)) / precision) * precision) : prop.endState.x, prop.enabled[1] ? (Math.round((prop.curState.y + ((prop.endState.y - prop.curState.y) * lockValue)) / precision) * precision) : prop.endState.y, prop.enabled[2] ? (Math.round((prop.curState.z + ((prop.endState.z - prop.curState.z) * lockValue)) / precision) * precision) : prop.endState.z ]; }
javascript
{ "resource": "" }
q59717
_forEachRenderable
validation
function _forEachRenderable(callback) { if (this._nodesById) { for (var key in this._nodesById) { callback(this._nodesById[key]); } } else { var sequence = this._viewSequence.getHead(); while (sequence) { var renderable = sequence.get(); if (renderable) { callback(renderable); } sequence = sequence.getNext(); } } }
javascript
{ "resource": "" }
q59718
_getActualDirection
validation
function _getActualDirection(direction) { // When the direction is configured in the capabilities, look it up there if (this._layout.capabilities && this._layout.capabilities.direction) { // Multiple directions are supported if (Array.isArray(this._layout.capabilities.direction)) { for (var i = 0; i < this._layout.capabilities.direction.length; i++) { if (this._layout.capabilities.direction[i] === direction) { return direction; } } return this._layout.capabilities.direction[0]; } // Only one direction is supported, we must use that else { return this._layout.capabilities.direction; } } // Use Y-direction as a fallback return (direction === undefined) ? Utility.Direction.Y : direction; }
javascript
{ "resource": "" }
q59719
_getViewSequenceAtIndex
validation
function _getViewSequenceAtIndex(index, startViewSequence) { if (this._viewSequence.getAtIndex) { return this._viewSequence.getAtIndex(index, startViewSequence); } var viewSequence = startViewSequence || this._viewSequence; var i = viewSequence ? viewSequence.getIndex() : index; if (index > i) { while (viewSequence) { viewSequence = viewSequence.getNext(); if (!viewSequence) { return undefined; } i = viewSequence.getIndex(); if (i === index) { return viewSequence; } else if (index < i) { return undefined; } } } else if (index < i) { while (viewSequence) { viewSequence = viewSequence.getPrevious(); if (!viewSequence) { return undefined; } i = viewSequence.getIndex(); if (i === index) { return viewSequence; } else if (index > i) { return undefined; } } } return viewSequence; }
javascript
{ "resource": "" }
q59720
_mouseDown
validation
function _mouseDown(event) { // Check whether mouse-scrolling is enabled if (!this.options.mouseMove) { return; } // Reset any previous mouse-move operation that has not yet been // cleared. if (this._scroll.mouseMove) { this.releaseScrollForce(this._scroll.mouseMove.delta); } // Calculate start of move operation var current = [event.clientX, event.clientY]; var time = _getEventTimestamp(event); this._scroll.mouseMove = { delta: 0, start: current, current: current, prev: current, time: time, prevTime: time }; // Apply scroll force this.applyScrollForce(this._scroll.mouseMove.delta); }
javascript
{ "resource": "" }
q59721
_touchStart
validation
function _touchStart(event) { // Create touch-end event listener if (!this._touchEndEventListener) { this._touchEndEventListener = function(event2) { event2.target.removeEventListener('touchend', this._touchEndEventListener); _touchEnd.call(this, event2); }.bind(this); } // Remove any touches that are no longer active var oldTouchesCount = this._scroll.activeTouches.length; var i = 0; var j; var touchFound; while (i < this._scroll.activeTouches.length) { var activeTouch = this._scroll.activeTouches[i]; touchFound = false; for (j = 0; j < event.touches.length; j++) { var touch = event.touches[j]; if (touch.identifier === activeTouch.id) { touchFound = true; break; } } if (!touchFound) { //_log.cal(this, 'removing touch with id: ', activeTouch.id); this._scroll.activeTouches.splice(i, 1); } else { i++; } } // Process touch for (i = 0; i < event.touches.length; i++) { var changedTouch = event.touches[i]; touchFound = false; for (j = 0; j < this._scroll.activeTouches.length; j++) { if (this._scroll.activeTouches[j].id === changedTouch.identifier) { touchFound = true; break; } } if (!touchFound) { var current = [changedTouch.clientX, changedTouch.clientY]; var time = _getEventTimestamp(event); this._scroll.activeTouches.push({ id: changedTouch.identifier, start: current, current: current, prev: current, time: time, prevTime: time }); // The following listener is automatically removed after touchend is received // and ensures that the scrollview always received touchend. changedTouch.target.addEventListener('touchend', this._touchEndEventListener); } } // The first time a touch new touch gesture has arrived, emit event if (!oldTouchesCount && this._scroll.activeTouches.length) { this.applyScrollForce(0); this._scroll.touchDelta = 0; } }
javascript
{ "resource": "" }
q59722
_touchEnd
validation
function _touchEnd(event) { // Remove touch var primaryTouch = this._scroll.activeTouches.length ? this._scroll.activeTouches[0] : undefined; for (var i = 0; i < event.changedTouches.length; i++) { var changedTouch = event.changedTouches[i]; for (var j = 0; j < this._scroll.activeTouches.length; j++) { var touch = this._scroll.activeTouches[j]; if (touch.id === changedTouch.identifier) { // Remove touch from active-touches this._scroll.activeTouches.splice(j, 1); // When a different touch now becomes the primary touch, update // its start position to match the current move offset. if ((j === 0) && this._scroll.activeTouches.length) { var newPrimaryTouch = this._scroll.activeTouches[0]; newPrimaryTouch.start[0] = newPrimaryTouch.current[0] - (touch.current[0] - touch.start[0]); newPrimaryTouch.start[1] = newPrimaryTouch.current[1] - (touch.current[1] - touch.start[1]); } break; } } } // Wait for all fingers to be released from the screen before resetting the move-spring if (!primaryTouch || this._scroll.activeTouches.length) { return; } // Determine velocity and add to particle var velocity = 0; var diffTime = primaryTouch.time - primaryTouch.prevTime; if ((diffTime > 0) && ((_getEventTimestamp(event) - primaryTouch.time) <= this.options.touchMoveNoVelocityDuration)) { var diffOffset = primaryTouch.current[this._direction] - primaryTouch.prev[this._direction]; velocity = diffOffset / diffTime; } // Release scroll force var delta = this._scroll.touchDelta; var swipeDirection = (Math.abs(primaryTouch.current[0] - primaryTouch.prev[0]) > Math.abs(primaryTouch.current[1] - primaryTouch.prev[1])) ? 0 : 1; var allowSwipes = (swipeDirection === this._direction); this.releaseScrollForce(delta, velocity, allowSwipes); this._scroll.touchDelta = 0; }
javascript
{ "resource": "" }
q59723
_scrollUpdate
validation
function _scrollUpdate(event) { if (!this.options.enabled) { return; } var offset = Array.isArray(event.delta) ? event.delta[this._direction] : event.delta; this.scroll(offset); }
javascript
{ "resource": "" }
q59724
_setParticle
validation
function _setParticle(position, velocity, phase) { if (position !== undefined) { //var oldPosition = this._scroll.particle.getPosition1D(); this._scroll.particleValue = position; this._scroll.particle.setPosition1D(position); //_log.call(this, 'setParticle.position: ', position, ' (old: ', oldPosition, ', delta: ', position - oldPosition, ', phase: ', phase, ')'); if (this._scroll.springValue !== undefined) { this._scroll.pe.wake(); } } if (velocity !== undefined) { var oldVelocity = this._scroll.particle.getVelocity1D(); if (oldVelocity !== velocity) { this._scroll.particle.setVelocity1D(velocity); //_log.call(this, 'setParticle.velocity: ', velocity, ' (old: ', oldVelocity, ', delta: ', velocity - oldVelocity, ', phase: ', phase, ')'); } } }
javascript
{ "resource": "" }
q59725
_calcScrollOffset
validation
function _calcScrollOffset(normalize, refreshParticle) { // When moving using touch-gestures, make the offset stick to the // finger. When the bounds is exceeded, decrease the scroll distance // by two. if (refreshParticle || (this._scroll.particleValue === undefined)) { this._scroll.particleValue = this._scroll.particle.getPosition1D(); this._scroll.particleValue = Math.round(this._scroll.particleValue * 1000) / 1000; } // do stuff var scrollOffset = this._scroll.particleValue; if (this._scroll.scrollDelta || this._scroll.normalizedScrollDelta) { scrollOffset += this._scroll.scrollDelta + this._scroll.normalizedScrollDelta; if (((this._scroll.boundsReached & Bounds.PREV) && (scrollOffset > this._scroll.springPosition)) || ((this._scroll.boundsReached & Bounds.NEXT) && (scrollOffset < this._scroll.springPosition)) || (this._scroll.boundsReached === Bounds.BOTH)) { scrollOffset = this._scroll.springPosition; } if (normalize) { if (!this._scroll.scrollDelta) { this._scroll.normalizedScrollDelta = 0; _setParticle.call(this, scrollOffset, undefined, '_calcScrollOffset'); } this._scroll.normalizedScrollDelta += this._scroll.scrollDelta; this._scroll.scrollDelta = 0; } } if (this._scroll.scrollForceCount && this._scroll.scrollForce) { if (this._scroll.springPosition !== undefined) { scrollOffset = (scrollOffset + this._scroll.scrollForce + this._scroll.springPosition) / 2.0; } else { scrollOffset += this._scroll.scrollForce; } } // Prevent the scroll position from exceeding the bounds when overscroll is disabled if (!this.options.overscroll) { if ((this._scroll.boundsReached === Bounds.BOTH) || ((this._scroll.boundsReached === Bounds.PREV) && (scrollOffset > this._scroll.springPosition)) || ((this._scroll.boundsReached === Bounds.NEXT) && (scrollOffset < this._scroll.springPosition))) { scrollOffset = this._scroll.springPosition; } } //_log.call(this, 'scrollOffset: ', scrollOffset, ', particle:', this._scroll.particle.getPosition1D(), ', moveToPosition: ', this._scroll.moveToPosition, ', springPosition: ', this._scroll.springPosition); return scrollOffset; }
javascript
{ "resource": "" }
q59726
_snapToPage
validation
function _snapToPage() { // Check whether pagination is active if (!this.options.paginated || this._scroll.scrollForceCount || //don't paginate while moving (this._scroll.springPosition !== undefined)) { return; } // When the energy is below the thresshold, paginate to the current page var item; switch (this.options.paginationMode) { case PaginationMode.SCROLL: if (!this.options.paginationEnergyThreshold || (Math.abs(this._scroll.particle.getEnergy()) <= this.options.paginationEnergyThreshold)) { item = this.options.alignment ? this.getLastVisibleItem() : this.getFirstVisibleItem(); if (item && item.renderNode) { this.goToRenderNode(item.renderNode); } } break; case PaginationMode.PAGE: item = this.options.alignment ? this.getLastVisibleItem() : this.getFirstVisibleItem(); if (item && item.renderNode) { this.goToRenderNode(item.renderNode); } break; } }
javascript
{ "resource": "" }
q59727
_normalizePrevViewSequence
validation
function _normalizePrevViewSequence(scrollOffset) { var count = 0; var normalizedScrollOffset = scrollOffset; var normalizeNextPrev = false; var node = this._nodes.getStartEnumNode(false); while (node) { if (!node._invalidated || !node._viewSequence) { break; } if (normalizeNextPrev) { this._viewSequence = node._viewSequence; normalizedScrollOffset = scrollOffset; normalizeNextPrev = false; } if ((node.scrollLength === undefined) || node.trueSizeRequested || (scrollOffset < 0)) { break; } scrollOffset -= node.scrollLength; count++; if (node.scrollLength) { if (this.options.alignment) { normalizeNextPrev = (scrollOffset >= 0); } else { if (Math.round(scrollOffset) >= 0) { this._viewSequence = node._viewSequence; normalizedScrollOffset = scrollOffset; } } } node = node._prev; } return normalizedScrollOffset; }
javascript
{ "resource": "" }
q59728
_getVisibleItem
validation
function _getVisibleItem(first) { var result = {}; var diff; var prevDiff = 10000000; var diffDelta = (first && this.options.alignment) ? -this._contextSizeCache[this._direction] : ((!first && !this.options.alignment) ? this._contextSizeCache[this._direction] : 0); var scrollOffset = this._scroll.unnormalizedScrollOffset; var node = this._nodes.getStartEnumNode(true); while (node) { if (!node._invalidated || (node.scrollLength === undefined)) { break; } if (node._viewSequence) { diff = Math.abs(diffDelta - (scrollOffset + (!first ? node.scrollLength : 0))); if (diff >= prevDiff) { break; } prevDiff = diff; result.scrollOffset = scrollOffset; result._node = node; scrollOffset += node.scrollLength; } node = node._next; } scrollOffset = this._scroll.unnormalizedScrollOffset; node = this._nodes.getStartEnumNode(false); while (node) { if (!node._invalidated || (node.scrollLength === undefined)) { break; } if (node._viewSequence) { scrollOffset -= node.scrollLength; diff = Math.abs(diffDelta - (scrollOffset + (!first ? node.scrollLength : 0))); if (diff >= prevDiff) { break; } prevDiff = diff; result.scrollOffset = scrollOffset; result._node = node; } node = node._prev; } if (!result._node) { return undefined; } result.scrollLength = result._node.scrollLength; if (this.options.alignment) { result.visiblePerc = (Math.min(result.scrollOffset + result.scrollLength, 0) - Math.max(result.scrollOffset, -this._contextSizeCache[this._direction])) / result.scrollLength; } else { result.visiblePerc = (Math.min(result.scrollOffset + result.scrollLength, this._contextSizeCache[this._direction]) - Math.max(result.scrollOffset, 0)) / result.scrollLength; } result.index = result._node._viewSequence.getIndex(); result.viewSequence = result._node._viewSequence; result.renderNode = result._node.renderNode; return result; }
javascript
{ "resource": "" }
q59729
_goToSequence
validation
function _goToSequence(viewSequence, next, noAnimation) { if (noAnimation) { this._viewSequence = viewSequence; this._scroll.springPosition = undefined; _updateSpring.call(this); this.halt(); this._scroll.scrollDelta = 0; _setParticle.call(this, 0, 0, '_goToSequence'); this._scroll.scrollDirty = true; } else { this._scroll.scrollToSequence = viewSequence; this._scroll.scrollToRenderNode = viewSequence.get(); this._scroll.ensureVisibleRenderNode = undefined; this._scroll.scrollToDirection = next; this._scroll.scrollDirty = true; } }
javascript
{ "resource": "" }
q59730
_ensureVisibleSequence
validation
function _ensureVisibleSequence(viewSequence, next) { this._scroll.scrollToSequence = undefined; this._scroll.scrollToRenderNode = undefined; this._scroll.ensureVisibleRenderNode = viewSequence.get(); this._scroll.scrollToDirection = next; this._scroll.scrollDirty = true; }
javascript
{ "resource": "" }
q59731
_goToPage
validation
function _goToPage(amount, noAnimation) { // Get current scroll-position. When a previous call was made to // `scroll' or `scrollTo` and that node has not yet been reached, then // the amount is accumalated onto that scroll target. var viewSequence = (!noAnimation ? this._scroll.scrollToSequence : undefined) || this._viewSequence; if (!this._scroll.scrollToSequence && !noAnimation) { var firstVisibleItem = this.getFirstVisibleItem(); if (firstVisibleItem) { viewSequence = firstVisibleItem.viewSequence; if (((amount < 0) && (firstVisibleItem.scrollOffset < 0)) || ((amount > 0) && (firstVisibleItem.scrollOffset > 0))) { amount = 0; } } } if (!viewSequence) { return; } // Find scroll target for (var i = 0; i < Math.abs(amount); i++) { var nextViewSequence = (amount > 0) ? viewSequence.getNext() : viewSequence.getPrevious(); if (nextViewSequence) { viewSequence = nextViewSequence; } else { break; } } _goToSequence.call(this, viewSequence, amount >= 0, noAnimation); }
javascript
{ "resource": "" }
q59732
_innerRender
validation
function _innerRender() { var specs = this._specs; for (var i3 = 0, j3 = specs.length; i3 < j3; i3++) { if (specs[i3].renderNode) { specs[i3].target = specs[i3].renderNode.render(); } } // Add our cleanup-registration id also to the list, so that the // cleanup function is called by famo.us when the LayoutController is // removed from the render-tree. if (!specs.length || (specs[specs.length-1] !== this._cleanupRegistration)) { specs.push(this._cleanupRegistration); } return specs; }
javascript
{ "resource": "" }
q59733
_setPullToRefreshState
validation
function _setPullToRefreshState(pullToRefresh, state) { if (pullToRefresh.state !== state) { pullToRefresh.state = state; if (pullToRefresh.node && pullToRefresh.node.setPullToRefreshStatus) { pullToRefresh.node.setPullToRefreshStatus(state); } } }
javascript
{ "resource": "" }
q59734
ViewStackLayout
validation
function ViewStackLayout(context, options) { var set = { size: context.size, translate: [0, 0, 0] }; this._size[0] = context.size[0]; this._size[1] = context.size[1]; var views = context.get('views'); var transferables = context.get('transferables'); var visibleCount = 0; for (var i = 0; i < views.length; i++) { var item = this._viewStack[i]; switch (item.state) { case ItemState.HIDDEN: context.set(views[i], { size: context.size, translate: [context.size[0] * 2, context.size[1] * 2, 0] }); break; case ItemState.HIDE: case ItemState.HIDING: case ItemState.VISIBLE: case ItemState.SHOW: case ItemState.SHOWING: if (visibleCount < 2) { visibleCount++; // Layout view var view = views[i]; context.set(view, set); // Layout any transferables for (var j = 0; j < transferables.length; j++) { for (var k = 0; k < item.transferables.length; k++) { if (transferables[j].renderNode === item.transferables[k].renderNode) { context.set(transferables[j], { translate: [0, 0, set.translate[2]], size: [context.size[0], context.size[1]] }); } } } // Increase z-index for next view set.translate[2] += options.zIndexOffset; } break; } } }
javascript
{ "resource": "" }
q59735
_createLayout
validation
function _createLayout() { this._renderables = { views: [], transferables: [] }; this._viewStack = []; this.layout = new LayoutController({ layout: ViewStackLayout.bind(this), layoutOptions: this.options, dataSource: this._renderables }); this.add(this.layout); this.layout.on('layoutend', _processAnimations.bind(this)); }
javascript
{ "resource": "" }
q59736
_getViewSpec
validation
function _getViewSpec(item, view, id, callback) { if (!item.view) { return; } var spec = view.getSpec(id); if (spec && !spec.trueSizeRequested) { callback(spec); } else { Timer.after(_getViewSpec.bind(this, item, view, id, callback), 1); } }
javascript
{ "resource": "" }
q59737
_getTransferable
validation
function _getTransferable(item, view, id) { // 1. If view supports getTransferable, use that if (view.getTransferable) { return view.getTransferable(id); } // 2. If view is derived from layoutcontroller, use that if (view.getSpec && view.get && view.replace) { if (view.get(id) !== undefined) { return { get: function() { return view.get(id); }, show: function(renderable) { view.replace(id, renderable); }, getSpec: _getViewSpec.bind(this, item, view, id) }; } } // 3. If view has an embedded layout, use that as fallback if (view.layout) { return _getTransferable.call(this, item, view.layout, id); } }
javascript
{ "resource": "" }
q59738
_initTransferableAnimations
validation
function _initTransferableAnimations(item, prevItem, callback) { var callbackCount = 0; function waitForAll() { callbackCount--; if (callbackCount === 0) { callback(); } } for (var sourceId in item.options.transfer.items) { if (_initTransferableAnimation.call(this, item, prevItem, sourceId, waitForAll)) { callbackCount++; } } if (!callbackCount) { callback(); } }
javascript
{ "resource": "" }
q59739
_endTransferableAnimations
validation
function _endTransferableAnimations(item) { for (var j = 0; j < item.transferables.length; j++) { var transferable = item.transferables[j]; for (var i = 0; i < this._renderables.transferables.length; i++) { if (this._renderables.transferables[i] === transferable.renderNode) { this._renderables.transferables.splice(i, 1); break; } } transferable.source.show(transferable.originalSource); transferable.target.show(transferable.originalTarget); } item.transferables = []; this.layout.reflowLayout(); }
javascript
{ "resource": "" }
q59740
_processAnimations
validation
function _processAnimations(event) { var prevItem; for (var i = 0; i < this._viewStack.length; i++) { var item = this._viewStack[i]; switch (item.state) { case ItemState.HIDE: item.state = ItemState.HIDING; _initHideAnimation.call(this, item, prevItem, event.size); _updateState.call(this); break; case ItemState.SHOW: item.state = ItemState.SHOWING; _initShowAnimation.call(this, item, prevItem, event.size); _updateState.call(this); break; } prevItem = item; } }
javascript
{ "resource": "" }
q59741
_initShowAnimation
validation
function _initShowAnimation(item, prevItem, size) { var spec = item.options.show.animation ? item.options.show.animation.call(undefined, true, size) : {}; item.startSpec = spec; item.endSpec = { opacity: 1, transform: Transform.identity }; item.mod.halt(); if (spec.transform) { item.mod.setTransform(spec.transform); } if (spec.opacity !== undefined) { item.mod.setOpacity(spec.opacity); } if (spec.align) { item.mod.setAlign(spec.align); } if (spec.origin) { item.mod.setOrigin(spec.origin); } var startShowAnimation = _startShowAnimation.bind(this, item, spec); var waitAndShow = item.wait ? function() { item.wait.then(startShowAnimation, startShowAnimation); } : startShowAnimation; if (prevItem) { _initTransferableAnimations.call(this, item, prevItem, waitAndShow); } else { waitAndShow(); } }
javascript
{ "resource": "" }
q59742
_startShowAnimation
validation
function _startShowAnimation(item, spec) { if (!item.halted) { var callback = item.showCallback; if (spec.transform) { item.mod.setTransform(Transform.identity, item.options.show.transition, callback); callback = undefined; } if (spec.opacity !== undefined) { item.mod.setOpacity(1, item.options.show.transition, callback); callback = undefined; } _startTransferableAnimations.call(this, item, callback); } }
javascript
{ "resource": "" }
q59743
_haltItemAtFrame
validation
function _haltItemAtFrame(item, perc) { item.mod.halt(); item.halted = true; if (item.startSpec && (perc !== undefined)) { if ((item.startSpec.opacity !== undefined) && (item.endSpec.opacity !== undefined)) { item.mod.setOpacity(_interpolate(item.startSpec.opacity, item.endSpec.opacity, perc)); } if (item.startSpec.transform && item.endSpec.transform) { var transform = []; for (var i = 0; i < item.startSpec.transform.length; i++) { transform.push(_interpolate(item.startSpec.transform[i], item.endSpec.transform[i], perc)); } item.mod.setTransform(transform); } } }
javascript
{ "resource": "" }
q59744
_initHideAnimation
validation
function _initHideAnimation(item, prevItem, size) { var startHideAnimation = _startHideAnimation.bind(this, item, prevItem, size); if (item.wait) { item.wait.then(startHideAnimation, startHideAnimation); } else { startHideAnimation(); } }
javascript
{ "resource": "" }
q59745
_startHideAnimation
validation
function _startHideAnimation(item, prevItem, size) { var spec = item.options.hide.animation ? item.options.hide.animation.call(undefined, false, size) : {}; item.endSpec = spec; item.startSpec = { opacity: 1, transform: Transform.identity }; if (!item.halted) { item.mod.halt(); var callback = item.hideCallback; if (spec.transform) { item.mod.setTransform(spec.transform, item.options.hide.transition, callback); callback = undefined; } if (spec.opacity !== undefined) { item.mod.setOpacity(spec.opacity, item.options.hide.transition, callback); callback = undefined; } if (callback) { callback(); } } }
javascript
{ "resource": "" }
q59746
_setItemOptions
validation
function _setItemOptions(item, options, callback) { item.options = { show: { transition: this.options.show.transition || this.options.transition, animation: this.options.show.animation || this.options.animation }, hide: { transition: this.options.hide.transition || this.options.transition, animation: this.options.hide.animation || this.options.animation }, transfer: { transition: this.options.transfer.transition || this.options.transition, items: this.options.transfer.items || {}, zIndex: this.options.transfer.zIndex, fastResize: this.options.transfer.fastResize } }; if (options) { item.options.show.transition = (options.show ? options.show.transition : undefined) || options.transition || item.options.show.transition; if (options && options.show && (options.show.animation !== undefined)) { item.options.show.animation = options.show.animation; } else if (options && (options.animation !== undefined)) { item.options.show.animation = options.animation; } item.options.transfer.transition = (options.transfer ? options.transfer.transition : undefined) || options.transition || item.options.transfer.transition; item.options.transfer.items = (options.transfer ? options.transfer.items : undefined) || item.options.transfer.items; item.options.transfer.zIndex = (options.transfer && (options.transfer.zIndex !== undefined)) ? options.transfer.zIndex : item.options.transfer.zIndex; item.options.transfer.fastResize = (options.transfer && (options.transfer.fastResize !== undefined)) ? options.transfer.fastResize : item.options.transfer.fastResize; } item.showCallback = function() { item.showCallback = undefined; item.state = ItemState.VISIBLE; _updateState.call(this); _endTransferableAnimations.call(this, item); item.endSpec = undefined; item.startSpec = undefined; if (callback) { callback(); } }.bind(this); }
javascript
{ "resource": "" }
q59747
_updateState
validation
function _updateState() { var prevItem; var invalidated = false; var hiddenViewCount = 0; var i = 0; while (i < this._viewStack.length) { if (this._viewStack[i].state === ItemState.HIDDEN) { hiddenViewCount++; for (var j = 0; j < this._viewStack.length; j++) { if ((this._viewStack[j].state !== ItemState.HIDDEN) && (this._viewStack[j].view === this._viewStack[i].view)) { this._viewStack[i].view = undefined; this._renderables.views.splice(i, 1); this._viewStack.splice(i, 1); i--; hiddenViewCount--; break; } } } i++; } while (hiddenViewCount > this.options.keepHiddenViewsInDOMCount) { this._viewStack[0].view = undefined; this._renderables.views.splice(0, 1); this._viewStack.splice(0, 1); hiddenViewCount--; } for (i = hiddenViewCount; i < (Math.min(this._viewStack.length - hiddenViewCount, 2) + hiddenViewCount); i++) { var item = this._viewStack[i]; if (item.state === ItemState.QUEUED) { if (!prevItem || (prevItem.state === ItemState.VISIBLE) || (prevItem.state === ItemState.HIDING)) { if (prevItem && (prevItem.state === ItemState.VISIBLE)) { prevItem.state = ItemState.HIDE; prevItem.wait = item.wait; } item.state = ItemState.SHOW; invalidated = true; } break; } else if ((item.state === ItemState.VISIBLE) && item.hide) { item.state = ItemState.HIDE; } if ((item.state === ItemState.SHOW) || (item.state === ItemState.HIDE)) { this.layout.reflowLayout(); } prevItem = item; } if (invalidated) { _updateState.call(this); this.layout.reflowLayout(); } }
javascript
{ "resource": "" }
q59748
Base
validation
function Base(options) { this._eventOutput = new EventHandler(); this._pool = []; EventHandler.setOutputHandler(this, this._eventOutput); if (options) { for (var key in options) { this[key] = options[key]; } } }
javascript
{ "resource": "" }
q59749
_getDateFromScrollWheels
validation
function _getDateFromScrollWheels() { var date = new Date(this._date); for (var i = 0; i < this.scrollWheels.length; i++) { var scrollWheel = this.scrollWheels[i]; var component = scrollWheel.component; var item = scrollWheel.scrollController.getFirstVisibleItem(); if (item && item.renderNode) { component.setComponent(date, component.getComponent(item.renderNode.date)); } } return date; }
javascript
{ "resource": "" }
q59750
_createLayout
validation
function _createLayout() { this.container = new ContainerSurface( this.options.container ); this.container.setClasses(this.classes); this.layout = new LayoutController({ layout: ProportionalLayout, layoutOptions: { ratios: [] }, direction: Utility.Direction.X }); this.container.add(this.layout); this.add(this.container); }
javascript
{ "resource": "" }
q59751
_clickItem
validation
function _clickItem(scrollWheel, event) { if (scrollWheel && event && event.target) { scrollWheel.scrollController.goToRenderNode(event.target); } }
javascript
{ "resource": "" }
q59752
_createOverlay
validation
function _createOverlay() { this.overlay = new LayoutController({ layout: OverlayLayout, layoutOptions: { itemSize: this.options.wheelLayout.itemSize }, dataSource: this._overlayRenderables }); this.add(this.overlay); }
javascript
{ "resource": "" }
q59753
_setSelectedItem
validation
function _setSelectedItem(index) { if (index !== this._selectedItemIndex) { var oldIndex = this._selectedItemIndex; this._selectedItemIndex = index; this.layout.setLayoutOptions({ selectedItemIndex: index }); if ((oldIndex >= 0) && this._renderables.items[oldIndex].removeClass){ this._renderables.items[oldIndex].removeClass('selected'); } if (this._renderables.items[index].addClass) { this._renderables.items[index].addClass('selected'); } if (oldIndex >= 0) { this._eventOutput.emit('tabchange', { target: this, index: index, oldIndex: oldIndex, item: this._renderables.items[index], oldItem: ((oldIndex >= 0) && (oldIndex < this._renderables.items.length)) ? this._renderables.items[oldIndex] : undefined }); } } }
javascript
{ "resource": "" }
q59754
_setListeners
validation
function _setListeners() { this.tabBar.on('tabchange', function(event) { _updateView.call(this, event); this._eventOutput.emit('tabchange', { target: this, index: event.index, oldIndex: event.oldIndex, item: this._items[event.index], oldItem: ((event.oldIndex >= 0) && (event.oldIndex < this._items.length)) ? this._items[event.oldIndex] : undefined }); }.bind(this)); }
javascript
{ "resource": "" }
q59755
_updateView
validation
function _updateView(event) { var index = this.tabBar.getSelectedItemIndex(); this.animationController.halt(); if (index >= 0) { this.animationController.show(this._items[index].view); } else { this.animationController.hide(); } }
javascript
{ "resource": "" }
q59756
_resolveNodeSize
validation
function _resolveNodeSize(node) { var localItemSize = itemSize; if (getItemSize) { localItemSize = getItemSize(node.renderNode, size); } if ((localItemSize[0] === true) || (localItemSize[1] === true)) { var result = context.resolveSize(node, size); if (localItemSize[0] !== true) { result[0] = itemSize[0]; } if (localItemSize[1] !== true) { result[1] = itemSize[1]; } return result; } else { return localItemSize; } }
javascript
{ "resource": "" }
q59757
FontLayout
validation
function FontLayout(context, options) { // Prepare size = context.size; direction = context.direction; text = options.text || 'KLMNOPQRSTUVW'; spacing = (options.spacing === undefined) ? 10 : options.spacing; offset = 0; set.size[0] = options.segmentSize ? options.segmentSize[0] : 20; set.size[1] = options.segmentSize ? options.segmentSize[1] : 4; for (var i = 0; i < text.length; i++) { var charSegments = charMap[text.charAt(i)] || charMap['?']; for (var j = 0; j < 8; j++) { if (charSegments & (1 << j)) { node = context.next(); if (!node) { return; } var segment = segmentMap[j]; set.translate[0] = (set.size[0] * segment[0]) + (segment[3] * set.size[1]); set.translate[1] = (set.size[0] * segment[1]) + (segment[4] * set.size[1]); set.translate[direction] += offset; set.rotate[2] = (segment[2] * Math.PI * 2); set.scrollLength = i ? 0 : (direction ? (set.size[0] * 2) : set.size[1]); if ((j === 0) && (i < (text.length - 1))) { set.scrollLength += spacing; } context.set(node, set); } } // Advance offset for next character offset += (direction ? (set.size[0] * 2) : set.size[0]) + spacing; } }
javascript
{ "resource": "" }
q59758
removeFromExports
validation
function removeFromExports(exports, dependencies = {}) { const localExports = { ...exports }; Object.keys(localExports).forEach((exported) => { if (dependencies[exported]) { delete localExports[exported]; } }); return localExports; }
javascript
{ "resource": "" }
q59759
encode
validation
function encode (payload) { var checksum = checksumFn(payload) return base58.encode(Buffer.concat([ payload, checksum ], payload.length + 4)) }
javascript
{ "resource": "" }
q59760
main
validation
function main() { return new Promise((resolve) => { fsx.readFile(path.resolve(__dirname, '../package.json'), 'utf8', (err, data) => { if (err) { throw err; } resolve(data); }); }) .then((data) => JSON.parse(data)) .then((packageData) => { const { author, version, description, keywords, repository, license, bugs, homepage, peerDependencies, dependencies, } = packageData; const minimalPackage = { name: '@boundlessgeo/sdk', author, version, description, keywords, repository, license, bugs, homepage, peerDependencies, dependencies, }; return new Promise((resolve) => { const buildPath = path.resolve(__dirname, '../dist/package.json'); const data = JSON.stringify(minimalPackage, null, 2); fsx.writeFile(buildPath, data, (err) => { if (err) { throw (err); } process.stdout.write(`Created package.json in ${buildPath}\n`); resolve(); }); }); }); }
javascript
{ "resource": "" }
q59761
authTileLoader
validation
function authTileLoader(fetchOptions) { return function(tile, src) { fetch(src, fetchOptions) .then(r => r.blob()) .then((imgData) => { tile.getImage().src = URL.createObjectURL(imgData); }) .catch(() => { console.error('Error fetchimg image at:', src); }); }; }
javascript
{ "resource": "" }
q59762
authVectorTileLoader
validation
function authVectorTileLoader(fetchOptions) { return function(tile, url) { const loader = () => { fetch(url, fetchOptions) .then(r => r.arrayBuffer()) .then((source) => { const format = tile.getFormat(); tile.setProjection(format.readProjection(source)); tile.setFeatures(format.readFeatures(source)); tile.setExtent(format.getLastExtent()); }) .catch((err) => { tile.onError(); }); }; tile.setLoader(loader); }; }
javascript
{ "resource": "" }
q59763
configureGeojsonSource
validation
function configureGeojsonSource(glSource, mapView, baseUrl, wrapX, fetchOptions) { const use_bbox = (typeof glSource.data === 'string' && glSource.data.indexOf(BBOX_STRING) >= 0); const vector_src = new VectorSource({ strategy: use_bbox ? bboxStrategy : allStrategy, loader: getLoaderFunction(glSource, mapView.getProjection(), baseUrl, fetchOptions), useSpatialIndex: true, wrapX: wrapX, }); // GeoJson sources can be clustered but OpenLayers // uses a special source type for that. This handles the // "switch" of source-class. let new_src = vector_src; if (glSource.cluster) { new_src = new ClusterSource({ source: vector_src, // default the distance to 50 as that's what // is specified by Mapbox. distance: glSource.clusterRadius ? glSource.clusterRadius : 50, }); } // seed the vector source with the first update // before returning it. updateGeojsonSource(new_src, glSource, mapView, baseUrl, fetchOptions); return new_src; }
javascript
{ "resource": "" }
q59764
hydrateLayerGroup
validation
function hydrateLayerGroup(layersDef, layerGroup) { const hydrated_group = []; for (let i = 0, ii = layerGroup.length; i < ii; i++) { // hydrateLayer checks for "ref" hydrated_group.push(hydrateLayer(layersDef, layerGroup[i])); } return hydrated_group; }
javascript
{ "resource": "" }
q59765
incrementVersion
validation
function incrementVersion(metadata, version) { const new_metadata = Object.assign({}, metadata); new_metadata[version] = getVersion(metadata, version) + 1; return { metadata: new_metadata, }; }
javascript
{ "resource": "" }
q59766
placeLayer
validation
function placeLayer(state, layer, targetId) { const new_layers = state.layers.slice(); const idx1 = getLayerIndexById(new_layers, layer.id); const idx2 = getLayerIndexById(new_layers, targetId); if (idx1 !== -1) { new_layers.splice(idx1, 1); } const newIndex = (targetId && idx2 !== -1) ? idx2 : new_layers.length; new_layers.splice(newIndex, 0, layer); return Object.assign({}, state, { layers: new_layers, }, incrementVersion(state.metadata, LAYER_VERSION_KEY)); }
javascript
{ "resource": "" }
q59767
moveGroup
validation
function moveGroup(state, action) { const place_at = getLayerIndexById(state.layers, action.placeAt); const n_layers = state.layers.length; // sanity check the new index. if (place_at < 0 || place_at > n_layers) { return state; } // find the starting and ending points of the group let group_start = null; let group_end = null; for (let i = 0, ii = n_layers; i < ii; i++) { const group = getGroup(state.layers[i]); if (group === action.group) { if (group_start === null || i < group_start) { group_start = i; } if (group_end === null || i > group_end) { group_end = i; } } } // get the real index of the next spot for the group, // if the placeAt index is mid group then place_at should // be the index of the FIRST member of that group. let place_start = place_at; const place_group = getGroup(state.layers[place_at]); const place_ahead = (place_at > group_start); // when placing a group before or after another group // the bounds of the target group needs to be found and the // appropriate index chosen based on the direction of placement. if (place_group) { let new_place = -1; if (place_ahead) { for (let i = n_layers - 1; i >= 0 && new_place < 0; i--) { if (getGroup(state.layers[i]) === place_group) { new_place = i; } } } else { for (let i = 0, ii = n_layers; i < ii && new_place < 0; i++) { if (getGroup(state.layers[i]) === place_group) { new_place = i; } } } place_start = new_place; } // build a new array for the layers. let new_layers = []; // have the group layers ready to concat. const group_layers = state.layers.slice(group_start, group_end + 1); for (let i = 0, ii = n_layers; i < ii; i++) { const layer = state.layers[i]; const in_group = (getGroup(layer) === action.group); if (place_ahead && !in_group) { new_layers.push(layer); } if (i === place_start) { new_layers = new_layers.concat(group_layers); } if (!place_ahead && !in_group) { new_layers.push(layer); } } return Object.assign({}, state, { layers: new_layers, }, incrementVersion(state.metadata, LAYER_VERSION_KEY)); }
javascript
{ "resource": "" }
q59768
changeData
validation
function changeData(state, sourceName, data) { const source = state.sources[sourceName]; if (!source) { return state; } const src_mixin = {}; // update the individual source. src_mixin[sourceName] = Object.assign({}, source, { data, }); // kick back the new state. return Object.assign({}, state, { sources: Object.assign({}, state.sources, src_mixin), }, incrementVersion(state.metadata, dataVersionKey(sourceName))); }
javascript
{ "resource": "" }
q59769
mapDispatchToProps
validation
function mapDispatchToProps(dispatch) { return { moveSlide: (count) => { dispatch(bookmarkAction.moveSlide(count)); }, zoomTo: (coords, zoomLevel) => { dispatch(mapActions.setView(coords, zoomLevel)); } }; }
javascript
{ "resource": "" }
q59770
addPoints
validation
function addPoints(sourceName, n_points = 10) { for (let i = 0; i < n_points; i++) { // the feature is a normal GeoJSON feature definition store.dispatch(mapActions.addFeatures(sourceName, [{ type: 'Feature', properties: { id: `point${i}`, title: 'Random Point', }, geometry: { type: 'Point', // this generates a point somewhere on the planet, unbounded. coordinates: [(Math.random() * 360) - 180, (Math.random() * 180) - 90], }, }])); } }
javascript
{ "resource": "" }
q59771
stripZeros
validation
function stripZeros(aInput) { var a = aInput; // eslint-disable-line var first = a[0]; // eslint-disable-line while (a.length > 0 && first.toString() === '0') { a = a.slice(1); first = a[0]; } return a; }
javascript
{ "resource": "" }
q59772
decodeParams
validation
function decodeParams(names, types, data, useNumberedParams = true) { // Names is optional, so shift over all the parameters if not provided if (arguments.length < 3) { data = types; types = names; names = []; } data = utils.hexOrBuffer(data); var values = new Result(); var offset = 0; types.forEach(function(type, index) { var coder = getParamCoder(type); if (coder.dynamic) { var dynamicOffset = uint256Coder.decode(data, offset); var result = coder.decode(data, dynamicOffset.value.toNumber()); offset += dynamicOffset.consumed; } else { var result = coder.decode(data, offset); offset += result.consumed; } if (useNumberedParams) { values[index] = result.value; } if (names[index]) { values[names[index]] = result.value; } }); return values; }
javascript
{ "resource": "" }
q59773
encodeSignature
validation
function encodeSignature(method) { const signature = `${method.name}(${utils.getKeys(method.inputs, 'type').join(',')})`; const signatureEncoded = `0x${(new Buffer(utils.keccak256(signature), 'hex')).slice(0, 4).toString('hex')}`; return signatureEncoded; }
javascript
{ "resource": "" }
q59774
encodeMethod
validation
function encodeMethod(method, values) { const paramsEncoded = encodeParams(utils.getKeys(method.inputs, 'type'), values).substring(2); return `${encodeSignature(method)}${paramsEncoded}`; }
javascript
{ "resource": "" }
q59775
decodeLogItem
validation
function decodeLogItem(eventObject, log, useNumberedParams = true) { if (eventObject && log.topics[0] === eventSignature(eventObject)) { return decodeEvent(eventObject, log.data, log.topics, useNumberedParams) } }
javascript
{ "resource": "" }
q59776
logDecoder
validation
function logDecoder(abi, useNumberedParams = true) { const eventMap = {} abi.filter(item => item.type === 'event').map(item => { eventMap[eventSignature(item)] = item }) return function(logItems) { return logItems.map(log => decodeLogItem(eventMap[log.topics[0]], log, useNumberedParams)).filter(i => i) } }
javascript
{ "resource": "" }
q59777
loader
validation
function loader(content) { const { addDependency, resource, resourcePath } = this; // Get callback because the SVG is going to be optimized and that is an async operation const callback = this.async(); // Parse the loader query and apply the default values in case no values are provided const { iconName, publicPath, sprite, svgoOptions } = Object.assign({}, DEFAULT_LOADER_OPTIONS, loaderUtils.getOptions(this)); // Add the icon as a dependency addDependency(resourcePath); // Start optimizing the SVG file imagemin .buffer(content, { plugins: [ imageminSvgo(svgoOptions), ], }) .then((content) => { // Create the icon name with the hash of the optimized content const name = loaderUtils.interpolateName(this, iconName, { content }); // Register the icon using its resource path with query as id // so that tools like: `svg-transform-loader` can be used in combination with this loader. const icon = sprite.addIcon(resource, name, content.toString()); // Export the icon as a metadata object that contains urls to be used on an <img/> in HTML or url() in CSS // If the outputted file is not hashed and to support hot module reload, we must force the browser // to re-download the sprite on subsequent compilations // We do this by adding a cache busting on the URL, with the following pattern: img/sprite.svg?icon-abcd#icon-abcd // It's important that the cache busting is not included initially so that it plays well with server-side rendering, // otherwise many view libraries will complain about mismatches during rehydration (such as React) const hasSamePath = sprite.originalResourcePath === sprite.resourcePath; setImmediate(() => { callback( null, `var publicPath = ${publicPath ? `'${publicPath}'` : '__webpack_public_path__'}; var symbolUrl = '${icon.getUrlToSymbol()}'; var viewUrl = '${icon.getUrlToView()}'; ${process.env.NODE_ENV !== 'production' && hasSamePath ? ` var addCacheBust = typeof document !== 'undefined' && document.readyState === 'complete'; if (addCacheBust) { symbolUrl = '${icon.getUrlToSymbol(true)}'; viewUrl = '${icon.getUrlToView(true)}'; } ` : '' } module.exports = { symbol: publicPath + symbolUrl, view: publicPath + viewUrl, viewBox: '${icon.getDocument().getViewBox()}', title: '${icon.getDocument().getTitle()}', toString: function () { return JSON.stringify(this.view); } };` ); }); }) .catch((err) => { setImmediate(() => callback(err)); }); }
javascript
{ "resource": "" }
q59778
validation
function() { var client = redis.client(); return client.keysAsync('bull:*:id').then(function(keys) { return _.map(keys, function(key) { return key.slice(5, -3); }); }); }
javascript
{ "resource": "" }
q59779
validation
function(qName) { if (!qName || qName.length === 0) { throw new Error('You must specify a queue name.'); } var client = redis.client(); return client.keysAsync('bull:' + qName + ':*').then(function(keys) { if (keys.length) { return client.del(keys); } }); }
javascript
{ "resource": "" }
q59780
validation
function(qName) { if (this._q.name !== qName) { this._q.name = qName; var queueOpts = { redis: { host: redis.redisOpts.host, port: redis.redisOpts.port, DB: redis.redisOpts.db, opts: { auth_pass: redis.redisOpts.auth_pass } } }; this._q.instance = new bull(qName, queueOpts); } return this._q.instance; }
javascript
{ "resource": "" }
q59781
validation
function(qName, id) { var q = queue.get(qName); return q.getJob(id).then(function(job) { if (!job) { return job; } return job.getState().then(function(state) { job.state = state; return job; }); }); }
javascript
{ "resource": "" }
q59782
validation
function(qName, data, opts) { var q = queue.get(qName); return q.add(data, opts).then(function(job) { if (!job) { return job; } return job.getState().then(function(state) { job.state = state; return job; }); }); }
javascript
{ "resource": "" }
q59783
validation
function(qName, id) { var q = queue.get(qName); return q.getJob(id).then(function(job) { return job.remove(); }); }
javascript
{ "resource": "" }
q59784
validation
function(qName, type) { var client = redis.client(); var key = 'bull:' + qName + ':' + type; if (type === 'wait' || type === 'active') { return client.llenAsync(key); } else if (type === 'delayed') { return client.zcardAsync(key); } else if (type === 'completed' || type === 'failed') { return client.scardAsync(key); } throw new Error('You must provide a valid job type.'); }
javascript
{ "resource": "" }
q59785
validation
function(qName, type, offset, limit) { var q = queue.get(qName); if (!(offset >= 0)) { offset = 0; } if (!(limit >= 0)) { limit = 30; } if (type === 'wait' || type === 'active') { return q.getJobs(type, 'LIST', offset, offset + limit - 1).then(function(jobs) { return Promise.all(_.map(jobs, function(job) { if (!job) { return null; } return job.getState().then(function(state) { job.state = state; return job; }); })); }); } else if (type === 'delayed') { return q.getJobs(type, 'ZSET', offset, offset + limit - 1).then(function(jobs) { return Promise.all(_.map(jobs, function(job) { if (!job) { return null; } return job.getState().then(function(state) { job.state = state; return job; }); })); }); } else if (type === 'completed' || type === 'failed') { var client = redis.client(); var key = 'bull:' + qName + ':' + type; return client.smembersAsync(key).then(function(ids) { var _ids = ids.slice(offset, offset + limit); return Promise.all(_.map(_ids, function(id) { return q.getJob(id).then(function(job) { if (!job) { return null; } return job.getState().then(function(state) { job.state = state; return job; }); }); })); }); } throw new Error('You must provide a valid job type.'); }
javascript
{ "resource": "" }
q59786
validation
function(opts) { this._client = Promise.promisifyAll(redis.createClient(opts)); if (opts.db) { this._client.selectAsync(opts.db); } this.redisOpts = opts; }
javascript
{ "resource": "" }
q59787
validation
function() { var multi = this._client.multi(); multi.execAsync = Promise.promisify(multi.exec); return multi; }
javascript
{ "resource": "" }
q59788
ial
validation
function ial(app, opts) { /** * Lazily creates an i18n. * * @api public */ Object.defineProperty(app.context, 'i18n', { get: function () { if (this._i18n) { return this._i18n } const i18n = new I18n(opts) i18n.request = this.request this._i18n = i18n // merge into ctx.state this.state.i18n = i18n registerMethods(this.state, i18n) debug('app.ctx.i18n %j', i18n) return i18n } }) Object.defineProperty(app.request, 'i18n', { get: function () { return this.ctx.i18n } }) return function i18nMiddleware(ctx, next) { ctx.i18n.whitelist.some(key => { const customLocaleMethod = typeof key === 'function' && ctx.i18n.setLocale(key.apply(ctx)) if (customLocaleMethod || ctx.i18n[SET_PREFIX + key]()) return true }) return next() } }
javascript
{ "resource": "" }
q59789
handleGroup
validation
function handleGroup(self, group, width, maxColumns) { if (group.length === 0) { return; } var minRows = Math.ceil(group.length / maxColumns); for (var row = 0; row < minRows; row++) { for (var col = 0; col < maxColumns; col++) { var idx = row * maxColumns + col; if (idx >= group.length) { break; } var item = group[idx]; self._writeToOutput(item); if (col < maxColumns - 1) { for (var s = 0; s < width - item.length; s++) { self._writeToOutput(' '); } } } self._writeToOutput('\r\n'); } self._writeToOutput('\r\n'); }
javascript
{ "resource": "" }
q59790
emitKeypressEvents
validation
function emitKeypressEvents(stream, iface) { if (stream[KEYPRESS_DECODER]) return; if (StringDecoder === undefined) StringDecoder = require('string_decoder').StringDecoder; stream[KEYPRESS_DECODER] = new StringDecoder('utf8'); stream[ESCAPE_DECODER] = emitKeys(stream); stream[ESCAPE_DECODER].next(); const escapeCodeTimeout = () => stream[ESCAPE_DECODER].next(''); let timeoutId; function onData(b) { if (stream.listenerCount('keypress') > 0) { var r = stream[KEYPRESS_DECODER].write(b); if (r) { clearTimeout(timeoutId); if (iface) { iface._sawKeyPress = r.length === 1; } for (var i = 0; i < r.length; i++) { if (r[i] === '\t' && typeof r[i + 1] === 'string' && iface) { iface.isCompletionEnabled = false; } try { stream[ESCAPE_DECODER].next(r[i]); // Escape letter at the tail position if (r[i] === kEscape && i + 1 === r.length) { timeoutId = setTimeout( escapeCodeTimeout, iface ? iface.escapeCodeTimeout : ESCAPE_CODE_TIMEOUT ); } } catch (err) { // If the generator throws (it could happen in the `keypress` // event), we need to restart it. stream[ESCAPE_DECODER] = emitKeys(stream); stream[ESCAPE_DECODER].next(); throw err; } finally { if (iface) { iface.isCompletionEnabled = true; } } } } } else { // Nobody's watching anyway stream.removeListener('data', onData); stream.on('newListener', onNewListener); } } function onNewListener(event) { if (event === 'keypress') { stream.on('data', onData); stream.removeListener('newListener', onNewListener); } } if (stream.listenerCount('keypress') > 0) { stream.on('data', onData); } else { stream.on('newListener', onNewListener); } }
javascript
{ "resource": "" }
q59791
cursorTo
validation
function cursorTo(stream, x, y) { if (stream === null || stream === undefined) return; if (typeof x !== 'number' && typeof y !== 'number') return; if (typeof x !== 'number') throw new Error('ERR_INVALID_CURSOR_POS'); if (typeof y !== 'number') { stream.write(CSI`${x + 1}G`); } else { stream.write(CSI`${y + 1};${x + 1}H`); } }
javascript
{ "resource": "" }
q59792
moveCursor
validation
function moveCursor(stream, dx, dy) { if (stream === null || stream === undefined) return; if (dx < 0) { stream.write(CSI`${-dx}D`); } else if (dx > 0) { stream.write(CSI`${dx}C`); } if (dy < 0) { stream.write(CSI`${-dy}A`); } else if (dy > 0) { stream.write(CSI`${dy}B`); } }
javascript
{ "resource": "" }
q59793
toCompute
validation
function toCompute(value) { if(value) { if(value.isComputed) { return value; } if(value.compute) { return value.compute; } else { return makeComputeLike(value); } } return value; }
javascript
{ "resource": "" }
q59794
HelperOptions
validation
function HelperOptions(scope, nodeList, exprData, stringOnly) { this.metadata = { rendered: false }; this.stringOnly = stringOnly; this.scope = scope; this.nodeList = nodeList; this.exprData = exprData; }
javascript
{ "resource": "" }
q59795
valueShouldBeInsertedAsHTML
validation
function valueShouldBeInsertedAsHTML(value) { return value !== null && typeof value === "object" && ( typeof value[toDOMSymbol] === "function" || typeof value[viewInsertSymbol] === "function" || typeof value.nodeType === "number" ); }
javascript
{ "resource": "" }
q59796
debuggerHelper
validation
function debuggerHelper (left, right) { //!steal-remove-start if (process.env.NODE_ENV !== 'production') { var shouldBreak = evaluateArgs.apply(null, Array.prototype.slice.call(arguments, 0, -1)); if (!shouldBreak) { return; } var options = arguments[arguments.length - 1], scope = options && options.scope; var get = function (path) { return scope.get(path); }; // This makes sure `get`, `options` and `scope` are available debuggerHelper._lastGet = get; canLog.log('Use `get(<path>)` to debug this template'); var allowDebugger = __testing.allowDebugger; // forgotten debugger // jshint -W087 if (allowDebugger) { debugger; return; } // jshint +W087 } //!steal-remove-end canLog.warn('Forgotten {{debugger}} helper'); }
javascript
{ "resource": "" }
q59797
validation
function(helperOptions) { // lookup // TODO: remove in prod // make sure we got called with the right stuff if(helperOptions.exprData.argExprs.length !== 1) { throw new Error("for(of) broken syntax"); } // TODO: check if an instance of helper; var helperExpr = helperOptions.exprData.argExprs[0].expr; var variableName, valueLookup, valueObservable; if(helperExpr instanceof expression.Lookup) { valueObservable = helperExpr.value(helperOptions.scope); } else if(helperExpr instanceof expression.Helper) { // TODO: remove in prod var inLookup = helperExpr.argExprs[0]; if(inLookup.key !== "of") { throw new Error("for(of) broken syntax"); } variableName = helperExpr.methodExpr.key; valueLookup = helperExpr.argExprs[1]; valueObservable = valueLookup.value(helperOptions.scope); } var items = valueObservable; var args = [].slice.call(arguments), options = args.pop(), resolved = bindAndRead(items); if(resolved && !canReflect.isListLike(resolved)) { return forOfObject(resolved,variableName, helperOptions); } if(options.stringOnly) { var parts = []; canReflect.eachIndex(resolved, function(value, index){ var variableScope = {}; if(variableName !== undefined){ variableScope[variableName] = value; } parts.push( helperOptions.fn( options.scope .add({ index: index }, { special: true }) .addLetContext(variableScope) ) ); }); return parts.join(""); } else { // Tells that a helper has been called, this function should be returned through // checking its value. options.metadata.rendered = true; return function(el){ // make a child nodeList inside the can.view.live.html nodeList // so that if the html is re var nodeList = [el]; nodeList.expression = "live.list"; nodeLists.register(nodeList, null, options.nodeList, true); // runs nest replacements nodeLists.update(options.nodeList, [el]); var cb = function (item, index, parentNodeList) { var variableScope = {}; if(variableName !== undefined){ variableScope[variableName] = item; } return options.fn( options.scope .add({ index: index }, { special: true }) .addLetContext(variableScope), options.options, parentNodeList ); }; live.list(el, items, cb, options.context, el.parentNode, nodeList, function(list, parentNodeList){ return options.inverse(options.scope, options.options, parentNodeList); }); }; } }
javascript
{ "resource": "" }
q59798
validation
function(process){ var subSection = new TextSection(); this.last().add({process: process, truthy: subSection}); this.stack.push(subSection); }
javascript
{ "resource": "" }
q59799
inferType
validation
function inferType(type) { if (!type) return ''; function iterateTypes(subTree) { return map(normalizeValue(subTree), inferType).join(', '); } switch (type.name) { case 'arrayOf': return `array of ${iterateTypes(type.value)}`; case 'custom': return COMMON_PROP_TYPES_TO_LINKS_MAP[type.raw] || type.raw; case 'enum': return `one of: ${iterateTypes(type.value)}`; case 'shape': case 'shapeOf': // FALL THROUGH return 'object'; case 'union': return iterateTypes(type.value); default: return type.name || type.value; } }
javascript
{ "resource": "" }