async record (recid) { let input = this.parentNode.output let stream = input.record({video: false, audio: true}) this.recordStreams[recid] = stream let filename = recid this.files[filename] = {stream, buffers: [], closed: false} stream.on('data', chunk => this.files[filename].buffers.push(chunk)) let cleanup = once(() => { this.files[filename].closed = true stream.emit('data', null) }) stream.on('end', cleanup) stream.on('close', cleanup) stream.on('error', cleanup) return filename }
onPeer (node) { if (node.peer) { let key = node.peer.publicKey node.onRPC = rpc => { this.peers[key] = node if (this.recording) { this.recordPeer(rpc, node) } } let cleanup = once(() => { // if (this.recording) return delete this.peers[key] }) node.peer.on('end', cleanup) node.peer.on('close', cleanup) node.peer.on('error', cleanup) } }
}) let cleanup = once(() => { let cv = this.querySelector('canvas.roll-call-visuals') let ctx = cv.canvasCtx
function teardown (cb) { cb = once(cb || function () {}) if (queryable) { // this will not work for pools, where we instead rely on the queryable.end // callback queryable.once('end', cb) if (connectionDone && semver.satisfies(pgVersion, '^5.2.1')) { // Version 5.2.1 doesn't release the connection back into the pool when // calling client.end(), so we'll instead drain the pool completely. This // takes a lot longer, so we don't wanna do this normally. // // For details see: // https://github.com/brianc/node-postgres/issues/1414 connectionDone(true) // true: disconnect and destroy the client connectionDone = undefined } else { queryable.end(cb) } queryable = undefined } else { process.nextTick(cb) } }
const done = once(() => { server.close() t.end()
const done = once(() => { server.close() t.end()
connection = hyperquest(url, options, once(function(error, response)
const send = (endpoint, data, onSuccess, onError, opts) => { onError = once(onError) const formData = new FormData() Object.keys(data).forEach(k => formData.append(k, data[k]))
callback = once(callback)
}) let reconnect = once(e => { console.log('Disconnected') let more = document.querySelector('bong-bong-more')
const closeWorker = once((code) => {
_makeRequest (opts, backoff, callback_) { const callback = once(callback_)
var onend = once(onended);
const done = once(() => { server.close() t.end()
const done = once(() => { server.close() t.end()