mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
19 lines
516 B
JavaScript
19 lines
516 B
JavaScript
import cloneBuffer from './_cloneBuffer';
|
|
|
|
/**
|
|
* 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 buffer = typedArray.buffer,
|
|
Ctor = typedArray.constructor;
|
|
|
|
return new Ctor(isDeep ? cloneBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
|
|
}
|
|
|
|
export default cloneTypedArray;
|