mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
21 lines
604 B
JavaScript
21 lines
604 B
JavaScript
define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
|
|
|
|
/**
|
|
* Creates a clone of `typedArray`.
|
|
*
|
|
* @private
|
|
* @param {Object} typedArray The typed array to clone.
|
|
* @param {boolean} [isDeep] Specify a deep clone.
|
|
* @returns {Object} Returns the cloned typed array.
|
|
*/
|
|
function cloneTypedArray(typedArray, isDeep) {
|
|
var arrayBuffer = typedArray.buffer,
|
|
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
|
|
Ctor = typedArray.constructor;
|
|
|
|
return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
|
|
}
|
|
|
|
return cloneTypedArray;
|
|
});
|