Create a blob from the given ArrayBuffer.
@param {ArrayBuffer} buffer the buffer to transform.
@return {Blob} the result.
@throws {Error} an Error if the browser doesn't support the requested feature.
351440
function (buffer) {
         JSZip.utils.checkSupport("blob");

         try {
            // Blob constructor
            return new Blob([buffer], { type: "application/zip" });
         }
         catch(e) {}

         try {
            // deprecated, browser only, old way
            var builder = new (window.BlobBuilder || window.WebKitBlobBuilder ||
                               window.MozBlobBuilder || window.MSBlobBuilder)();
            builder.append(buffer);
            return builder.getBlob('application/zip');
         }
         catch(e) {}

         // well, fuck ?!
         throw new Error("Bug : can't construct the Blob.");
      }
402547
function processBuffer(buffer) {
      if (!outputJSON.buffers) {
        outputJSON.buffers = [{ byteLength: 0 }];
      }

      // All buffers are merged before export.
      buffers.push(buffer);

      return 0;
    }
596302
function copyBuffer(buf, pos, len) {
  var copy = utils.newBuffer(len);
  buf.copy(copy, 0, pos, pos + len);
  return copy;
}
472085
function toBuffer (media) {
  return new Promise((resolve, reject) => {
    if (isURL(media)) {
      toBase64(media)
      .then(data => {
        toBuffer(data)
        .then(data => resolve(data))
        .catch(error => reject(error))
      })
      .catch(error => reject(error))
    } else if (isBase64(media)) {
      try {
        resolve(Buffer.from(media))
      } catch (ex) {
        reject(ex)
      }
    } else if (isFile(media)) {
      fs.readFile(media, (err, data) => {
        err && reject(err)
        resolve(data)
      })
    } else {
      reject('Error: toBuffer(): argument must be file, url or file')
    }
  })
}
809811
function bnToBuffer( bn ) {
  var hex = bn.toString( 16 )
  hex = hex.length % 2 === 1 ? '0' + hex : hex
  return Buffer.from( hex, 'hex' )
}
1158095
function toArray(buffer) {
    if(!buffer) buffer = new Buffer(0);
    var view = new Uint8Array(buffer.length);
    for (var i = 0; i < buffer.length; ++i) {
        view[i] = buffer[i];
    }
    return view;
  }
768523
public static Buffer wrap(final byte[] buffer) {
        if (buffer == null || buffer.length == 0) {
            throw new IllegalArgumentException("the buffer cannot be null or empty");
        }

        return new ByteBuffer(buffer);
    }
725152
function cloneArrayBuffer(arrayBuffer) {
  var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  return result;
}
876544
function(arrayBuffer) {
	this.bytes = new Uint8Array(arrayBuffer);
	this.length = this.bytes.length;
	this.writePos = this.bytes.length;
	this.index = 0;
}
1107660
function _toBuffer(buffer) {
        var _buffer, nums;

        if (Buffer.isBuffer(buffer)) {
            _buffer = new Buffer(buffer.length);
            buffer.copy(_buffer);
        }
        else if (Array.isArray(buffer)) {
            _buffer = new Buffer(buffer);
        }
        else if (typeof buffer === 'string') {
            nums = buffer.replace(/^0x/i, '').match(/.{1,2}(?=(..)+(?!.))|..?$/g);
            _buffer = new Buffer(nums.length);

            _buffer.fill(0);

            for (var i = nums.length - 1; i >= 0; i--) {
                _buffer.writeUInt8(parseInt(nums[i], 16), i);
            }
        }

        return _buffer;
    }
1235738
function exifBuffer(buf, options, cb) {
  if(typeof options === 'function') {
    cb = options;
    options = {};
  }

  try {
    buf = bufferUtils.toArrayBuffer(buf);

    if(hasWorker) {
      const wr = require('webworkify')(exifWorker);

      wr.onmessage = ({ data: msg }) => {
        const err = msg.err ? new Error(msg.err) : undefined;
        cb(err, msg.result);
      };

      const msg = {
        buf: buf
      };

      if (options.transferable) {
        wr.postMessage(msg, [ buf ]);
      } else {
        wr.postMessage(msg);
      }
    } else {
      exif(buf, options, cb);
    }
  } catch(err) {
    cb(err);
  }
}
1344445
public static String decompress(byte [] buffer){
        char [] buf = decompress(buffer, 0, buffer.length);
        return new String(buf);
    }
487842
private static byte[] toByteArray(final ByteBuffer buffer)
  {
    if (buffer.hasArray()
        && buffer.arrayOffset() == 0
        && buffer.position() == 0
        && buffer.array().length == buffer.limit()) {
      return buffer.array();
    } else {
      final byte[] retVal = new byte[buffer.remaining()];
      buffer.duplicate().get(retVal);
      return retVal;
    }
  }
1320856
function decodeArrayBuffer(array) {

    /* Speedup on Node.JS using native BASE64 */
    if (process && Buffer && (array['!$base64$!'] != null)) {
      return new Uint8Array(new Buffer(array['!$base64$!'], 'base64')).buffer
    }

    /* Normal array processing */
    return new Uint8Array(array).buffer;
  }
208240
function bufferFromFile( filename ) {
	console.info( ("Loading "+filename).grey );
	var buf = fs.readFileSync( filename ),	// Load Buffer
    	ab = new ArrayBuffer( buf.length ),	// Create an ArrayBuffer to fit the data
    	view = new Uint8Array(ab);			// Create an Uint8Array view

    // Copy buffer into view
    for (var i = 0; i < buf.length; ++i)
        view[i] = buf[i];

    // Return buffer view
    return view;
}
154116
function fromBuffer(b) {
	// TODO: Use nodert-streams to more efficiently convert the buffer?
	let len = b.length;
	const DataWriter = Windows.Storage.Streams.DataWriter;
	let w = new DataWriter();
	for (let i = 0; i < len; i++) {
		w.writeByte(b[i]);
	}
	return w.detachBuffer();
}
83918
function toBuffer(buf) {
  if (buf instanceof ArrayBuffer) {
    return arrayBufferToBuffer(buf);
  } else if (Buffer.isBuffer(buf)) {
    return buf;
  } else if (buf instanceof Uint8Array) {
    return new Buffer(buf);
  } else {
    return buf; // type unknown, trust the user
  }
}