_cloneDataView.js 507B

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