server.js
function getOrCreateSwarm (cb) {
      self.getSwarm(params.info_hash, (err, swarm) => {
        if (err) return cb(err)
        if (swarm) return cb(null, swarm)
        self.createSwarm(params.info_hash, (err, swarm) => {
          if (err) return cb(err)
          cb(null, swarm)
        })
      })
    }
function getOrCreateSwarm (cb) {
      self.getSwarm(params.info_hash, (err, swarm) => {
        if (err) return cb(err)
        if (swarm) return cb(null, swarm)
        self.createSwarm(params.info_hash, (err, swarm) => {
          if (err) return cb(err)
          cb(null, swarm)
        })
      })
    }
function getOrCreateSwarm ( cb ) { self . getSwarm ( params . info_hash , ( err , swarm ) => { if ( err ) return cb ( err ) if ( swarm ) return cb ( null , swarm ) self . createSwarm ( params . info_hash , ( err , swarm ) => { if ( err ) return cb ( err ) cb ( null , swarm ) } ) } ) }
Get existing swarm, or create one if one does not exist
Get existing swarm or create one if one does not exist