Method: Browser::Blob#buffer

Defined in:
opal/browser/blob.rb

#bufferObject

Buffer view into the blob

If block is given it will be called with a parameter once we receive the buffer. Otherwise return a Promise which will resolve once we receive it.



44
45
46
47
48
49
50
51
52
53
# File 'opal/browser/blob.rb', line 44

def buffer
  promise = nil
  unless block_given?
    promise = Promise.new
    block = proc { |i| promise.resolve(i) }
  end
  resblock = proc { |i| block.call(Buffer.new(i)) }
  `#@native.arrayBuffer().then(#{resblock.to_n})`
  promise
end