@filecoin-shipyard/lotus-client-provider-browser
Advanced tools
Comparing version 0.0.6 to 0.0.7
class BrowserProvider { | ||
constructor (url, options = {}) { | ||
this.url = url | ||
this.wsUrl = | ||
options.wsUrl || url.replace(/^https:/, 'wss:').replace(/^http:/, 'ws:') | ||
this.httpUrl = | ||
@@ -8,3 +10,3 @@ options.httpUrl || url.replace(/^wss:/, 'https:').replace(/^ws:/, 'http:') | ||
options.importUrl || this.httpUrl.replace(/\/rpc\//, '/rest/') + '/import' | ||
this.transport = options.transport || 'ws' | ||
this.transport = options.transport || (url.match(/^http/) ? 'http' : 'ws') | ||
this.id = 0 | ||
@@ -239,5 +241,6 @@ this.inflight = new Map() | ||
async destroy () { | ||
async destroy (code = 1000) { | ||
// List of codes: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes | ||
if (this.ws) { | ||
this.ws.close() | ||
this.ws.close(code) | ||
this.destroyed = true | ||
@@ -244,0 +247,0 @@ } |
{ | ||
"name": "@filecoin-shipyard/lotus-client-provider-browser", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "module": "index.js", |
10083
239