Sha256: 0f9ff459db794c63ae953cc3aade5c5596c95da6af18e791678ec56ea382ea99

Contents?: true

Size: 628 Bytes

Versions: 6

Compression:

Stored size: 628 Bytes

Contents

# backtick_javascript: true

module OpenURI
  @__xmlhttprequest__ = `require('unxhr')`
  `var __XMLHttpRequest__ = #{@__xmlhttprequest__}.XMLHttpRequest`

  def self.request(uri)
    %x{
      var xhr = new __XMLHttpRequest__();
      xhr.open('GET', uri, false);
      xhr.responseType = 'arraybuffer';
      xhr.send();
      return xhr;
    }
  end

  def self.data(req)
    %x{
      var arrayBuffer = req.response;
      var byteArray = new Uint8Array(arrayBuffer);
      var result = []
      for (var i = 0; i < byteArray.byteLength; i++) {
        result.push(byteArray[i]);
      }
      return result;
    }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 stdlib/nodejs/open-uri.rb
opal-1.8.2 stdlib/nodejs/open-uri.rb
opal-1.8.1 stdlib/nodejs/open-uri.rb
opal-1.8.0 stdlib/nodejs/open-uri.rb
opal-1.8.0.beta1 stdlib/nodejs/open-uri.rb
opal-1.8.0.alpha1 stdlib/nodejs/open-uri.rb