{"size": 609, "ext": "js", "max_stars_repo_path": "src/lib/Response.js", "max_stars_repo_name": "jeffreyrivor/node-ld", "max_stars_repo_stars_event_min_datetime": "2015-12-28T03:23:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-27T23:31:29.000Z", "max_issues_repo_path": "src/lib/Response.js", "max_issues_repo_name": "jeffreyrivor/node-ld", "max_issues_repo_issues_event_min_datetime": "2015-12-29T21:21:25.000Z", "max_issues_repo_issues_event_max_datetime": "2019-05-08T17:02:30.000Z", "max_forks_repo_path": "src/lib/Response.js", "max_forks_repo_name": "jeffreyrivor/node-ld", "max_forks_repo_forks_event_min_datetime": "2015-12-31T11:06:10.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-01T08:33:58.000Z"}
{"max_stars_count": 60, "max_issues_count": 23, "max_forks_count": 42, "avg_line_length": 19.03125, "max_line_length": 59, "alphanum_fraction": 0.6502463054}
import Frame from './Frame'

export default class Response {
	constructor(data){
		if(data && data instanceof Buffer) data = new Frame(data)
		if(data && data instanceof Frame) this.parse(data)
	}

	parse(f){
		this.frame = f
		var p = f.payload
		this.cid = p[0]
		this.payload = p.slice(1) 
	}

	build(){
		this.frame = this.frame || new Frame()
		var b = new Buffer(this.payload.length + 1)
		b[0] = this.cid
		this.payload.copy(b,1)
		this.frame.type = 0x55
		this.frame.payload = b;
		return this.frame.build()
	}

	preventDefault(){
		this._preventDefault = true
	}
	cancel(){
		this._cancel = true
	}
}