Skip to content

Commit

Permalink
Adds arrayBuffer method
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-polach committed Jun 1, 2017
1 parent cf71a1b commit dfed82c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ Body.prototype.buffer = function() {

};

/**
* Decode response as arrayBuffer
*
* @return Promise
*/
Body.prototype.arrayBuffer = function() {

return this._decode().then(function(buf){
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
});

},

/**
* Decode buffers into utf-8 string
*
Expand Down

0 comments on commit dfed82c

Please sign in to comment.