fs.readdirSync(themesDir).forEach(th => { if (!th.endsWith(".json")) return; th = th.replace(".json", ""); if (th === window.settings.theme) return; themes += `<option>${th}</option>`; });
function getNextVertexInPool() { if ( _vertexCount === _vertexPoolLength ) { var vertex = new THREE.RenderableVertex(); _vertexPool.push( vertex ); _vertexPoolLength ++; _vertexCount ++; return vertex; } return _vertexPool[ _vertexCount ++ ]; }
export default function getBufferFromStream(stream) { return new Promise(resolve => { const chunks = []; stream.on('data', chunk => { chunks.push(chunk); }); stream.on('end', () => { resolve(Buffer.concat(chunks)); }); }); }
it('.emit()', async function() { expect(emitter.emit('a')).to.be.a('promise'); const array = []; emitter.on('a', () => array.push(1)); emitter.on('a', async () => { await timeout(10); array.push(2); }); emitter.on('a', () => array.push(3)); expect(await emitter.emit('a')).to.be.true; expect(array).to.have.ordered.members([1, 2, 3]); });
function totalTime(timings = {}) { return keys(timings).reduce( (total, k) => (timings[k] > 0 ? (total += timings[k]) : total), 0 ); }
async flush() { const NOOP = () => {}; await Promise.all( // The NOOP is there to handle both a resolved and rejected promise // to ensure the promise resolves regardless of the outcome. this._requests.map(r => Promise.resolve(r.promise).then(NOOP, NOOP)) ); }
export default function buildUrl(...paths) { const url = new URL( paths .map(p => p && (p + '').trim()) // Trim each string .filter(Boolean) // Remove empty strings or other falsy paths .join('/') ); // Replace 2+ consecutive slashes with 1. (e.g. `///` --> `/`) url.set('pathname', url.pathname.replace(/\/{2,}/g, '/')); return url.href; }
function captureRequests(server) { const reqs = []; server.any().on('request', req => reqs.push(req)); return reqs; }
Object.keys(publicEnv).forEach(key => { if (!process.env[key]) { process.env[key] = publicEnv[key]; } });
function getNextFaceInPool() { if ( _faceCount === _facePoolLength ) { var face = new THREE.RenderableFace(); _facePool.push( face ); _facePoolLength ++; _faceCount ++; return face; } return _facePool[ _faceCount ++ ]; }