OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-deps / @holepunchto / keet-core / lib / core / tasks / task.js

1 lines · javascript ref:
const t=require("ready-resource"),e=require("hypercore-id-encoding");class i extends t{constructor(t){super(),this.handle=t,this.description=t.description,this.type=this.description.type,this.scope=this.description.discoveryKey,this.priority=this.description.priority,this.keet=this.handle.manager.keet,this.store=this.keet.store,this.local=this.keet.local,this.swarm=this.keet.swarm,this.swarmWorker=this.keet.swarmWorker,this.files=this.keet.files,this._running=null}_open(){this._running=this._run(),this._running.catch(this.keet.onerror).finally(()=>this.close().catch(this.keet.onerror))}get id(){return this._id||(this._id=i.getId(this.description)),this._id}async run(){this.opened||await this.ready(),await this._running}async _run(){}async _close(){}static getId(t){return`${t.timestamp}:${e.encode(t.discoveryKey)}:${t.type}`}}module.exports={Task:i};