mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
20 lines
443 B
JavaScript
20 lines
443 B
JavaScript
import Uint8Array from './_Uint8Array';
|
|
|
|
/**
|
|
* Creates a clone of `buffer`.
|
|
*
|
|
* @private
|
|
* @param {ArrayBuffer} buffer The array buffer to clone.
|
|
* @returns {ArrayBuffer} Returns the cloned array buffer.
|
|
*/
|
|
function cloneBuffer(buffer) {
|
|
var Ctor = buffer.constructor,
|
|
result = new Ctor(buffer.byteLength),
|
|
view = new Uint8Array(result);
|
|
|
|
view.set(new Uint8Array(buffer));
|
|
return result;
|
|
}
|
|
|
|
export default cloneBuffer;
|