_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q27500
baseInverter
train
function baseInverter(object, setter, iteratee, accumulator) { baseForOwn(object, function(value, key, object) { setter(accumulator, iteratee(value), key, object); }); return accumulator; }
javascript
{ "resource": "" }
q27501
basePullAt
train
function basePullAt(array, indexes) { var length = array ? indexes.length : 0, lastIndex = length - 1; while (length--) { var index = indexes[length]; if (length == lastIndex || index !== previous) { var previous = index; if (isIndex(index)) { splic...
javascript
{ "resource": "" }
q27502
baseRepeat
train
function baseRepeat(string, n) { var result = ''; if (!string || n < 1 || n > MAX_SAFE_INTEGER) { return result; } // Leverage the exponentiation by squaring algorithm for a faster repeat. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. do { ...
javascript
{ "resource": "" }
q27503
baseSampleSize
train
function baseSampleSize(collection, n) { var array = values(collection); return shuffleSelf(array, baseClamp(n, 0, array.length)); }
javascript
{ "resource": "" }
q27504
baseSortedIndex
train
function baseSortedIndex(array, value, retHighest) { var low = 0, high = array == null ? low : array.length; if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { while (low < high) { var mid = (low + high) >>> 1, computed = array[mid]...
javascript
{ "resource": "" }
q27505
baseUpdate
train
function baseUpdate(object, path, updater, customizer) { return baseSet(object, path, updater(baseGet(object, path)), customizer); }
javascript
{ "resource": "" }
q27506
createBind
train
function createBind(func, bitmask, thisArg) { var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func); function wrapper() { var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; return fn.apply(isBind ? thisArg : this, arguments); } return w...
javascript
{ "resource": "" }
q27507
createRelationalOperation
train
function createRelationalOperation(operator) { return function(value, other) { if (!(typeof value == 'string' && typeof other == 'string')) { value = toNumber(value); other = toNumber(other); } return operator(value, other); }; }
javascript
{ "resource": "" }
q27508
customDefaultsAssignIn
train
function customDefaultsAssignIn(objValue, srcValue, key, object) { if (objValue === undefined || (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { return srcValue; } return objValue; }
javascript
{ "resource": "" }
q27509
getFuncName
train
function getFuncName(func) { var result = (func.name + ''), array = realNames[result], length = hasOwnProperty.call(realNames, result) ? array.length : 0; while (length--) { var data = array[length], otherFunc = data.func; if (otherFunc == null || otherFunc =...
javascript
{ "resource": "" }
q27510
getWrapDetails
train
function getWrapDetails(source) { var match = source.match(reWrapDetails); return match ? match[1].split(reSplitDetails) : []; }
javascript
{ "resource": "" }
q27511
setWrapToString
train
function setWrapToString(wrapper, reference, bitmask) { var source = (reference + ''); return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); }
javascript
{ "resource": "" }
q27512
wrapperClone
train
function wrapperClone(wrapper) { if (wrapper instanceof LazyWrapper) { return wrapper.clone(); } var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); result.__actions__ = copyArray(wrapper.__actions__); result.__index__ = wrapper.__index__; result.__values...
javascript
{ "resource": "" }
q27513
dropRight
train
function dropRight(array, n, guard) { var length = array == null ? 0 : array.length; if (!length) { return []; } n = (guard || n === undefined) ? 1 : toInteger(n); n = length - n; return baseSlice(array, 0, n < 0 ? 0 : n); }
javascript
{ "resource": "" }
q27514
findIndex
train
function findIndex(array, predicate, fromIndex) { var length = array == null ? 0 : array.length; if (!length) { return -1; } var index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { index = nativeMax(length + index, 0); } return baseFindIndex(a...
javascript
{ "resource": "" }
q27515
flattenDeep
train
function flattenDeep(array) { var length = array == null ? 0 : array.length; return length ? baseFlatten(array, INFINITY) : []; }
javascript
{ "resource": "" }
q27516
fromPairs
train
function fromPairs(pairs) { var index = -1, length = pairs == null ? 0 : pairs.length, result = {}; while (++index < length) { var pair = pairs[index]; result[pair[0]] = pair[1]; } return result; }
javascript
{ "resource": "" }
q27517
initial
train
function initial(array) { var length = array == null ? 0 : array.length; return length ? baseSlice(array, 0, -1) : []; }
javascript
{ "resource": "" }
q27518
sortedIndexOf
train
function sortedIndexOf(array, value) { var length = array == null ? 0 : array.length; if (length) { var index = baseSortedIndex(array, value); if (index < length && eq(array[index], value)) { return index; } } return -1; }
javascript
{ "resource": "" }
q27519
sortedUniqBy
train
function sortedUniqBy(array, iteratee) { return (array && array.length) ? baseSortedUniq(array, getIteratee(iteratee, 2)) : []; }
javascript
{ "resource": "" }
q27520
unzip
train
function unzip(array) { if (!(array && array.length)) { return []; } var length = 0; array = arrayFilter(array, function(group) { if (isArrayLikeObject(group)) { length = nativeMax(group.length, length); return true; } }); return baseTimes(...
javascript
{ "resource": "" }
q27521
forEachRight
train
function forEachRight(collection, iteratee) { var func = isArray(collection) ? arrayEachRight : baseEachRight; return func(collection, getIteratee(iteratee, 3)); }
javascript
{ "resource": "" }
q27522
negate
train
function negate(predicate) { if (typeof predicate != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } return function() { var args = arguments; switch (args.length) { case 0: return !predicate.call(this); case 1: return !predicate.call(this, args[0]); ...
javascript
{ "resource": "" }
q27523
conformsTo
train
function conformsTo(object, source) { return source == null || baseConformsTo(object, source, keys(source)); }
javascript
{ "resource": "" }
q27524
create
train
function create(prototype, properties) { var result = baseCreate(prototype); return properties == null ? result : baseAssign(result, properties); }
javascript
{ "resource": "" }
q27525
replace
train
function replace() { var args = arguments, string = toString(args[0]); return args.length < 3 ? string : string.replace(args[1], args[2]); }
javascript
{ "resource": "" }
q27526
startsWith
train
function startsWith(string, target, position) { string = toString(string); position = position == null ? 0 : baseClamp(toInteger(position), 0, string.length); target = baseToString(target); return string.slice(position, position + target.length) == target; }
javascript
{ "resource": "" }
q27527
truncate
train
function truncate(string, options) { var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION; if (isObject(options)) { var separator = 'separator' in options ? options.separator : separator; length = 'length' in options ? toInteger(options.length) : length; om...
javascript
{ "resource": "" }
q27528
cond
train
function cond(pairs) { var length = pairs == null ? 0 : pairs.length, toIteratee = getIteratee(); pairs = !length ? [] : arrayMap(pairs, function(pair) { if (typeof pair[1] != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } return [toIteratee(pair[0]), pair...
javascript
{ "resource": "" }
q27529
nthArg
train
function nthArg(n) { n = toInteger(n); return baseRest(function(args) { return baseNth(args, n); }); }
javascript
{ "resource": "" }
q27530
toPath
train
function toPath(value) { if (isArray(value)) { return arrayMap(value, toKey); } return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); }
javascript
{ "resource": "" }
q27531
train
function(cx, cy, r, width) { return {type: 'ring', cx: cx, cy: cy, r: r, width: width} }
javascript
{ "resource": "" }
q27532
renderStackup
train
function renderStackup(stackupLayers, next) { var stackup = createStackup(stackupLayers, options) stackup.layers = stackupLayers next(null, stackup) }
javascript
{ "resource": "" }
q27533
makeRenderLayerTask
train
function makeRenderLayerTask(layer) { return function renderLayer(next) { var stackupLayer = makeBaseStackupLayer(layer) if (stackupLayer.converter) return next(null, stackupLayer) var converter = gerberToSvg( stackupLayer.gerber, stackupLayer.options, function handleLaye...
javascript
{ "resource": "" }
q27534
makeBaseStackupLayer
train
function makeBaseStackupLayer(layer) { var layerSide = layer.side var layerType = layer.type if ( layer.filename && typeof layerSide === 'undefined' && typeof layerType === 'undefined' ) { var gerberId = layerTypes[layer.filename] layerSide = gerberId.side layerType ...
javascript
{ "resource": "" }
q27535
train
function() { var t = tokens.shift() var exp if (RE_NUMBER.test(t)) { exp = {type: 'n', val: t} } else { exp = parseExpression() tokens.shift() } return exp }
javascript
{ "resource": "" }
q27536
train
function() { var exp = parsePrimary() var t = tokens[0] if (t === 'X') { parser._warn("multiplication in macros should use 'x', not 'X'") t = 'x' } while (t === 'x' || t === '/') { tokens.shift() var right = parsePrimary() exp = {type: t, left: exp, right: right} ...
javascript
{ "resource": "" }
q27537
train
function(op, mods) { var getValue = function(t) { if (t[0] === '$') { return Number(mods[t]) } return Number(t) } var type = op.type if (type === 'n') { return getValue(op.val) } if (type === '+') { return evaluate(op.left, mods) + evaluate(op.right, mods) ...
javascript
{ "resource": "" }
q27538
findPrimes
train
function findPrimes(n) { var i, s, p, ans; s=new Array(n); for (i=0; i<n; i++) s[i]=0; s[0]=2; p=0; //first p elements of s are primes, the rest are a sieve for (;s[p]<n;) { //s[p] is the pth prime for (i=s[p]*s[p]; i<n; i+=s[p]) //mark multiples of s[p] s[i]=1; p++; ...
javascript
{ "resource": "" }
q27539
millerRabinInt
train
function millerRabinInt(x, b) { if (mr_x1.length!=x.length) { mr_x1=dup(x); mr_r=dup(x); mr_a=dup(x); } copyInt_(mr_a, b); return millerRabin(x, mr_a); }
javascript
{ "resource": "" }
q27540
bitSize
train
function bitSize(x) { var j, z, w; for (j=x.length-1; (x[j]==0) && (j>0); j--); for (z=0, w=x[j]; w; (w>>=1), z++); z+=bpe*j; return z; }
javascript
{ "resource": "" }
q27541
expand
train
function expand(x, n) { var ans=int2bigInt(0, (x.length>n ? x.length : n)*bpe, 0); copy_(ans, x); return ans; }
javascript
{ "resource": "" }
q27542
randTruePrime
train
function randTruePrime(k) { var ans=int2bigInt(0, k, 0); randTruePrime_(ans, k); return trim(ans, 1); }
javascript
{ "resource": "" }
q27543
randProbPrime
train
function randProbPrime(k) { if (k>=600) return randProbPrimeRounds(k, 2); //numbers from HAC table 4.3 if (k>=550) return randProbPrimeRounds(k, 4); if (k>=500) return randProbPrimeRounds(k, 5); if (k>=400) return randProbPrimeRounds(k, 6); if (k>=350) return randProbPrimeRounds(k, 7); if (k>=300) return ra...
javascript
{ "resource": "" }
q27544
randBigInt_
train
function randBigInt_(b, n, s) { var i, a; for (i=0; i<b.length; i++) b[i]=0; a=Math.floor((n-1)/bpe)+1; //# array elements to hold the BigInt for (i=0; i<a; i++) { b[i]=Math.floor(Math.random()*(1<<(bpe-1))); } b[a-1] &= (2<<((n-1)%bpe))-1; if (s==1) b[a-1] |= (1<<((n-1)%bpe)); }
javascript
{ "resource": "" }
q27545
carry_
train
function carry_(x) { var i, k, c, b; k=x.length; c=0; for (i=0; i<k; i++) { c+=x[i]; b=0; if (c<0) { b=-(c>>bpe); c+=b*radix; } x[i]=c & mask; c=(c>>bpe)-b; } }
javascript
{ "resource": "" }
q27546
modInt
train
function modInt(x, n) { var i, c=0; for (i=x.length-1; i>=0; i--) c=(c*radix+x[i])%n; return c; }
javascript
{ "resource": "" }
q27547
equals
train
function equals(x, y) { var i; var k=x.length<y.length ? x.length : y.length; for (i=0; i<k; i++) if (x[i]!=y[i]) return 0; if (x.length>y.length) { for (;i<x.length; i++) if (x[i]) return 0; } else { for (;i<y.length; i++) if (y[i]) return 0; } return 1; }
javascript
{ "resource": "" }
q27548
mod_
train
function mod_(x, n) { if (s4.length!=x.length) s4=dup(x); else copy_(s4, x); if (s5.length!=x.length) s5=dup(x); divide_(s4, n, s5, x); //x = remainder of s4 / n }
javascript
{ "resource": "" }
q27549
trim
train
function trim(x, k) { var i, y; for (i=x.length; i>0 && !x[i-1]; i--); y=new Array(i+k); copy_(y, x); return y; }
javascript
{ "resource": "" }
q27550
parseIcon
train
function parseIcon(icon = "none") { if (!!icon && icon !== "none") { if (typeof icon === "string") { return { icon, position: "left", style: {} }; } return { position: "left", style: {}, ...icon }; } return null; }
javascript
{ "resource": "" }
q27551
getOptions
train
function getOptions (ctx) { const { vnode } = ctx const { value } = ctx.binding if (process.env.NODE_ENV !== 'production' && (isUndefined(value) || !isObject(value))) { warn('v-position -> configuration is missing or is not an Object', vnode.context) } const options = assign({ target: null, posi...
javascript
{ "resource": "" }
q27552
getContext
train
function getContext (el, binding, vnode) { const ctx = { el, binding, vnode } ctx.props = getOptions(ctx) if (!ctx.props) { binding.def.unbind(el, binding) return } return ctx }
javascript
{ "resource": "" }
q27553
extractSetterFromNode
train
function extractSetterFromNode( handler, node ) { assignSetterFnForNode( handler, node ); if ( node.children ) { // Recurse down to this node's children Object.keys( node.children ).forEach( ( key ) => { extractSetterFromNode( handler, node.children[ key ] ); } ); } }
javascript
{ "resource": "" }
q27554
createNodeHandlerSpec
train
function createNodeHandlerSpec( routeDefinition, resource ) { const handler = { // A "path" is an ordered (by key) set of values composed into the final URL _path: { '0': resource, }, // A "level" is a level-keyed object representing the valid options for // one level of the resource URL _levels: {}, ...
javascript
{ "resource": "" }
q27555
createPathPartSetter
train
function createPathPartSetter( node ) { // Local references to `node` properties used by returned functions const nodeLevel = node.level; const nodeName = node.names[ 0 ]; const supportedMethods = node.methods || []; const dynamicChildren = node.children ? Object.keys( node.children ) .map( key => node.childr...
javascript
{ "resource": "" }
q27556
registerRoute
train
function registerRoute( namespace, restBase, options = {} ) { // Support all methods until requested to do otherwise let supportedMethods = [ 'head', 'get', 'patch', 'put', 'post', 'delete' ]; if ( Array.isArray( options.methods ) ) { // Permit supported methods to be specified as an array supportedMethods = op...
javascript
{ "resource": "" }
q27557
reduceRouteComponents
train
function reduceRouteComponents( routeObj, topLevel, parentLevel, component, idx, components ) { // Check to see if this component is a dynamic URL segment (i.e. defined by // a named capture group regular expression). namedGroup will be `null` if // the regexp does not match, or else an array defining the RegExp mat...
javascript
{ "resource": "" }
q27558
WPAPI
train
function WPAPI( options ) { // Enforce `new` if ( this instanceof WPAPI === false ) { return new WPAPI( options ); } if ( typeof options.endpoint !== 'string' ) { throw new Error( 'options hash must contain an API endpoint URL string' ); } // Dictionary to be filled by handlers for default namespaces this...
javascript
{ "resource": "" }
q27559
WPRequest
train
function WPRequest( options ) { /** * Configuration options for the request * * @property _options * @type Object * @private * @default {} */ this._options = [ // Whitelisted options keys 'auth', 'endpoint', 'headers', 'username', 'password', 'nonce', ].reduce( ( localOptions, key ) => { ...
javascript
{ "resource": "" }
q27560
createEndpointRequest
train
function createEndpointRequest( handlerSpec, resource, namespace ) { // Create the constructor function for this endpoint class EndpointRequest extends WPRequest { constructor( options ) { super( options ); /** * Semi-private instance property specifying the available URL path options * for this end...
javascript
{ "resource": "" }
q27561
_setHeaders
train
function _setHeaders( request, options ) { // If there's no headers, do nothing if ( ! options.headers ) { return request; } return objectReduce( options.headers, ( request, value, key ) => request.set( key, value ), request ); }
javascript
{ "resource": "" }
q27562
_auth
train
function _auth( request, options, forceAuthentication ) { // If we're not supposed to authenticate, don't even start if ( ! forceAuthentication && ! options.auth && ! options.nonce ) { return request; } // Enable nonce in options for Cookie authentication http://wp-api.org/guides/authentication.html if ( option...
javascript
{ "resource": "" }
q27563
createPaginationObject
train
function createPaginationObject( result, options, httpTransport ) { let _paging = null; if ( ! result.headers ) { // No headers: return as-is return _paging; } // Guard against capitalization inconsistencies in returned headers Object.keys( result.headers ).forEach( ( header ) => { result.headers[ header.t...
javascript
{ "resource": "" }
q27564
returnBody
train
function returnBody( wpreq, result ) { const body = extractResponseBody( result ); const _paging = createPaginationObject( result, wpreq._options, wpreq.transport ); if ( _paging ) { body._paging = _paging; } return body; }
javascript
{ "resource": "" }
q27565
_httpPost
train
function _httpPost( wpreq, data, callback ) { checkMethodSupport( 'post', wpreq ); const url = wpreq.toString(); data = data || {}; let request = _auth( agent.post( url ), wpreq._options, true ); request = _setHeaders( request, wpreq._options ); if ( wpreq._attachment ) { // Data must be form-encoded alongside...
javascript
{ "resource": "" }
q27566
applyEnv
train
function applyEnv(env, secrets = {}, required = {}) { if (Array.isArray(env)) { env.forEach(key => { // if the key already exists don't overwrite it if (!process.env[key]) { const value = getValue(key, {}, secrets, required) process.env[key] = value } }) } else { Object...
javascript
{ "resource": "" }
q27567
config
train
function config() { // only run this if it's not running inside Now.sh if (Boolean(process.env.NOW_REGION || process.env.NOW)) return const secrets = loadSecrets() const required = loadRequired() // load environment variables from now.json loadNowJSON(secrets, required) }
javascript
{ "resource": "" }
q27568
setupCache
train
function setupCache (config = {}) { // Extend default configuration config = makeConfig(config) // Axios adapter. Receives the axios request configuration as only parameter async function adapter (req) { // Merge the per-request config with the instance config. const reqConfig = mergeRequestConfig(conf...
javascript
{ "resource": "" }
q27569
buildSolidBrush
train
function buildSolidBrush(color, alpha) { let component; component = (color >> 16) & 0xff; const R = component / 255; component = (color >> 8) & 0xff; const G = component / 255; component = color & 0xff; const B = component / 255; const A = alpha; const brush = new libui.DrawBrush(); brush.color = new libui....
javascript
{ "resource": "" }
q27570
train
function(suffix) { return function(now, tween) { var floored_number = Math.floor(now), target = $(tween.elem); target.prop('number', now).text(floored_number + suffix); }; }
javascript
{ "resource": "" }
q27571
train
function(separator, group_length, suffix) { separator = separator || ' '; group_length = group_length || 3; suffix = suffix || ''; return function(now, tween) { var negative = now < 0, floored_number = Math.floor((negative ? -1 : 1) * now), separate...
javascript
{ "resource": "" }
q27572
getMarkupFromData
train
function getMarkupFromData(dataForSingleItem) { var name = dataForSingleItem.first_name + ' ' + dataForSingleItem.last_name; // https://www.paulirish.com/2009/random-hex-color-code-snippets/ var randomColor = ('000000' + Math.random().toString(16).slice(2, 8)).slice(-6); return [ '<div class="js-item col-3@...
javascript
{ "resource": "" }
q27573
replaceLoadMoreButton
train
function replaceLoadMoreButton() { var text = document.createTextNode('All users loaded'); var replacement = document.createElement('p'); replacement.appendChild(text); loadMoreButton.parentNode.replaceChild(replacement, loadMoreButton); }
javascript
{ "resource": "" }
q27574
PhotoItem
train
function PhotoItem({ id, username, src, name }) { return ( <div key={id} className="col-3@xs col-4@sm photo-item"> <div className="aspect aspect--4x3"> <div className="aspect__inner"> <img src={src} /> <PhotoAttribution username={username} name={name} /> </div> </di...
javascript
{ "resource": "" }
q27575
PhotoAttribution
train
function PhotoAttribution({ username, name }) { if (!username) { return null; } const href = `https://unsplash.com/${username}?utm_medium=referral&amp;utm_campaign=photographer-credit&amp;utm_content=creditBadge`; const title = `Download free do whatever you want high-resolution photos from ${name}`; ret...
javascript
{ "resource": "" }
q27576
addToList
train
function addToList(i, L, R) { R[L[i + 1]] = R[i]; L[R[i]] = L[i + 1]; R[i] = i + 1; L[i + 1] = i; }
javascript
{ "resource": "" }
q27577
removeFromList
train
function removeFromList(i, L, R) { R[L[i]] = R[i]; L[R[i]] = L[i]; R[i] = i; L[i] = i; }
javascript
{ "resource": "" }
q27578
breakInsideToken
train
function breakInsideToken(tokens, tokenIndex, breakIndex, removeBreakChar) { let newBreakToken = { type: TYPE_NEWLINE }; let newTextToken = { type: TYPE_TEXT, value: tokens[tokenIndex].value.substring(breakIndex + (removeBreakChar ? 1 : 0)) }; tokens.splice(tokenIndex + 1, 0,...
javascript
{ "resource": "" }
q27579
insertAfter
train
function insertAfter(newNode, referenceNode) { if (!referenceNode.parentNode) { referenceNode = AFRAME.INSPECTOR.selectedEntity; } if (!referenceNode) { AFRAME.INSPECTOR.sceneEl.appendChild(newNode); } else { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } }
javascript
{ "resource": "" }
q27580
prepareForSerialization
train
function prepareForSerialization(entity) { var clone = entity.cloneNode(false); var children = entity.childNodes; for (var i = 0, l = children.length; i < l; i++) { var child = children[i]; if ( child.nodeType !== Node.ELEMENT_NODE || (!child.hasAttribute('aframe-injected') && !child.h...
javascript
{ "resource": "" }
q27581
optimizeComponents
train
function optimizeComponents(copy, source) { var removeAttribute = HTMLElement.prototype.removeAttribute; var setAttribute = HTMLElement.prototype.setAttribute; var components = source.components || {}; Object.keys(components).forEach(function(name) { var component = components[name]; var result = getImp...
javascript
{ "resource": "" }
q27582
getImplicitValue
train
function getImplicitValue(component, source) { var isInherited = false; var value = (isSingleProperty(component.schema) ? _single : _multi)(); return [value, isInherited]; function _single() { var value = getMixedValue(component, null, source); if (value === undefined) { value = getInjectedValue(...
javascript
{ "resource": "" }
q27583
getFromAttribute
train
function getFromAttribute(component, propertyName, source) { var value; var mappings = source.mappings || {}; var route = component.name + '.' + propertyName; var primitiveAttribute = findAttribute(mappings, route); if (primitiveAttribute && source.hasAttribute(primitiveAttribute)) { value = source.getAtt...
javascript
{ "resource": "" }
q27584
getMixedValue
train
function getMixedValue(component, propertyName, source) { var value; var reversedMixins = source.mixinEls.reverse(); for (var i = 0; value === undefined && i < reversedMixins.length; i++) { var mixin = reversedMixins[i]; if (mixin.attributes.hasOwnProperty(component.name)) { if (!propertyName) { ...
javascript
{ "resource": "" }
q27585
getInjectedValue
train
function getInjectedValue(component, propertyName, source) { var value; var primitiveDefaults = source.defaultComponentsFromPrimitive || {}; var aFrameDefaults = source.defaultComponents || {}; var defaultSources = [primitiveDefaults, aFrameDefaults]; for (var i = 0; value === undefined && i < defaultSources....
javascript
{ "resource": "" }
q27586
getDefaultValue
train
function getDefaultValue(component, propertyName, source) { if (!propertyName) { return component.schema.default; } return component.schema[propertyName].default; }
javascript
{ "resource": "" }
q27587
getOptimalUpdate
train
function getOptimalUpdate(component, implicit, reference) { if (equal(implicit, reference)) { return null; } if (isSingleProperty(component.schema)) { return reference; } var optimal = {}; Object.keys(reference).forEach(function(key) { var needsUpdate = !equal(reference[key], implicit[key]); ...
javascript
{ "resource": "" }
q27588
getUniqueId
train
function getUniqueId(baseId) { if (!document.getElementById(baseId)) { return baseId; } var i = 2; // If the baseId ends with _#, it extracts the baseId removing the suffix var groups = baseId.match(/(\w+)-(\d+)/); if (groups) { baseId = groups[1]; i = groups[2]; } while (document.getEleme...
javascript
{ "resource": "" }
q27589
getModifiedProperties
train
function getModifiedProperties(entity, componentName) { var data = entity.components[componentName].data; var defaultData = entity.components[componentName].schema; var diff = {}; for (var key in data) { // Prevent adding unknown attributes if (!defaultData[key]) { continue; } ...
javascript
{ "resource": "" }
q27590
train
function(focusEl) { this.opened = true; Events.emit('inspectortoggle', true); if (this.sceneEl.hasAttribute('embedded')) { // Remove embedded styles, but keep track of it. this.sceneEl.removeAttribute('embedded'); this.sceneEl.setAttribute('aframe-inspector-removed-embedded'); } ...
javascript
{ "resource": "" }
q27591
train
function() { this.opened = false; Events.emit('inspectortoggle', false); // Untrick scene when we enabled this to run the cursor tick. this.sceneEl.isPlaying = false; this.sceneEl.play(); this.cursor.pause(); if (this.sceneEl.hasAttribute('aframe-inspector-removed-embedded')) { this...
javascript
{ "resource": "" }
q27592
train
function() { var xhr = new XMLHttpRequest(); var url = assetsBaseUrl + assetsRelativeUrl['images']; // @todo Remove the sync call and use a callback xhr.open('GET', url); xhr.onload = () => { var data = JSON.parse(xhr.responseText); this.images = data.images; this.images.forEach(...
javascript
{ "resource": "" }
q27593
onDoubleClick
train
function onDoubleClick(event) { const array = getMousePosition( inspector.container, event.clientX, event.clientY ); onDoubleClickPosition.fromArray(array); const intersectedEl = mouseCursor.components.cursor.intersectedEl; if (!intersectedEl) { return; } Events.emit(...
javascript
{ "resource": "" }
q27594
equalArray
train
function equalArray(array1, array2) { return ( array1.length === array2.length && array1.every(function(element, index) { return element === array2[index]; }) ); }
javascript
{ "resource": "" }
q27595
stringToArrayBuffer
train
function stringToArrayBuffer(text) { if (window.TextEncoder !== undefined) { return new TextEncoder().encode(text).buffer; } var array = new Uint8Array(new ArrayBuffer(text.length)); for (var i = 0, il = text.length; i < il; i++) { var value = text.charCodeAt(i); // Re...
javascript
{ "resource": "" }
q27596
getMinMax
train
function getMinMax(attribute, start, count) { var output = { min: new Array(attribute.itemSize).fill(Number.POSITIVE_INFINITY), max: new Array(attribute.itemSize).fill(Number.NEGATIVE_INFINITY) }; for (var i = start; i < start + count; i++) { for (var a = 0; a < attribute.item...
javascript
{ "resource": "" }
q27597
isNormalizedNormalAttribute
train
function isNormalizedNormalAttribute(normal) { if (cachedData.attributes.has(normal)) { return false; } var v = new THREE.Vector3(); for (var i = 0, il = normal.count; i < il; i++) { // 0.0005 is from glTF-validator if (Math.abs(v.fromArray(normal.array, i * 3).length()...
javascript
{ "resource": "" }
q27598
createNormalizedNormalAttribute
train
function createNormalizedNormalAttribute(normal) { if (cachedData.attributes.has(normal)) { return cachedData.attributes.get(normal); } var attribute = normal.clone(); var v = new THREE.Vector3(); for (var i = 0, il = attribute.count; i < il; i++) { v.fromArray(attribute...
javascript
{ "resource": "" }
q27599
getPaddedArrayBuffer
train
function getPaddedArrayBuffer(arrayBuffer, paddingByte) { paddingByte = paddingByte || 0; var paddedLength = getPaddedBufferSize(arrayBuffer.byteLength); if (paddedLength !== arrayBuffer.byteLength) { var array = new Uint8Array(paddedLength); array.set(new Uint8Array(arrayBuffer)); ...
javascript
{ "resource": "" }