_cloneTypedArray.js 527 B

12345678910111213141516
  1. var cloneArrayBuffer = require('./_cloneArrayBuffer');
  2. /**
  3. * Creates a clone of `typedArray`.
  4. *
  5. * @private
  6. * @param {Object} typedArray The typed array to clone.
  7. * @param {boolean} [isDeep] Specify a deep clone.
  8. * @returns {Object} Returns the cloned typed array.
  9. */
  10. function cloneTypedArray(typedArray, isDeep) {
  11. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  12. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  13. }
  14. module.exports = cloneTypedArray;