function getReqRaw(req) { removeEncodingFields(req.headers); var headers = getHeadersRaw(req.headers, req.rawHeaderNames); var url = String(req.url || '').replace(/^ws/, 'http'); headers.unshift([getMethod(req.method), url, 'HTTP/1.1'].join(' ')); return decodeRaw(headers, req); }
function print(...msg) { if (outputProcess) { msg.unshift(outputProcess); } if (!newline) { console.log(); newline = true; } console.log.apply(this, msg); }
/** * An array of cached versions of the message, including the current version * Sorted from latest (first) to oldest (last) * @type {Message[]} * @readonly */ get edits() { const copy = this._edits.slice(); copy.unshift(this); return copy; }
enqueue(payload) { debug('Enqueue event in worker queue'); if (this.running < this.concurrency) { this.running++; this.execute(payload); } else { this.queue.unshift(payload); } }
Array.from({length: Math.min(total, length)}, (_, sampleIndex) => { let indexRemaining = sampleIndex; const combination = []; for (let i = combinations.length - 1; i >= 0; i--) { const items = combinations[i]; const {length} = items; const index = indexRemaining % length; indexRemaining = (indexRemaining - index) / length; combination.unshift(items[index]); } return combination; })
function init() { const ArrayProto = Array.prototype const SafeProto = SafeArray.prototype return { concat: unapply(SafeProto.concat), from: SafeArray.from, indexOf: unapply(ArrayProto.indexOf), join: unapply(ArrayProto.join), of: SafeArray.of, push: unapply(ArrayProto.push), unshift: unapply(ArrayProto.unshift) } }
fs.writeFile(path.join(LOCAL_FILES, name), content, function(err) { if (!err) { var index = indexOfUploadFiles(name); if (index !== -1) { uploadFiles.splice(index, 1); } uploadFiles.unshift({ name: name, date: Date.now() }); } callback(err); });
event.dispatcher.on(event.step.started, (step) => { output.stepShift = 3; const printMetaStep = (metaStep) => { if (!metaStep) return currentMetaStep.shift(); if (currentMetaStep.indexOf(metaStep.toString()) >= 0) return; // step is the same if (metaStep.metaStep) { printMetaStep(metaStep.metaStep); } currentMetaStep.unshift(metaStep.toString()); output.step(metaStep); }; printMetaStep(step.metaStep); output.step(step); });
/* * Helper to map the cwd on the host to the one in the container */ const getContainerPath = appRoot => { // Break up our app root and cwd so we can get a diff const cwd = process.cwd().split(path.sep); const dir = _.drop(cwd, appRoot.split(path.sep).length); // Add our in-container app root // this will always be /app dir.unshift('/app'); // Return the directory return dir.join('/'); }
playUnknown(input, options) { this.destroyDispatcher(); const isStream = input instanceof ReadableStream; const args = isStream ? FFMPEG_ARGUMENTS.slice() : ['-i', input, ...FFMPEG_ARGUMENTS]; if (options.seek) args.unshift('-ss', String(options.seek)); const ffmpeg = new prism.FFmpeg({ args }); const streams = { ffmpeg }; if (isStream) { streams.input = input; input.pipe(ffmpeg); } return this.playPCMStream(ffmpeg, options, streams); }
test('should only execute once if map is called within callback', t => { let count = 0; const object = { arr: [], foo: true }; const proxy = onChange(object, function () { count++; this.arr.map(item => item); }); proxy.arr.unshift('value'); t.is(count, 1); });
/* * @TODO, add compose data to the add */ add(data, front = false) { if (front) this.composeData.unshift(data); else this.composeData.push(data); }
_.forEach(_.uniq(_.map(build, 'id')), container => { build.unshift({ id: container, cmd: '/helpers/user-perms.sh --silent', compose: app.compose, project: app.project, opts: { mode: 'attach', prestart, user: 'root', services: [container.split('_')[1]], }, }); });
function getResRaw(res) { removeEncodingFields(res.headers); var headers = getHeadersRaw(res.headers, res.rawHeaderNames); var statusCode = res.statusCode === 'aborted' ? 502 : res.statusCode; var statusMessage = !statusCode ? '' : res.statusMessage || STATUS_CODES[statusCode] || 'unknown'; headers.unshift(['HTTP/1.1', statusCode, statusMessage].join(' ')); return decodeRaw(headers, res); }
enqueue(payload) { debug('Enqueue event in worker queue'); if (this.running < this.concurrency) { this.running++; this.execute(payload); } else { this.queue.unshift(payload); } }