2014-08-08 19:18:09 +00:00
|
|
|
function FilerBuffer (subject, encoding, nonZero) {
|
|
|
|
|
|
|
|
// Automatically turn ArrayBuffer into Uint8Array so that underlying
|
|
|
|
// Buffer code doesn't just throw away and ignore ArrayBuffer data.
|
|
|
|
if (subject instanceof ArrayBuffer) {
|
|
|
|
subject = new Uint8Array(subject);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Buffer(subject, encoding, nonZero);
|
|
|
|
};
|
|
|
|
|
2014-08-09 17:05:15 +00:00
|
|
|
// Inherit prototype from Buffer
|
|
|
|
FilerBuffer.prototype = Object.create(Buffer.prototype);
|
|
|
|
FilerBuffer.prototype.constructor = FilerBuffer;
|
|
|
|
|
|
|
|
// Also copy static methods onto FilerBuffer ctor
|
2014-08-08 19:18:09 +00:00
|
|
|
Object.keys(Buffer).forEach(function (p) {
|
|
|
|
if (Buffer.hasOwnProperty(p)) {
|
|
|
|
FilerBuffer[p] = Buffer[p];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = FilerBuffer;
|