Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_cloneBuffer.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. var root = require('./_root');
  2. /** Detect free variable `exports`. */
  3. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  4. /** Detect free variable `module`. */
  5. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  6. /** Detect the popular CommonJS extension `module.exports`. */
  7. var moduleExports = freeModule && freeModule.exports === freeExports;
  8. /** Built-in value references. */
  9. var Buffer = moduleExports ? root.Buffer : undefined,
  10. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  11. /**
  12. * Creates a clone of `buffer`.
  13. *
  14. * @private
  15. * @param {Buffer} buffer The buffer to clone.
  16. * @param {boolean} [isDeep] Specify a deep clone.
  17. * @returns {Buffer} Returns the cloned buffer.
  18. */
  19. function cloneBuffer(buffer, isDeep) {
  20. if (isDeep) {
  21. return buffer.slice();
  22. }
  23. var length = buffer.length,
  24. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  25. buffer.copy(result);
  26. return result;
  27. }
  28. module.exports = cloneBuffer;