Skip to content

Commit

Permalink
Buffer get written blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Apr 29, 2017
1 parent e1ef657 commit a025807
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/browser/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,38 @@ var ASYNC_SAFE = false;
fn();
};

AsyncXHRBuffer.prototype.get_written_blocks = function()
{
var count = 0;
for(var _ in this.loaded_blocks)
{
count++;
}

var buffer = new Uint8Array(count * this.block_size);
var indices = [];

var i = 0;
for(var index in this.loaded_blocks)
{
var block = this.loaded_blocks[index];
dbg_assert(block.length === this.block_size);
index = +index;
indices.push(index);
buffer.set(
block,
i * this.block_size
);
i++;
}

return {
buffer,
indices,
block_size: this.block_size,
};
};

/**
* Synchronous access to File, loading blocks from the input type=file
* The whole file is loaded into memory during initialisation
Expand Down

0 comments on commit a025807

Please sign in to comment.