cloneDataView.js 535 Bytes
Newer Older
1
import cloneArrayBuffer from './cloneArrayBuffer.js';
徐立's avatar
徐立 committed
2 3 4 5 6 7 8 9 10 11

/**
 * Creates a clone of `dataView`.
 * 创建“dataView”的克隆
 * @private
 * @param {Object} dataView 要克隆的数据视图.
 * @param {boolean} [isDeep] 指定深度克隆.
 * @returns {Object} 返回克隆的数据视图。
 */
function cloneDataView(dataView, isDeep) {
12 13
	const buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
	return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
徐立's avatar
徐立 committed
14 15
}

16
export default cloneDataView;